Skip to content

Declare and report outcomes

Whether a run executed is something the gateway can see: every call answered, nothing was blocked, the run was closed. Whether it did its job is something only the agent knows. A screening run that recorded a recommendation did its job; a tick that found nothing to screen executed perfectly and produced nothing. If the ledger cannot tell those apart, the success rate, the cost per task and the drift baselines all lie.

So the agent declares how its runs may end, and says on the last call of each run which of those it was. That is a declared outcome. The full model is in Declared outcomes; this page is how the screening agent does it.

screening_agent/outcomes.json ships inside the agent’s package. The same file is read by the agent (to validate what it sends), by setup.py (to declare it on the AI System) and, through the contract, by the gateway (to judge each run):

screening_agent/outcomes.json (abridged)
{
"outcomes": [
{
"id": "application_processed",
"label": "Application processed",
"counts_toward_baseline": true,
"variants": [
{"id": "loan_approved", "label": "Recommended: approve",
"expect": {"requires_capabilities": ["applications_set_recommendation"]}},
{"id": "loan_rejected", "label": "Recommended: decline",
"expect": {"requires_capabilities": ["applications_set_recommendation"]}},
{"id": "loan_referred", "label": "Recommended: refer",
"expect": {"requires_capabilities": ["applications_set_recommendation"]}},
{"id": "held_for_underwriter", "label": "Held for underwriter approval",
"expect": {"requires_capabilities": ["applications_add_note"]}},
{"id": "underwriter_decision_applied", "label": "Underwriter-approved decision applied",
"expect": {"max_actions": 2, "max_model_calls": 0}},
{"id": "underwriter_hold_renewed", "label": "Lapsed underwriter hold re-raised", "expect": {...}},
{"id": "underwriter_hold_closed", "label": "Underwriter hold closed with a note", "expect": {...}},
{"id": "sent_to_manual_review", "label": "Sent to manual review",
"expect": {"max_model_calls": 0, "requires_capabilities": ["applications_hand_off"]}}
]
},
{
"id": "no_applications_available",
"label": "Nothing to screen",
"counts_toward_baseline": false,
"expect": {"max_model_calls": 0, "max_cost_usd": 0,
"forbids_capabilities": ["applications_set_recommendation",
"applications_add_note", "applications_hand_off"]}
},
{"id": "applications_dispatched", "label": "Applications handed to screening runs",
"counts_toward_baseline": false, "expect": {...}}
],
"dependencies": [
{"delegate": "brutor-demo-fraud-screener-agent", "capability": "screening.fraud_sanctions",
"expected_outcomes": ["screening_completed.clear", "screening_completed.review",
"screening_completed.hit"]}
]
}

Three things in it carry most of the weight:

  • counts_toward_baseline. application_processed is work; the two tick outcomes are not. A no-work run never counts as a success of the work and never dilutes cost per processed outcome.
  • Variants. The recorded recommendation is a variant, so the outcome mix (approve / decline / refer / held) is a signal of its own. An outcome with variants is never sent bare.
  • expect. What a run reporting this outcome must look like: a loan_approved that never called applications_set_recommendation, or a no_applications_available that spent money, is a finding. The agent cannot claim an outcome its own actions contradict.

setup.py step 9c PUTs the outcomes list, verbatim, before the contract is minted:

Terminal window
curl -X PUT http://localhost:5050/v1/admin/ai-systems/$G/outcomes \
-H "Authorization: Bearer $ADMIN_TOKEN" -H "Content-Type: application/json" \
-d "$(jq '{outcomes: .outcomes}' screening_agent/outcomes.json)"
{
"ai_system_id": "group-01M61N376V2RR6J2TV7Q7EVRET",
"outcomes": [
{"id": "application_processed", "label": "Application processed",
"counts_toward_baseline": true, "expect": null,
"variants": [{"id": "held_for_underwriter", "label": "Held for underwriter approval", ...}, ...]},
...
]
}

It PUTs only when the stored catalogue differs. The catalogue is part of the contract, so an unchanged re-run must not drift it, and a changed catalogue drifts it exactly once, to be approved. Every new AI System starts with a starter catalogue (task_completed, nothing_to_do); replace it with what your agent really produces. Admin UI: the outcomes are edited on the system’s Contract tab.

