Create, run, inspect, and archive Cloud Agent Sessions.
A Session is a running workspace for an Agent. It binds an Agent snapshot to an Environment, optional resources, and optional Vault credentials. New Sessions start in
Existing Sessions use pinned runtime snapshots. Updating an Agent or publishing a new Agent version does not change them, and a Skill binding pinned to a numeric version stays on that version when a newer Skill version is published. To apply model, system prompt, tool, MCP server, Skill-binding, name, or description changes, call Update a session with the corresponding
A Session is a state machine. The
Two additional lifecycle markers are surfaced outside the
When the service classifies a model request error as recoverable, it retries automatically and the Session or Thread may temporarily enter
If you send a new
This is the most common pitfall for new users. Always wait for
Create a Session with an existing
The create response is a Session object. It includes
Attach files, repositories, and Memory Stores in the
To add a file after creation, use the Add a Session resource API. Current CAS supports post-create add only for file resources. Use the resource list/get/update/delete endpoints to inspect, rotate a GitHub token, or remove resources.
Send
The send-events endpoint returns HTTP 200 with
Use the event stream for live updates:
The stream emits Server-Sent Events with
List responses use
Session list uses
Managed-agent Sessions can have a coordinator thread and child threads. Thread endpoints use the public
Child threads can be archived with
Archive a Session when it should no longer be used:
Delete a Session when you need removal confirmation:
Delete returns:
The cancel endpoint returns
Sessions support multi-turn conversations. The recommended pattern is:
Q: What happens if I send a message to a
idle; send events to start work.
Dynamic runtime configuration updates
Existing Sessions use pinned runtime snapshots. Updating an Agent or publishing a new Agent version does not change them, and a Skill binding pinned to a numeric version stays on that version when a newer Skill version is published. To apply model, system prompt, tool, MCP server, Skill-binding, name, or description changes, call Update a session with the corresponding agent fields. Skill bindings with an omitted version or "latest" follow the newest Skill version at sandbox preparation time.
Session Status Lifecycle
A Session is a state machine. The status field on a Session resource takes one of the following values:
| Status | Description | Transitions to |
|---|---|---|
idle | Session is idle and ready to receive a message | running, terminated |
running | Agent is processing a turn | idle, rescheduling, terminated |
rescheduling | A model request hit a recoverable error and the service is retrying automatically; the current turn is still active | running, idle, terminated |
terminated | Session has been terminated (final state) | — |
status field:
- Archived: signalled by a non-null
archived_attimestamp. Thestatusvalue itself does not change toarchived— the Session remains readable but rejects new events. - Cancel response: the
POST /api/v1/cloud/sessions/{id}/cancelendpoint always returns a fixed body literal"status": "canceling". This is a response shape, not a Session status — the persistedstatusreverts toidleonce the turn aborts.
1
Created → idle
A new Session starts in
idle, awaiting input.2
idle → running
Sending a
user.message event moves the Session into running.3
running → idle
When the turn completes, the Session returns to
idle. Repeat for each turn.4
running → idle (after cancel)
Cancelling a running Session aborts the turn and the Session returns to
idle. The cancel response body uses a fixed "status": "canceling" literal regardless of the persisted status. The Session remains reusable.5
running → rescheduling → running / idle
A Session may temporarily enter
rescheduling during an automatic model retry. It returns to running when the next attempt starts, or to idle when the current turn ends.6
archived / terminated (terminal)
Archival (via
archived_at) or termination ends the Session permanently — it cannot be resumed.Automatic model request retries
When the service classifies a model request error as recoverable, it retries automatically and the Session or Thread may temporarily enter rescheduling. This is still part of the current turn. The client does not need to resend user.message; keep the event stream open and wait for the status to return to running or idle. If an error occurs after the model has produced a response chunk, the service does not replay the request, avoiding duplicate output or tool calls.
If session.error is received, use error.retry_status.type to determine whether the service will retry. Use subsequent Session/Thread status events as the source of truth for the final outcome.
Cancel Semantics
- Cancel on
idle: No-op. Returns HTTP200and the status staysidle. - Cancel with an active turn: Applies in both
runningandrescheduling. Returns HTTP202; the response status iscanceling, and the Session returns toidleonce the turn aborts. - After cancel: The Session remains reusable — send the next
user.messageto start a new turn.
Only
archived and terminated are terminal states. A cancelled Session always returns to idle and can continue accepting messages.Sending Messages While a Turn Is Active (409 Error)
If you send a new user.message while a Session is processing a turn, including while it is running or rescheduling, the API returns HTTP 409:
session.status_idle before sending the next message, or cancel the current turn first.
Create a Session
Create a Session with an existing agent and environment_id:
agent, environment_id, status, resources, vault_ids, deployment_id, outcome_evaluations, stats, usage, environment_variables, archived_at, created_at, and updated_at. usage.total_credits is a cumulative snapshot of credits consumed by recorded model calls and is floored to at most 2 decimal places.
See Create a session for the environment_variables string-to-string map format and validation rules.
Attach Resources at Creation
Attach files, repositories, and Memory Stores in the resources array:
Send Messages
Send user.message events through the Events API. content must be a non-empty array of content blocks:
{"data":[...]}. It accepts these client event types: user.message, user.interrupt, user.tool_confirmation, user.tool_result, user.custom_tool_result, and user.define_outcome.
Read Events
Use the event stream for live updates:
id, event, and data. The stream endpoint supports the Last-Event-ID header for reconnection replay; event type query filters are not currently supported.
Use the list endpoint for history and pagination:
data and next_page.
Read and Update Sessions
page / next_page pagination and supports filters such as agent_id, agent_version, deployment_id, memory_store_id, statuses, and created_at[...].
Threads
Managed-agent Sessions can have a coordinator thread and child threads. Thread endpoints use the public session_thread shape and do not include legacy thread fields such as role, name, agent_id, agent_version, or stop_reason.
POST /api/v1/cloud/sessions/{session_id}/threads/{thread_id}/archive. Current CAS returns 409 when asked to archive the coordinator/main thread.
Lifecycle
Archive a Session when it should no longer be used:
{"id":"...","type":"session","status":"canceling"}. It responds with 202 Accepted when there is an active turn to cancel, and 200 OK (no-op) when the Session is already idle.
Multi-Turn Conversation Workflow
Sessions support multi-turn conversations. The recommended pattern is:
- Send a
user.messageevent. - Listen to the SSE stream for updates.
- Wait for the
session.status_idleevent. - Send the next
user.message.
Always wait for
session.status_idle before sending the next message. Sending a message while the Session is still running returns HTTP 409.Best practices
- Pin Agent versions — In production, always create Sessions with
{"id": ..., "type": "agent", "version": ...}so Agent updates do not change Session behavior unexpectedly. - Use metadata — Record business context (task ID, trigger source, etc.) in the
metadatafield for traceability and debugging. - Cancel promptly — Cancel Sessions you no longer need to free compute resources.
FAQ
Q: What happens if I send a message to a running Session?
A: The API returns HTTP 409 with type: "invalid_request_error" and the message "Session is currently processing a turn. Cancel the current turn or wait for completion." Either cancel the current turn or wait until the Session returns to idle before sending the next message.
Q: Can I still use a Session after cancelling?
A: Yes. After cancel, the Session transitions from canceling back to idle. You can continue the conversation by sending the next user.message. Only archived and terminated are terminal states.
Q: How do I get the full conversation history?
A: Use GET /api/v1/cloud/sessions/{id}/events to retrieve all events for the Session, including user messages and Agent responses.
Q: How do I reconnect after an SSE disconnect?
A: Pass the Last-Event-ID header when reconnecting to the SSE stream endpoint. The server will replay events from after that ID.
Q: GET /api/v1/cloud/environments returns an empty array?
A: Check that your PAT or SAT has the required permissions for the target workspace. Environment access is scoped to the authenticated subject's permissions.

