Skip to content

Record whether a routed run's result counts - #80468

Merged
rabeckett merged 6 commits into
mainfrom
routing-outcome
Nov 23, 2026
Merged

rabeckett merged 6 commits into
mainfrom
routing-outcome

Conversation

@rabeckett

@rabeckett rabeckett commented Nov 23, 2026 •

Copy link
Copy Markdown
Collaborator

Fixes #79103

This records whether each routed run's result can teach a router anything about the model and effort the firewall selected. For a run that AWF routed and whose agent made requests, the conclusion job's unified session now has one routing.observation event. It is success or failure when the result counts, or skip with a reason: cancelled, infrastructure, rate_limited, pair_mismatch or unknown_evidence.

The event carries only the verdict, because the session already holds everything else, for every engine. AWF's records give the selection, whether each request ran as selected, and each request's priced cost. The verdict attributes requests with the rule routing analytics already applies (T-UAS-081):

  • requests that ran as selected are the main conversation;
  • a deviated request to a declared sub-agent's model is sub-agent work;
  • anything else either ran another model or effort (pair_mismatch) or cannot be attributed (unknown_evidence).

That rule moved into a shared attributeRequest helper in routing_analytics.cjs; the baseline estimate behaves exactly as before.

The rules put platform causes first, so a setup timeout or a 429 is never a model failure, and a run that succeeded is not re-examined for errors it recovered from. Platform evidence includes 5xx and 429 responses that AWF recorded for the agent's own requests. A success needs a successful agent job whose validated safe outputs include a terminal output (a valid noop counts), with threat detection reaching a clean result wherever it ran. A failure needs evidence that the selected pair failed on its own: an incomplete report, a step, token, credit or tool-denial limit (with or without output), a refusal or content filter in the main conversation that left no terminal output, or outputs the validator rejected. Output that threat detection flagged is skipped, and an incomplete report whose reason claims an infrastructure error counts neither way, since the agent can file that reason. Whether a run may update a routing history (reruns, pull request runs, experiment workflows) is left to the history writer.

The safe-output collector now records collectorInfrastructureCause: "safeoutputs_gateway_empty" in agent_output.json when the gateway registered no tools. Without it, that infrastructure failure looks the same as the agent's own invalid outputs.

Only the conclusion job computes the verdict, because only it has the final job results. The collector's entry point turns it on, so there is no compiler change and no lock file is recompiled. The collector drops routing.observation events supplied by any other source.

gh aw audit prints the verdict with the model routing details, and audit --json and logs --json include it as model_routing.observation. The CLI reads it in the same pass as the run's other routing records, and only with the collector's provenance. The session schema closes its vocabulary. Version 2.14.0 of the unified agent session specification defines it as T-UAS-094, and the audit reference and a changeset describe it. Because the change touches model_routing.go, the change-scoped linters now cover that file, so two existing findings there are fixed: a discarded filepath.WalkDir error and an unchecked Close are now logged.

Testing replays real AWF records through the collector:

  • Run 39508154330 (routed GPT-5.6 Luna with a declared Claude Haiku sub-agent) counts as a success, with the same verdict whatever the engine setting.
  • Run 39147795806 (report created, then a later check failed the agent job) is skipped as unknown evidence.
  • Run 39499464895 (a selection and the classifier call, but no agent request) and the unrouted run 39506475007 have no verdict.

Unit tests cover the precedence table and the attribution, and a verdict planted in the agent's session is dropped. A Go test reads a golden written by the collector through the model routing summary and checks provenance and vocabulary. The Linux pre-PR gate (make agent-report-progress) passed on the head commit.

For each run AWF routed whose agent made requests, the conclusion job's
unified session now records routing.observation: success or failure
when the result counts as evidence about the model and effort AWF
selected, or skip with the reason it does not. The verdict uses only
engine-neutral evidence: AWF's request records, attributed with the rule
routing analytics already applies, the job results and the validated
safe outputs. The selected pair and its cost stay in AWF's records.

gh aw audit and gh aw logs --json show the verdict, and version 2.13.0
of the unified agent session specification defines it as T-UAS-093.

Fixes #79103

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Changes recommended

