Recommended use of Outcomes: writing the task and acceptance criteria, choosing iterations, detecting completion, and retrieving deliverables.
This page describes the recommended way to use Outcomes and walks through a complete example. For fields and mechanics, see Outcome Evaluation.
An Outcome that passes evaluation runs in this order:
Each criterion should describe one thing. Split "complete", "runnable", and "evidenced" into three criteria instead of combining them.
Tune the rubric with
Send
You can send the event when
The Session stays
Read
When the rubric requires a file, ask the Agent in
In this example the Agent computes the order count, the total amount, and the top-spending customer from an order CSV, writes them to
The evaluation thread inherits the Agent's tool permissions. Configure the tools the evaluation needs as
The task and the source data go in
Example response:
The wrap-up turn may still be running when
Output:
Event order for this example when the first evaluation passes (
If the Agent's first output does not pass,
Flow overview
An Outcome that passes evaluation runs in this order:
- The client sends
user.define_outcomewith the task indescriptionand the acceptance criteria inrubric. - The Agent works from
descriptionand the Session entersrunning. - The evaluation thread grades the output. The event stream emits
span.outcome_evaluation_start,span.outcome_evaluation_ongoing, andspan.outcome_evaluation_end. span.outcome_evaluation_end.resultissatisfied, andoutcome_evaluations[].completed_atis set on the Session object.- The Agent writes its final reply and the Session returns to
idle.
Task and acceptance criteria
description is the input of the Agent turn and rubric is used only by the evaluation thread. Neither side can read the other:
| Content | Location | Visible to |
|---|---|---|
| Task, deliverable path, output format, source data | description | Agent |
| Acceptance criteria, expected values, failure condition | rubric | Evaluation thread |
- If the task is written only in
rubric, the Agent cannot read it. - The evaluation thread cannot read
description. Put any expected values or source data the criteria depend on intorubric, and avoid criteria such as "check against the task description".
| Type | Example |
|---|---|
| Deliverable location | /data/report.html exists |
| Specific content | Contains throughput and latency figures, with at least one chart each |
| Evidence | Each bottleneck cites a code location or profiling data |
| Failure condition | failed when the file is absent from the sandbox and the Agent states it cannot finish |
Evaluation iterations
max_iterations is the upper bound on the number of evaluations. Every evaluation consumes credits.
| Value | When to use |
|---|---|
1 | You only need a pass or fail verdict. If the evaluation does not pass, the Outcome reaches max_iterations_reached |
2–3 (default 3) | The Agent should revise based on the verdict. A revision turn starts automatically after needs_revision |
Greater than 3 | The task needs several revisions to converge |
max_iterations: 1 first. Raise the limit only after one iteration produces the correct verdict.
When to send
Send user.define_outcome in its own request, and only when the Session is idle and has no active Outcome:
status is idle and active_outcomes is 0. See Request constraints.
Detect completion
The Session stays running for the whole Outcome. Choose the condition by purpose:
| Purpose | Condition |
|---|---|
| Read the verdict | outcome_evaluations[].completed_at is not null |
| Read the Agent's final reply, or send the next event | Session status is back to idle |
explanation together with result. explanation contains the per-criterion assessment and can be shown to users or written to logs.
On the event stream, a session.status_idle with stop_reason.type set to requires_action means a tool call is waiting for confirmation, not that the Outcome has ended. See Tool confirmation.
Retrieve deliverables
When the rubric requires a file, ask the Agent in description to write it under /data/ and deliver it with DeliverArtifacts. A successful delivery emits agent.artifact_delivered on the event stream.
- A revision turn that delivers again creates a new File. Use the
file_idof the lastagent.artifact_deliveredto get the final version. - A file can take a few seconds after delivery to appear in the file list.
- The Agent may also return the result directly in its reply. Clients should handle both cases.
Example: order summary
In this example the Agent computes the order count, the total amount, and the top-spending customer from an order CSV, writes them to /data/summary.json, and delivers the file. The Outcome then evaluates whether the result is correct.
1. Create the Agent
The evaluation thread inherits the Agent's tool permissions. Configure the tools the evaluation needs as always_allow so that the Outcome runs without manual confirmation.
2. Create the Session
3. Define the Outcome
The task and the source data go in description; the expected values go in rubric. max_iterations is 2, which allows the Agent to revise once based on the verdict.
4. Read the verdict
5. Read the final reply
The wrap-up turn may still be running when completed_at is set. Wait for the Session to return to idle, then read the last agent.message:
6. Retrieve the deliverable
7. Archive the Session
Event stream
Event order for this example when the first evaluation passes (span.model_request_* and agent.thinking omitted):
span.outcome_evaluation_end has result set to needs_revision, followed by the revision turn's agent.tool_use, a new agent.artifact_delivered, and the evaluation events with iteration=1. The Session then holds two summary.json files, and the last agent.artifact_delivered refers to the final version.
Checklist
- The task, deliverable path, and output format are in
description; the acceptance criteria are inrubric. rubricdoes not depend on the content ofdescription; expected values or source data are written intorubric.- Every criterion can be verified on its own, and the failure condition is stated.
- The first release uses
max_iterations: 1to confirm that one iteration produces the correct verdict. - The read-only tools the evaluation needs are
always_allow, or the client handlesrequires_action. user.define_outcomeis sent in its own request, only when the Session isidleand has no active Outcome.- Retries of the same request carry an
Idempotency-Key. completed_atis used to detect that the Outcome has ended; the client waits for the Session to return toidlebefore reading the final reply or sending the next event.explanationis read and recorded.- The deliverable is retrieved with the
file_idof the lastagent.artifact_delivered.

