Skip to main content
Files are your organization’s file library. It holds two kinds of file:
  • Uploads. Files you add, such as a data set, a spec, or a rubric. Attach an upload to any number of sessions, read-only.
  • Session outputs. Deliverables an agent saves in a session. They’re kept with the session, and you can download them.
The TypeScript samples assume the rl client from Client setup. Uploading and downloading bytes are plain HTTP calls, so those samples use cURL.

Before you begin

  • Listing and downloading files needs read permission. Uploading needs create, attaching to or detaching from a session needs update, and deleting needs delete. Organization developers and admins have all of them. See Organizations and roles.
  • Attaching files needs an environment with a sandbox, which every environment has by default.

How files reach a session

An attached file is copied into the sandbox under /workspace/.managed-agents/files, read-only. The agent knows it’s there and can read it with read_file or from a shell. Each attachment takes the file’s content as it is when you attach it, so later changes to the library don’t change a running session.

Upload a file

  1. In the sidebar, click Files, then click Upload file.
  2. Choose one or more files.
  3. Optionally set Expires to 1 day, 7 days, 30 days, or 90 days. The default is Never.
  4. Optionally describe the files in Purpose. It’s stored with each file.
  5. Click Upload.
The response is 201 with the file:
Send the bytes as the file part of a multipart/form-data body. The part’s file name becomes filename, and its Content-Type becomes media_type; when the part has no type, the type is detected from the file name and then the bytes. Optional parts:
  • metadata: a JSON object, stored with the file and returned unchanged. A value that doesn’t parse is refused.
  • expires_in_seconds: from 3600 (an hour) to 7776000 (90 days). After that the file can’t be attached or downloaded. Leave it out for a file that doesn’t expire. You can’t change it later.

List and find files

Files lists every file with its Name, Type, Size, Added, and Expires. Search by name, media type, or id, and use Filter by source to show All files, Uploads, or Session outputs.
Files come back newest first, 200 per page by default and up to 1,000, with next_page_token while more follow. Pass it back as page_token with the same filters. An expired file stays listed, with expires_at in the past, until it’s removed after a grace period. To show only files you can still attach, skip files whose expires_at has passed. getFile returns one file’s metadata.

Attach files when a session starts

Name files in resources when you start the session. They’re in the sandbox before the agent’s first step.
  1. In the sidebar, click Sessions, then click Launch session.
  2. Choose the agent and environment, and write the opening message.
  3. Under Files, add each file and, optionally, the path it should have.
  4. Click Launch session.
relative_path places the file under the files directory; it defaults to the file’s own name. It must be unique in the session and can’t contain . or .. segments. The start is all-or-nothing: one unknown, expired, or out-of-organization file_id refuses the whole request with 404, and no session is created.

Attach and detach files while a session runs

  1. Open the session and choose the Files tab in the side panel.
  2. Click Attach files, choose the files, and click Attach.
  3. To detach one, open its row’s menu and choose to detach it.
Attach returns 201 with only the resources it added:
What success means: the file is placed in the sandbox on the session’s next tool call, and the agent can see it from its next turn. mount_path appears on the resource once it’s in place. Read it with listSessionResources or getSessionResource.
  • Attach is all-or-nothing. An unknown file refuses the batch with 404. A path that collides with another attachment, or nests inside one, refuses it with 409.
  • Attach to the root session of a multi-agent tree. A subagent or teammate session answers 409; everyone in the tree shares the root’s sandbox.
  • You can attach to a finished root session. Its next message resumes it with the file already in place.
  • Detach stops listing the file. A copy already in the sandbox stays, because the agent may be reading it.

Show a file to the agent in a message

To have the agent look at an image or read a short document as part of a message, name the file in the message instead of attaching it. The file is read when the message is accepted.
In the session’s message box, click Attach from Files, choose an image or a text document, then send the message.
Use "type": "image" for a PNG, JPEG, or WebP image the model sees, and "type": "document" for a text file, which is placed in the message as text. To send an image that isn’t in your library, see Send an image.

Download session deliverables

Every deliverable an agent saves in /workspace/.managed-agents/outputs is kept as a session output after each turn. See Deliverables and artifacts for what’s kept and when.
Open the session and choose the Files tab in the side panel. Outputs are listed with their paths. Click one to preview it, or download it. Files in the sidebar also lists every session’s outputs under Session outputs, with Open session on each.
A session output has source: "session_output", scope_session_id set to the root session, and its path under the outputs directory in metadata.path:
getFileContent returns the bytes with the file’s media type and a Content-Disposition that names it. It works the same for uploads and outputs. Subagent and teammate deliverables are listed under the root session. Compare the download with sha256 to check it.

Delete a file

Open the file’s row menu in Files, choose Delete file, and confirm.
The file stops being listed at once, and new attachments and downloads answer 404. Its stored content is removed after a grace period. Until then, a session that attached it before the delete still receives it on later turns and resumes; after that, the session continues without it and records a warning. To stop a running session using a file, detach it as well.

What can go wrong

For every error code, see Errors.

Limits

See Limits for deliverable capture limits and every other limit.

Next steps

Deliverables and artifacts

Ask for named deliverables and see how they’re kept.

Sessions

Start sessions, send messages, and attach images.

Outcomes

Grade sessions against a rubric, including one from a file.

Automations

Mount the same files into every automated run.