You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Record whether a routed run's result counts - #80468
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>
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.
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.
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.
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.
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.
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.
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.
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
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
Review the draft ADR committed to your branch — it was generated from the PR diff
Complete the missing sections — add context the AI couldn't infer, refine the decision rationale, and list real alternatives you considered
Commit the finalized ADR to docs/adr/ on your branch
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
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
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.
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
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
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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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.observationevent. It issuccessorfailurewhen the result counts, orskipwith a reason:cancelled,infrastructure,rate_limited,pair_mismatchorunknown_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):
pair_mismatch) or cannot be attributed (unknown_evidence).That rule moved into a shared
attributeRequesthelper inrouting_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"inagent_output.jsonwhen 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.observationevents supplied by any other source.gh aw auditprints the verdict with the model routing details, andaudit --jsonandlogs --jsoninclude it asmodel_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 touchesmodel_routing.go, the change-scoped linters now cover that file, so two existing findings there are fixed: a discardedfilepath.WalkDirerror and an uncheckedCloseare now logged.Testing replays real AWF records through the collector:
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.