Contract → Outcomes for the Brutor Demo System: the declared catalogue, application_processed with its variants and the two no-work tick outcomes.

The last call of a run carries X-Brutor-Run-End: completed and the outcome. In the screening run that is record, and the outcome follows from the recommendation:

screening_agent/graph.py — the record node
outcome_id = RECOMMENDATION_OUTCOMES.get(final["recommendation"])
# approve → application_processed.loan_approved
# decline → application_processed.loan_rejected
# refer → application_processed.loan_referred
try:
gw.mcp_call(settings.applications_mcp_server_id, "applications_set_recommendation",
tool_args, run_end="completed", outcome_id=outcome_id, **hdr("record"))
except ApprovalRequired as held:
# held for a human: the note becomes the closing call instead
gw.mcp_call(settings.applications_mcp_server_id, "applications_add_note",
{"application_id": state["application_id"], "note": note},
run_end="completed", outcome_id=HELD_FOR_UNDERWRITER, **hdr("record"))
POST /v1/proxy/mcp/mcp-01M61N37VYTSY0ETNQWW0DMRFY
x-brutor-run-id: bds-APP-20261028-004-01M61Q2W7ZK3DN6E8R4T5V9XB2
X-Brutor-Step-Id: decide
X-Brutor-Turn-Id: t2
X-Brutor-Run-End: completed
X-Brutor-Outcome-Id: application_processed.loan_approved

The client validates the id before the call is sent, against the same file:

screening_agent/outcomes.py
# grammar: ^[a-z0-9_-]{1,48}(\.[a-z0-9_-]{1,48})?$
def validate(value: Any) -> str:
"""The id, if it is well formed and declared by this agent's catalogue;
otherwise raise (UndeclaredOutcome is a ValueError)."""
check_grammar(value)
if value not in full_ids(): # every declared <outcome>[.<variant>]
raise UndeclaredOutcome(f"outcome {value!r} is not declared in {CATALOGUE_FILE.name}; ...")
return value

and gateway.headers() refuses an outcome without X-Brutor-Run-End: completed, or with any other terminal state. A failed run reports no outcome. Errors are execution, not outcomes: a run that errored is closed errored and the gateway records its error cause (blocked_by_policy for a guardrail or policy refusal).

How the run ended Closing call Outcome
Recommendation recorded applications_set_recommendation application_processed.loan_approved / loan_rejected / loan_referred
Recommendation held for an underwriter applications_add_note application_processed.held_for_underwriter
Approved decision applied applications_set_recommendation + token application_processed.underwriter_decision_applied
Lapsed hold re-raised applications_set_recommendation application_processed.underwriter_hold_renewed
Hold closed with a note applications_add_note application_processed.underwriter_hold_closed
Handed off to manual review applications_hand_off application_processed.sent_to_manual_review
Tick, nothing to screen applications_list_pending no_applications_available
Tick, work handed to per-application runs applications_list_pending applications_dispatched
Anything failed the failed call, or POST /v1/runs/{root}/end none, state errored

Sometimes the run cannot close on its last call: a node raised, or the closing call answered 202. The client then closes explicitly:

Terminal window
curl -X POST http://localhost:8100/v1/runs/$ROOT/end \
-H "Authorization: Bearer $BRUTOR_API_KEY" -H "Content-Type: application/json" \
-d '{"state": "errored"}'

$ROOT is the x-brutor-run-id response header from an earlier LLM call of the run, which the client keeps. Only LLM responses carry it, so a run that fails before any model call has answered cannot be closed this way. The agent logs a warning and the gateway sweeps the run after the AI System’s idle window as errored, because its last action failed. That is also why the tick run, which makes no model call, always closes with headers on a final listing call.

The gateway judges each reported outcome against the active contract’s catalogue and records an outcome_conformance (declared, undeclared, unreported) on the run. Together with the execution state and counts_toward_baseline, that gives every run a run class, and the run class is what the Signals read: completion rate, cost per processed outcome, run length per outcome, the outcome mix and its drift. Details: Run lifecycle and Declared outcomes.

Signals → Outcomes for the Brutor Demo System: the outcome mix by declared outcome and variant, with run class.

Next: human oversight, where the held outcomes come from.