id. The optional max_steps and max_time_s caps bound how long it runs before the agent is asked for a final answer.
id, which you poll for progress and the answer as in the Quickstart. For a one-shot run, the helper below blocks until the agent finishes and hands back the result.
Reading the answer
The simplest is the session snapshot.GET /sessions/{id} returns latest_answer, the agent’s most recent final answer, or null until it first answers. It needs no cursor and never goes stale, so once a run has settled it is the easiest way to read the answer.
While a run is active, GET /sessions/{id}/changes carries the same answer alongside the live event feed. Because changes returns only what is new since your cursor (and 204 No Content when nothing new has arrived), the answer rides the page that delivers the final events. Keep polling until the session reaches a terminal state and you have drained the remaining events; a 204 means no new events yet, not no answer. The SDK helpers (run_session / wait_for_session) run this loop and drain to the end for you.
Don’t poll status for the answer: it never carries one.
Session object
Lifecycle
Every session moves through the same state machine, whichever agent runs it:Overrides
Reuse a catalog agent but adjust it for a single run withoverrides, a map on the create-session body. Rather than defining a new agent, you point at fields of the resolved request. Each key is a dotted path, and its value replaces whatever that path resolves to, applied after agent is expanded from its catalog id.
- Dots walk into objects.
agent.instructionssets behavior,agent.modelswaps the serving model, andagent.answer_formatpins a structured answer. - A
[field=value]selector picks a list member.agent.environments[kind=web]selects the web environment, soagent.environments[kind=web].start_urlsets just its start page andagent.environments[kind=web].modeswitches how it reads the page. - Values are type-checked. Each value must match the type of the field its path targets. An unknown path or a wrong type is rejected with
422at creation, before the agent runs.
Structured output
By default the agent’s answer is free-form text. Set ananswer_format (a JSON Schema) on the agent, or pass a Pydantic / Zod schema to the SDKs, and the final answer comes back as typed, validated data instead. See Structured output.
Listing and filtering
GET /api/v2/sessions pages through your sessions, newest first, with filters you can combine:
items holds the resources, page echoes the page number you asked for, and total counts all matches. Responses don’t echo size back, so track it yourself; there are more pages while page * size < total. This endpoint caps size at 100 and sorts by -created_at (newest first) unless you pass sort=created_at. See List sessions for the full parameter reference.