Skip to main content
An outcome tells the session what the end result should look like and how to measure its quality. The agent works toward that target, self-evaluating and iterating until the outcome is met. When you define an outcome, the harness automatically provisions a grader to evaluate the artifact against a rubric. The grader uses a separate context window to avoid being influenced by the main agent’s implementation choices. The grader returns an explanation summarizing which criteria passed or failed, or confirming that the artifact satisfies the rubric. That feedback is handed back to the agent for the next iteration.
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.
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.
Example rubric:
Pass the rubric as inline text on 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 a user.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.message events 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.interrupt event pauses work on the current outcome and marks the span.outcome_evaluation_end.result as interrupted, 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.
This is the event you send to initiate an outcome. It is echoed back on receipt, including a processed_at timestamp and outcome_id.

Outcome evaluation start

Emitted once the grader starts an evaluation over one iteration loop. The iteration 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. The result field indicates what happens next.

Check outcome status

You can either listen on the event stream for span.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.