Unresolved verdict-classification bugs can falsely credit success without clean detector evidence, count infrastructure or threat-flagged output as model failures, and skip confirmed behavioral failures.

10 open issues
What changed in this PR

Adds routing verdicts to gh-aw’s unified sessions so downstream consumers can distinguish model outcomes from runs that should not inform routing decisions.

Changes:

  • Computes collector-only success, failure, or skip observations from request attribution and final run evidence.
  • Exposes observations through audit and logs, with updated types, schemas, and documentation.
  • Adds replay fixtures, JavaScript and Go tests, and a release note.
File Description
schemas/​logs.schema.json Adds observations to logs JSON.
schemas/​logs-jsonl.schema.json Adds observations to JSONL output.
schemas/​audit.schema.json Adds observations to audit JSON.
pkg/​cli/​testdata/​routing-observation/​aw_session.jsonl Provides a verdict parsing golden.
pkg/​cli/​routing_observation_test.go Tests parsing, provenance, and rendering.
pkg/​cli/​model_routing.go Attaches observations and adds file diagnostics.
pkg/​cli/​model_routing_session.go Parses collector verdicts and validates vocabulary.
pkg/​cli/​audit_report_render.go Prints observations in routing details.
docs/​src/​content/​docs/​specs/​unified-agent-session-specification.md Defines T-UAS-093 and its precedence rules.
docs/​src/​content/​docs/​reference/​audit.md Documents observation output and limits.
docs/​public/​schemas/​unified-session.schema.json Defines the closed observation vocabulary.
actions/​setup/​session_parsers.go Embeds the observation module.
actions/​setup/​js/​unified_session.cjs Computes verdicts and drops supplied observations.
actions/​setup/​js/​unified_session_render.cjs Renders observation event details.
actions/​setup/​js/​types/​unified_session.d.ts Adds observation types and event mapping.
actions/​setup/​js/​routing_observation.test.cjs Tests attribution, precedence, and collection.
actions/​setup/​js/​routing_observation.cjs Implements routed-run verdict classification.
actions/​setup/​js/​routing_analytics.cjs Shares request attribution with verdict computation.
actions/​setup/​js/​fixtures/​routing-analytics/​run-39147795806/​sandbox/​firewall/​logs/​api-proxy-logs/​token-usage.jsonl Supplies recorded request usage for replay.
actions/​setup/​js/​fixtures/​routing-analytics/​run-39147795806/​sandbox/​firewall/​logs/​api-proxy-logs/​model-routing.jsonl Supplies selection and request routing evidence.
actions/​setup/​js/​fixtures/​routing-analytics/​run-39147795806/​agent_output.json Supplies reduced validated-output evidence.
actions/​setup/​js/​fixtures/​routing_analytics_runs.cjs Documents the added replay fixture.
.changeset/​routing-run-observation.md Announces the new routing observation feature.

Review effort: Max (adaptive)

Comment thread actions/setup/js/unified_session.cjs Resolved
Comment thread actions/setup/js/unified_session.cjs Resolved
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
# Conflicts:
#	actions/setup/js/unified_session.cjs
#	docs/src/content/docs/specs/unified-agent-session-specification.md

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Changes recommended

Unresolved verdict-handling defects can misclassify run outcomes, trust agent-controlled evidence, and lose collector verdicts when routing metadata is absent.

5 open issues
3 previously missed issues

In code that hasn't changed since last review

Medium severity Cap-generated 429s are misclassified as rate limits

actions/​setup/​js/​routing_observation.cjs:192

An invocation-budget rejection can be recorded as both invocation_cap_exceeded and HTTP 429 (agent_execution.test.cjs:165,287). This check turns a matched, cap-exhausted run into skip/rate_limited instead of a counted failure. Preserve the response cause and exclude cap-generated 429s without ignoring independent provider throttling.

Medium severity Denial-limit evidence is missing from the verdict inputs

actions/​setup/​js/​unified_session.cjs:211

The SDK emits guard.tool_denials_exceeded when its denial threshold stops the run, but none of the evidence passed here includes that event. With missing output and a generic permission_denied harness class, a confirmed limit becomes skip/unknown_evidence rather than failure. Include the main-session guard in the limit evidence independently of output availability.

