Skip to main content
A session is one run of an agent on a task. It runs in its own sandbox, pins the agent version and environment it started with, and keeps a transcript you can stream, read, and continue.
You need an agent and an environment. If the environment has a setup script, it must have passed a current setup run. Starting, messaging, and stopping sessions needs the Developer or Admin role; the User role can list and read them. API calls use a key from API keys.

Start a session

Send the agent, the environment, and the task. Name the files you want back, so the agent saves them as deliverables.
  1. In the sidebar, click Sessions, then click Launch session.
  2. Under Configuration, select an Agent and an Environment.
  3. Under Task, write the Opening message: the task, the deliverables you want by name, and what done looks like.
  4. Optionally, choose vaults under Credentials, a mode under Team, and add Custom metadata.
  5. Click Launch session.
The session is accepted right away and starts in the background. The response is 202 Accepted:
Keep session_id. 202 means the session was accepted, not that it is running. status_path is relative to https://api.recursion.labelbox.com and already starts with /managed-agents, as does the Location response header. The Idempotency-Key header is required. Use a value that identifies the work, such as a job id, and send it again on every retry: the same request with the same key returns the same session instead of starting a second one.
Keys share one namespace across keyed mutations in your organization, so include the operation and work identity. Completed receipts last about 24 hours, pending claims can be reclaimed after about 1 hour, and deduplication is not guaranteed after expiry. The session id is derived deterministically from the durable receipt, so an exact replay returns the same session_id. See Idempotent mutations.

Watch it work

Stream the session’s events to follow along as the agent works. The stream replays what already happened, then stays open for new events, and closes when the session reaches a terminal status.
Open the session from Sessions. The transcript updates live, and the status badge shows the current state.
You see the agent’s steps as they happen. This output is abridged; each data line carries the full event.
Events lists every frame type and shows how to resume a dropped stream. To poll instead, read the session with view=summary and stop on any terminal status, not only completed, and also when the session needs you.
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.

What success means

When the agent loop finishes, status becomes completed whether or not the task succeeded. Read the final message and open the files it saved to judge the work. 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. Deliverables appear in the session’s Files tab. Files the agent leaves elsewhere stay in /workspace for later turns, even after a stopped sandbox is released, and can be used when the workspace reopens successfully, but they aren’t captured as deliverables. Deleting the session removes access to its workspace. See Deliverables and artifacts and Download session deliverables. To give a session input files, attach them in Launch session, with resources at start, or in the session’s Files tab while it runs.
In Sessions, click a session. The Session tab shows its state, agent, environment, and Custom metadata. A session an automation started also shows Started by: the Automation, the Trigger that fired, and the Run, each linking back to the automation. See Automations.With the API, 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.

Continue the conversation

Send a follow-up to add to the task or ask for changes. A running session reads it at its next turn. An idle or finished root session picks the work up again. 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. To change direction mid-turn, interrupt instead:
  • Interrupt stops the current model call and gives a running tool a short grace period to stop. The session waits, with its sandbox, for your next message.
  • Interrupt and send stops the current turn and starts a new one with your message, in one call.
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. In the console, click Interrupt under the last event while the agent is working.
The response is { "interrupted": true }. A session with nothing running (idle and not sleeping or waiting on its subagents, or already finished) answers 409 conflict, and nothing is recorded. interrupted: false means the stop was recorded but reaching the running work was not confirmed, usually because the run ended as the request arrived.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. In the console, type your message and click Interrupt & send, which appears while the agent is working.
The response has the same shape as a send, with events_accepted: 2: the interrupt and your message.

Send an image

To show the agent a screenshot or chart, attach it to 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. Send PNG, JPEG, or WebP; the type is detected from the bytes. An image the session’s image limits refuse returns 400 with the reason. See Limits.

Stop or delete a session

Cancel answers { "cancelled": true } and delete { "deleted": true }. You can cancel any session that is not completed, failed, or already cancelled, including an idle one. The cancel response is the same when the session was already finished, so it is safe to repeat. Sandbox teardown can finish shortly after the response.

Find sessions

listSessions returns sessions in your organization, most recently updated first. Filter by status, kind, agent, agent tags, or your metadata.
In the sidebar, click Sessions. The Status, Agent, Agent tags, and Metadata filters cover every session. The search box matches id, agent, state, or metadata on the page shown; paste a full session id to find a session on any page. Click a column header to sort the page.
root_only=true returns one row per run, without the subagent sessions under it. List rows are summaries: they leave out snapshots, config is empty, and token totals aren’t included. Each row carries the session tree’s costUsd and costState (see Usage and cost).
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.

How a session runs

Two fields describe a session. status says whether it’s still live. While it’s active, execution_state says what the agent loop is doing. When the loop isn’t 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 terminal statuses: 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, or from queued when the agent is at its cap. After a cancel, the session gets a new sandbox. After a completed or failed run, the sandbox is reused when possible.When a root session is stopped for review and no subagent is working, its sandbox is stopped with /workspace preserved, and restored from /workspace before the agent’s next tool call; processes it started are gone. A session whose setup ran on its own compute keeps its sandbox until the environment’s idle stop.

What can go wrong

The most common problems:
  • The session stays queued. The agent is at max_concurrent_sessions, or a slot freed while your tenant was out of credit. A queued session starts only when a slot is free and credit is available. Wait, cancel other sessions, raise the agent limit, or add credits.
  • 422 environment_not_verified on start. The environment’s setup script has not passed a current setup run. Run environment setup, then start again. See Environments.
  • status: completed but the task is not done. The loop finishing does not mean the task succeeded. Read the final message, then send a follow-up with what is missing.
Every error is a flat object with required code and message fields and optional details, which can include field, requestId, and retryable. See Errors.
Limits on metadata, referenced sessions, concurrency, and provisioning are in Limits.

Next steps

Events

Stream, send, and read every kind of session event.

Session operations

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

Files

Give a session input files and download its outputs.

Deliverables and artifacts

Ask for deliverables and see how they’re kept.