The building blocks
See the Glossary for every other term.
The session lifecycle
A session has two fields that describe where it is.status is the coarse state, and execution_state says what the agent loop is doing right now. The diagram shows the execution_state values, plus the failed and cancelled values of status.
What each state tells you:
- queued: The agent already has as many root sessions running as its
max_concurrent_sessionsallows. The session waits for a slot. Child sessions never count toward the cap. - provisioning: The sandbox is being prepared. This normally takes under a minute. If compute isn’t ready within five minutes, the session fails with
sandbox_provision_timeout. - running: The agent or one of its tools is working.
- idle: Nothing is running.
stop_reasonsays why:end_turn,sleeping,awaiting_subagents,outcome_unmet,max_iterations,interrupted, and others. An idle session keeps its sandbox until the environment’s idle policy stops it. - completed: The work met its outcome.
stop_reasonisoutcome_satisfied. - failed and cancelled: The session stopped on an error or a hard stop.
failureexplains a failure.
What happens when you start a session
- You call
startSession, or click Launch session in the console, with an agent, an environment, and a task. The request returns202 Acceptedright away with asession_id. - The session freezes the current agent version, the environment, and the credentials you granted.
- The sandbox is provisioned and prepared with the environment’s verified setup, if it has a setup script. Session credentials are withheld from the setup script.
- The agent works through model turns and tool calls. Each step is recorded as an event you can read or stream.
- At the end of every turn, the agent’s deliverables are collected. If the session has an outcome, the grader runs next.
- You read the transcript, the verdict, and the cost from the same session record.
How credentials reach the agent
Credentials never go in a prompt. You store them in a vault, or connect an app on the Integrations page, grant them to an agent or a session, and each type is delivered in its own way.
Grant only what the task needs. A session can narrow its credentials to a list of specific items with
credential_refs. Prefer an MCP credential whenever the service speaks MCP, because its value never enters the sandbox. See Vaults and Security.
How grading works
An outcome turns “the agent stopped” into “the work is done”. You give it an objective and a rubric of checkable criteria. After each turn, a separate grader scores every criterion. What you can rely on:- The grader sees the objective, the rubric, and the agent’s work. It never sees a separate opening
message, so you can give the agent context that isn’t part of what’s measured. - Each criterion gets
pass,fail, ornot_applicable, with a rationale and the event ids it relied on. max_iterationscaps grading passes. Omitted or0means the agent keeps revising until the grader is satisfied.- A session has at most one open outcome at a time. Define the next one after the current one is graded.
Where the work happens
Each session tree gets its own sandbox. The agent’s working directory is/workspace. Agents already know where to save deliverables, so you only need to name the file you want in the task or the rubric. Subagents and teammates share their root session’s sandbox and hand work over by file path. See Artifacts and Multi-agent.
Next steps
Quickstart
Run the whole flow once: key, environment, agent, graded session.
Agent setup
Choose the model, prompt, tools, skills, and credentials.
Sessions
Look up every start field and how to follow a session.
Security
See how sandboxes, network policy, and credentials are isolated.