Medium severity Unified-session routing evidence is ignored without workflow metadata

pkg/​cli/​model_routing.go:361

With only the unified session available, a collector verdict is lost when workflow.info.modelRouting is absent, even if the session contains AWF selection records. analyzeModelRouting leaves summary nil, so this assignment is never reached. Initialize summaries from the trusted session evidence, including the matching metadata gate at model_routing.go:659.

10 resolved since last review

Review effort: Max (adaptive)

Comment thread actions/setup/js/unified_session.cjs Resolved
Comment thread actions/setup/js/unified_session.cjs Resolved
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@rabeckett
rabeckett marked this pull request as ready for review November 23, 2026 17:49
@github-actions

github-actions Bot commented Nov 23, 2026 •

Copy link
Copy Markdown
Contributor

⚠️ PR Code Quality Reviewer failed to deliver outputs during code quality review.

PR Code Quality Reviewer

Outcome: reported_action

The agent completed and reported one or more actions. The no-op output is a completion signal, not a claim that no action was taken.

The [aw] No-Op Runs tracker omits agent messages. The category uses structured run status, not interpretation of agent prose.

No-op message

Completed PR #80468 review: published 2 inline findings, submitted REQUEST_CHANGES, and recorded review history.

🔎 Code quality review by PR Code Quality Reviewer · copilot · gpt56 · ~9 AIC · ⌖ ~1 AIC · ⊞ 1.7K · history

@github-actions

github-actions Bot commented Nov 23, 2026 •

Copy link
Copy Markdown
Contributor

✅ Test Quality Sentinel completed test quality analysis.

🧪 Test quality analysis by Test Quality Sentinel · copilot · routed: haiku55 xhigh · ~10 AIC · ⌖ ~2 AIC · ⊞ 7.4K · history

@github-actions

github-actions Bot commented Nov 23, 2026 •

Copy link
Copy Markdown
Contributor

✅ Ponytail Reviewer completed successfully!

Ponytail Reviewer

Outcome: reported_no_action

The agent completed and reported no action. A no-op output alone does not verify that all required work was completed or that publication was possible.

The [aw] No-Op Runs tracker omits agent messages. The category uses structured run status, not interpretation of agent prose.

No-op message

Lean already. Ship.

Generated by Ponytail Reviewer for #80468 · codex · routed: gpt61 medium · ~7 AIC · ⌖ ~1 AIC · ⊞ 176 · history

@github-actions

github-actions Bot commented Nov 23, 2026 •

Copy link
Copy Markdown
Contributor

🧠 Matt Pocock Skills Reviewer has completed the skills-based review. ✅

🧠 Reviewed using Matt Pocock's skills by Matt Pocock Skills Reviewer · copilot · routed: haiku55 xhigh · ~13 AIC · ⌖ ~2 AIC · ⊞ 7.1K · history

@github-actions

github-actions Bot commented Nov 23, 2026 •

Copy link
Copy Markdown
Contributor

✅ PR Specification Reviewer completed successfully!

Generated by PR Specification Reviewer for #80468 · copilot · gpt56 · ~3 AIC · ⌖ ~1 AIC · ⊞ 1.8K · history

@github-actions

This comment has been minimized.

@github-actions github-actions Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewed head 2b256f0c852ff30b47f77518729d6073082c7cfd against Unified Agent Session Specification 2.14.0, T-UAS-094.

Blocking finding: the routing observation classifier treats an empty set of detection results as clean, so a detector job that fails or is cancelled before producing detection_result.json can allow a routed run to be recorded as success. T-UAS-094 rule 7 requires unknown_evidence for failed/cancelled detection. See the inline comment on routing_observation.cjs:156.

No specification synchronization is proposed; the implementation needs to preserve the existing contract.

Generated by PR Specification Reviewer for #80468 · copilot · gpt50 · ~3 AIC · ⌖ ~1 AIC · ⊞ 1.8K
Comment /review-specs to run again

@github-actions

Copy link
Copy Markdown
Contributor

Comment Memory

