Skip to main content
A session is one run of an agent against a task. It pins the agent version and environment at start, runs in its own sandbox, and keeps a transcript you can read, stream, and resume. The TypeScript samples assume the rl client from Client setup.

Before you begin

  • You need the organization developer or admin role to start, message, interrupt, cancel, or delete sessions. The organization user role can list and read sessions. The billing role cannot see sessions. See Organizations and roles.
  • For API calls, create a key under API keys. See API keys.
  • You need an agent and an environment. If the environment has a setup script, that script must have passed a current setup run.

How a session runs

Every session has two fields that change as it runs. status says whether the session is still live. execution_state says what the agent loop is doing right now. When the loop is not running, stop_reason says why. provisioning, queued, running, and idle are execution states of a session whose status is active. completed, failed, and cancelled are statuses. They are terminal: the session does not change on its own after reaching one. A follow-up message to a root session in a terminal status starts it again from provisioning. After a cancel, the session gets a new sandbox. After a completed or failed run, the sandbox is reused when possible.

Start a session

  1. In the sidebar, click Sessions, then click Launch session.
  2. Under Agent, select an agent and an Environment.
  3. Under Task, write the Opening message. To grade the run, turn on Grade this session against a rubric and enter a Rubric.
  4. Optionally, choose vaults under Credential access, a mode under Team, and add Custom metadata.
  5. Click Launch session.
The response is 202 Accepted:
202 means the session was accepted, not that it is running. Use session_id with Get a session or stream its events. status_path is relative to https://api.recursion.labelbox.com/managed-agents. The Location response header carries the full path under /managed-agents/v1/.

Request fields

Metadata can only be set at start. It is returned on the root session by getSession and listSessions, and you can filter on it. There is no call to change it later. See Session operations for metadata search.

Retry a start safely

startSession requires an Idempotency-Key header. Use a value that identifies the work, such as a job id, and reuse it on every retry of that start. Keys are shared across your whole organization, so include something unique to the caller. A key is remembered for about 24 hours. After that, the same key may start a new session. The session id is derived from the key, so a replay always returns the same session_id.

What success means

When the agent loop finishes, status becomes completed whether or not the task succeeded. Read execution_state and stop_reason to know the result. When a session fails, failure holds phase, code, message, retryable, category, and at. category is transient (retry), caller_error (fix the request or setup), or internal.

Wait for a session to finish

Stream the session’s events for live progress; the stream closes when the session reaches a terminal status. See Stream events. To poll instead, stop on any terminal status, not only completed, and also stop when the session needs you.
Open the session from Sessions. The transcript updates live, and the status badge shows the current state.
An interrupted or sleeping session stays active. A loop that waits only for a terminal status keeps waiting until someone sends a message, the wake time arrives, or the session is cancelled.

Get a session

view=full (the default) returns the whole session, including the agent and model snapshots and the resolved configuration. view=summary omits agent_snapshot, model_snapshot, and config, which makes polling cheaper. Any other view value returns 400.
In Sessions, click a session. The Session tab shows its state, agent, environment, and Custom metadata.

List sessions

listSessions returns sessions in your organization, most recently updated first.
In the sidebar, click Sessions. Filter with Status, Agent, Agent tags, and Metadata, or search by id, agent, state, or metadata.
A page token is valid for one hour and only with the same filters and limit. Changing either returns 400 invalid_request; start again without a token. Because the list is ordered by last update, a session that changes while you page can appear twice or be skipped. Deduplicate by session_id, or filter on a value that does not change. List rows are summaries. They leave out snapshots, and config is empty. Token and cost totals are not included; see Usage and cost.

Send a follow-up message

A message to a running session is read at its next turn. A message to an idle or finished root session resumes it. The full send options, including the delivery states in the response, are in Events.
Open the session, type in Message the agent…, and click Send. While the agent is working the button reads Queue.
Only root sessions resume. A message to a subagent session in a terminal status returns 409 conflict; message the root session instead.

Send an image

To show the agent a screenshot or chart that isn’t in your Files library, upload it to the session, then reference it from a message. The model sees the image when its model accepts images.
In the session’s message box, click Attach image, choose the image, write your message, and click Send. To use an image from your library, click Attach from Files.
The upload returns 201 with the stored image:
  • Send PNG, JPEG, or WebP. The type is detected from the bytes. You can also send the bytes as the raw request body with an image Content-Type.
  • The uri works only in the session it was uploaded to. An upload that no message references is removed after a while.
  • An image the session’s image limits refuse returns 400 with the reason. See Limits.

Interrupt a session

An interrupt stops the current model call right away and gives a running tool a short grace period to stop. If messages are queued, the newest starts a fresh turn. Otherwise the session stays active and goes idle with stop_reason: interrupted, ready for your next message. The sandbox stays up.
While the agent is working, open the session and click Interrupt under the last event.
interrupted: false means nothing was running to stop. That is not an error.

Interrupt and send a new message

interruptAndSendSessionMessage stops the current turn and starts a fresh one with your message in one call. Send message for plain text, or content for content blocks; content wins if you send both.
Type your message in Message the agent… and click Interrupt & send. The button appears while the agent is working.
The response has the same shape as a send, with events_accepted: 2: the interrupt and your message.

Cancel a session

Cancelling stops the session now. In-flight work is abandoned, the sandbox is torn down, and the status becomes cancelled with stop_reason: interrupted. Events, outcomes, and deliverables stay readable. A follow-up message to a cancelled root session starts it again in a new sandbox.
  1. Open the session, then open Session actions and click Hard stop….
  2. Click Stop now.
The response is the same when the session was already finished, so it is safe to repeat. Sandbox teardown can finish shortly after the response.

Delete a session

Deleting removes the session and all its subagent sessions from lists and reads, stops any running work, and tears down the sandbox. The transcript is retained, not erased. You cannot undo a delete.
  1. Open the session, then open Session actions and click Delete session….
  2. Click Delete.

Get the deliverables

Ask for deliverables by name in your message, for example “write a risk summary named risks.md”. Agents already know where to save files so they are kept after the session ends. Only files saved there are kept; anything else in the sandbox is lost when it is torn down. Download them from the session’s Files tab, or with listFiles and getFileContent. See Deliverables and artifacts and Download session deliverables. To give a session input files, attach them at start with resources or while it runs. See Files.

What can go wrong

Every error uses the same body: code, message, and details with field, requestId, and retryable. See Errors.

Limits

  • Metadata: 32 entries per session, 64-character keys, 512-character values.
  • Referenced sessions: 10 per start.
  • List page size: 1000.
  • Provisioning: 5 minutes.
  • Concurrency is set per agent with max_concurrent_sessions.
See Limits for the rest.

Next steps

Events

Send messages, read the transcript, and stream live events.

Session operations

Search metadata, inspect compute, ask the analyst, and read the tree.

Outcomes

Define what success means and let a grader check it.

Deliverables and artifacts

Ask for deliverables and see how they’re kept.