Managed Agents API requests require the
managed-agents-2026-04-01 beta header, except memory store endpoints, which use agent-memory-2026-07-22 instead. The SDK sets the correct beta header automatically. See Beta headers.Create a rubric
A rubric is a markdown document describing per-criterion scoring. The rubric is required.Tips for writing effective rubrics
Tips for writing effective rubrics
Structure the rubric as explicit, gradeable criteria, such as “The CSV contains a price column with numeric values” rather than “The data looks good.” The grader scores each criterion independently, so vague criteria produce noisy evaluations.If you don’t have a rubric on hand, give the evaluator model an example of a known-good artifact and ask it to analyze what makes that content good, then turn that analysis into a rubric. This middle-ground approach often produces better results than writing criteria from scratch.
user.define_outcome (see Create a session with an outcome), or upload it through the Files API for reuse across sessions.
Uploading through the Files API requires a beta header that grants Files API access. Your Managed Agents beta header grants this on its own, so you don’t need to send
files-api-2025-04-14 alongside it. The curl example passes its headers explicitly.Create a session with an outcome
The following examples create a session for an existing agent and environment (both created separately), then send auser.define_outcome event. The agent begins work immediately. No additional user message event is required.
You can also define the outcome in the create request itself: pass a single
user.define_outcome event in initial_events to create the session and start work toward the outcome in one call.Outcome events
Progress on an outcome-oriented session is surfaced on the events stream.agent.*events (such as messages and tool use) show progress toward the outcome.span.outcome_evaluation_*events are only emitted for outcome-oriented sessions and show the number of iteration loops and the grader’s feedback process.- You can also send
user.messageevents to an outcome-oriented session to direct the agent’s work as it progresses, but it isn’t required: the agent works toward the outcome on its own, iterating until it succeeds or runs out of iterations. - A
user.interruptevent pauses work on the current outcome and marks thespan.outcome_evaluation_end.resultasinterrupted, allowing you to kick off a new outcome. - After the final outcome evaluation, the session can be continued as a conversational session, or a new outcome can be started. The session retains history of the prior outcome.
Define outcome user event
Only one outcome is supported at a time, but you may chain outcomes in sequence. To do this, send a new
user.define_outcome event after the terminal span.outcome_evaluation_end event of the previous outcome.processed_at timestamp and outcome_id.
Outcome evaluation start
Emitted once the grader starts an evaluation over one iteration loop. Theiteration field is a 0-indexed revision counter: 0 is the first evaluation, 1 is the re-evaluation after the first revision, and so on.
Outcome evaluation ongoing
Heartbeat emitted while the grader runs. The grader’s internal reasoning is opaque: you see that it’s working, not what it’s thinking.Outcome evaluation end
Emitted when an outcome evaluation cycle ends: after the grader finishes evaluating one iteration, or when the session is interrupted while an outcome is active. Theresult field indicates what happens next.
Check outcome status
You can either listen on the event stream forspan.outcome_evaluation_end, or poll GET /v1/sessions/{session_id} and read outcome_evaluations[].result. Until an evaluation completes, result reports pending, running, or evaluating:
Retrieve deliverables
The agent writes output files to/mnt/session/outputs/ inside the sandbox. Once the session is idle, fetch them through the Files API scoped to the session.
Filtering by
scope_id requires the managed-agents-2026-04-01 beta header on the files request. The SDK files methods send only the files beta automatically, so the examples pass it explicitly.Next steps
Authenticate with vaults
Register per-user credentials when creating sessions.
Session event stream
Send events, stream responses, and interrupt or redirect your session mid-execution.
Adding files
Upload files and mount them in your sandbox for reading and processing.