Peek at saved memory (spec-review-history)
{"id":"ldg-4cebdb52-d8ad-4a3a-bd1d-714b8eb71564","parents":[],"payload":{"id":"ldg-d11d7ba9-1441-4600-b95d-4f217a97e1b4","operation":"append","value":{"finding_count":1,"head_sha":"2b256f0c852ff30b47f77518729d6073082c7cfd","outcome":"regression"}},"sha":"sha256:5e090d7e4eade343226d6abaab64fe9e7c2eaed263e8809c13c77aaa04c7b72a","timestamp":"2026-11-23T17:57:49.857Z","type":"ledger_append","version":1}
History

@github-actions

Copy link
Copy Markdown
Contributor

🏗️ Design Decision Gate — ADR Required

This PR makes significant changes to core business logic (>100 new lines) but does not have a linked Architecture Decision Record (ADR).

📄 Draft ADR committed: docs/adr/80468-record-routing-observation-verdict.md — review and complete it before merging.

🔒 This PR cannot merge until an ADR is linked in the PR body.

📋 What to do next
  1. Review the draft ADR committed to your branch — it was generated from the PR diff

  2. Complete the missing sections — add context the AI couldn't infer, refine the decision rationale, and list real alternatives you considered

  3. Commit the finalized ADR to docs/adr/ on your branch

  4. Reference the ADR in this PR body by adding a line such as:

    ADR: ADR-80468: Record a Routing Observation Verdict for Routed Runs (link unavailable: invalid HTTPS URL)

Once an ADR is linked in the PR body, this gate will re-run and verify the implementation matches the decision.

Note: the linked issue #79103 has no ADR content, and no existing docs/adr/ file matches this PR.

❓ Why ADRs Matter

"AI made me procrastinate on key design decisions. Because refactoring was cheap, I could always say 'I'll deal with this later.' Deferring decisions corroded my ability to think clearly."

ADRs create a searchable, permanent record of why the codebase looks the way it does. Future contributors (and your future self) will thank you.

📋 Michael Nygard ADR Format Reference

An ADR must contain these four sections to be considered complete:

  • Context — What is the problem? What forces are at play?
  • Decision — What did you decide? Why?
  • Alternatives Considered — What else could have been done?
  • Consequences — What are the trade-offs (positive and negative)?

