To start sessions, you need the Developer or Admin role in the organization. See Organizations and roles. Every session runs in an environment’s sandbox. See Environments.
Ask for a deliverable
Name the file and its format in the task, and say what it must contain. This session asks for a CSV and a short summary.- Console
- cURL
- In the sidebar, click Sessions, then click Launch session.
- Choose the Agent and Environment.
- In Opening message, describe the task and name the deliverables.
- Click Launch session.
202 Accepted:
write_artifact call answers with the path and “it is captured as a session output when this turn ends”. A call that includes metadata answers that the file was stored as a session output instead. When the session finishes, download the deliverables.
Prompt patterns that work
Prompt patterns that work
Label deliverables with metadata
An agent can attach key/valuemetadata when it calls write_artifact, for example {"kind": "report", "ticket": "OPS-12"}. The metadata is stored on the deliverable’s file, returned as metadata beside path when you list or get the file, and shown under Metadata in the file preview. Ask for it in the task: “Save summary.md with metadata kind set to summary and quarter set to Q3.”
Later sessions of the same agent can find deliverables by their metadata when the agent has File history on. See Agent file history.
Metadata rules
Metadata rules
- A write that includes
metadatais kept at once rather than at the end of the turn, so it doesn’t take time to save. - A write that includes
metadatareplaces the deliverable’s earlier metadata, and{}clears it. A write that leaves it out keeps it. - The metadata stays when the file is changed later by another tool or command.
- The rules are the same as for uploaded files: at most 32 keys, each up to 64 characters of letters, digits,
_,., and-, and at most 64 KiB of JSON in total. Thepathkey is reserved.
Show images inline
Ask the agent to share a chart or screenshot: “Plot weekly signups and share the chart.” The agent saves the image under/workspace and calls share_file.
- Console
- cURL
- In the sidebar, click Sessions, then open the session.
- Find the
share_filerow in the transcript and click the thumbnail.
artifact event carries the caption and the image.
What an image event looks like
What an image event looks like
url is omitted when none can be issued for that read. The image is always available through the authenticated session image endpoint, GET /managed-agents/v1/sessions/{sessionId}/images, with the image block’s uri as the uri query parameter.Download deliverables
Every kept deliverable is a file in your organization’s library withsource: "session_output", listed under the root session, including deliverables that subagents and teammates saved.
Open the session and choose the Files tab in the side panel. Outputs shows each deliverable with its path under the deliverables folder. Click it to preview it, and download it from the preview. Through the API, list a session’s deliverables with listFiles and scope_session_id, then download each with getFileContent. See Download session deliverables.
For a session an automation started, the run’s result also lists its deliverables with their fileIds once the run is finished.
Each output keeps its path under the deliverables folder, such as reports/q3.md. Saving to the same path again replaces the earlier version at the end of the turn, or at once when the write_artifact call includes metadata.
Other ways to use results
Other ways to use results
Where work happens
Files outside the deliverables folder stay in the session workspace for later turns when it reopens, but aren’t saved separately as deliverables or shown in the Files tab. Deleting the session removes access to its workspace.
Tools you'll see in transcripts
Tools you'll see in transcripts
Agents use these tools on their own. You can also name them in prompts.
write_artifact takes text. For a binary deliverable, such as a PDF or a spreadsheet, the agent creates the file with a command and saves it anywhere under /workspace/.managed-agents/outputs. Files placed there by any tool are kept the same way.What gets kept
At the end of each turn, once the agent stops and nothing is queued, the deliverables folder is checked and every new or changed file is kept. While files are being saved, the session header shows Saving files: 200 of 251. Saving goes on in batches until every new or changed file is saved, for up to about ten minutes. If time runs out, a batch saves nothing, or a message arrives while files are saving, a warning in the transcript says how many files were saved and how many wait: for example, “Saved 1,300 of 1,351 files. The other 51 will be saved after the agent’s next reply.” A message sent while files are saving lets the batch in progress finish, then the agent starts its reply; the remaining files are saved when that reply ends. A file that can’t be kept is reported as a warning; the session keeps running. A file that can’t be saved appears in Outputs as Not saved, with the reason in place of its size, for example Not saved: 1.5 GiB is over the 1 GiB limit. It has no download or preview, and an earlier saved copy of it is removed, so the Files page no longer lists it. Ask the agent to split or compress an oversized file. Once the file can be saved again, its row returns to normal.How files are kept
How files are kept
- Changes. A file saved again under the same path replaces the earlier version. A file that hasn’t changed isn’t kept twice.
- Children. Subagents and teammates share the root’s sandbox, so their deliverables count as the root session’s deliverables.
- Progress. While files save, the session adds
session_statusevents withevent_statussaving_filesand the countssavedandtotal, which cover only new or changed files: one when saving starts and at most one every 10 seconds after that. They are notices, not state changes: the session staysrunning. A turn with nothing new or changed adds none. - Problems are reported, not fatal. A file that can’t be kept adds a
session_statusevent withevent_statuswarning, the codesession_output_degraded, and a message naming the file. The session keeps running. A file refused once is not reported again until it changes. - No stale copies. If a kept file is later emptied, grows past the size limit, or becomes unreadable, its earlier kept copy is removed. The Outputs row says why the current file was not saved.
Limits
One deliverable can be at most 1 GiB on managed computes or 64 MiB on self-hosted workers. Each batch saves at most 200 files and normally 512 MiB. A single file over the batch byte budget can still be saved as its first file. More batches run while new or changed files remain, for about ten minutes; a batch already started may finish after that. Files that wait for a later turn are kept only if the session has one.Every deliverable limit
Every deliverable limit
A session also has an overall image budget, shared by every tool that returns images, of 500 images and 100 MiB. See Limits.
What can go wrong
The most common problems:- A deliverable is missing from the Files tab. It was saved outside the deliverables folder. Ask for it by name as a deliverable, or save it under
/workspace/.managed-agents/outputs. session_output_degradedwarning about the per-file limit. A deliverable exceeds the limit for its compute provider. Split or compress the file.share_filefails with “supports PNG, JPEG, and WebP images”. The file is another format, such as SVG or PDF. Ask the agent to render a PNG first.
Every deliverable error
Every deliverable error
Next steps
Files
Attach input files and download session outputs.
Referenced sessions
Read an earlier session’s deliverables from a new one.
Teams
Have several agents produce parts of one deliverable.
Research team tutorial
A team session that ends in a report.