All ADRs are stored in docs/adr/ as Markdown files numbered by PR number (e.g., 80468-record-routing-observation-verdict.md for PR #80468).

🏗️ ADR gate enforced by Design Decision Gate 🏗️ · pi · routed: haiku55 xhigh · ~3 AIC · ⌖ ~2 AIC · ⊞ 6.6K · history
Comment /review to run again

@github-actions github-actions Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Skills-Based Review 🧠

Applied /tdd via the pr-triage recommendation. The earlier review threads are addressed, and the cross-file event and field names match their producers.

📋 Scope and limits
  • One inline finding: an absent detection result counts as clean, which may let a run with a failed detection job count as success.
  • Static review only. The test suite was not run.
  • Investigation stopped at the budget. The failureCause trace in empty_output_outcome.cjs (unknown and request_rejection) remains unverified.

🧠 Reviewed using Matt Pocock's skills by Matt Pocock Skills Reviewer · copilot · routed: haiku55 xhigh · ~13 AIC · ⌖ ~2 AIC · ⊞ 7.1K
Comment /matt to run again

@github-actions

Copy link
Copy Markdown
Contributor

Comment Memory

Peek at saved memory (pr-code-quality-reviewer)
reviewed_at: 2026-11-23T17:52:39Z
review_event: REQUEST_CHANGES
top_themes:
  - ambiguous routing records must fail closed across model and effort
  - published schemas must enforce observation vocabulary
files_reviewed:
  - actions/setup/js/routing_analytics.cjs
  - actions/setup/js/routing_observation.cjs
  - actions/setup/js/unified_session.cjs
  - pkg/cli/model_routing_session.go
  - schemas/audit.schema.json
  - schemas/logs-jsonl.schema.json
  - schemas/logs.schema.json
comment_count: 2
History

Note

This comment is managed by comment memory.

Expand the saved memory block to view or edit the persistent context for this thread.
Edit only the text inside the backtick fences; workflow metadata and the footer are regenerated automatically.

Learn more about comment memory

🔎 Code quality review by PR Code Quality Reviewer · copilot · gpt50 · ~9 AIC · ⌖ ~1 AIC · ⊞ 1.7K · history
Comment /review to run again

@github-actions

Copy link
Copy Markdown
Contributor

🧪 Test Quality Sentinel Report

✅ Test Quality Score: 96/100 — Excellent

Analyzed 56 test scenarios across 15 test functions: 56 design, 0 implementation, 0 violations.

📊 Metrics (56 tests)
Metric Value
Analyzed 56 (Go: 6, JS: 50)
✅ Design 56 (100%)
⚠️ Implementation 0 (0%)
Edge/error coverage 49 (88%)
Duplicate clusters 0
Inflation No (Go test 1.9:1 against model_routing.go and audit_report_render.go; JS 1:1)
🚨 Violations 0
Test File Classification Issues
routedRun (6 tests) routing_observation.test.cjs:23 behavioral_contract, design_test, high_value None
routingOutcome outcome table (30 rows) routing_observation.test.cjs:69 behavioral_contract, design_test, high_value None; 2 happy-path rows
detectionVerdict table (8 rows) routing_observation.test.cjs:127 behavioral_contract, design_test, high_value None
routing.observation in the unified session (6 tests) routing_observation.test.cjs:142 behavioral_contract, design_test, high_value None; validates output against the session schema
TestModelRoutingReadsRoutingObservation (6 subtests) pkg/cli/routing_observation_test.go:16 behavioral_contract, design_test, high_value See flagged tests
Collector assertion (modified, not scored) collect_ndjson_output.test.cjs:265 behavioral_contract, design_test, high_value None
⚠️ Flagged Tests (1)

TestModelRoutingReadsRoutingObservation (pkg/cli/routing_observation_test.go:16): design_test, soft red flag, below failure threshold. Five require.* assertions have no failure message. The console check on line 48 pins exact four-space indentation, which breaks on harmless formatting changes. Fix: add messages, and match on the field text rather than exact whitespace.

Verdict

✅ passed. 0% implementation tests (threshold: 30%). No guideline violations.

Scope: static review. Test execution was blocked in this run, so pass or fail status is not verified here.

🧪 Test quality analysis by Test Quality Sentinel · copilot · routed: haiku55 xhigh · ~10 AIC · ⌖ ~2 AIC · ⊞ 7.4K · history
Comment /review to run again

@github-actions github-actions Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

✅ Test Quality Sentinel: 96/100. 0% implementation tests (threshold: 30%), no guideline violations. Static review only; test execution was blocked in this run, so pass/fail is not verified.

🧪 Test quality analysis by Test Quality Sentinel · copilot · routed: haiku55 xhigh · ~10 AIC · ⌖ ~2 AIC · ⊞ 7.4K
Comment /review to run again

Also finalize ADR-80468.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@rabeckett

Copy link
Copy Markdown
Collaborator Author

The PR Code Quality Reviewer's run (45231864722) failed to submit its review (submit_pull_request_review: missing safe-output prerequisite), so its two findings never reached the PR. I read them from the run's agent output and am leaving both as they are:

  • Request records that differ only in effort are not treated as conflicting. Attribution follows AWF's own routed judgment through the existing T-UAS-081 helper. Two copies that agree on routed and the requested model agree on whether the selected pair ran. Changing the conflict rule would also change the baseline estimate, which this PR keeps as it was.
  • The audit and logs JSON schemas don't close the observation's vocabulary. The CLI reader accepts only T-UAS-094's outcomes and reasons and drops anything else, and the session schema closes the vocabulary at the source. Closing the CLI output schemas too would need a schema post-processor or new generator options, which isn't worth it for one field.

@rabeckett
rabeckett merged commit 9b8dfa2 into main Nov 23, 2026
103 checks passed
@rabeckett
rabeckett deleted the routing-outcome branch November 23, 2026 18:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Report which routed workflow outcomes can be used to learn about a model

2 participants