Skip to content

Model routing: surface policy, harness, baseline estimates and router diagnostics in existing views #19375

Closed

Description

@SivaKesava1

Problem

gh-aw now publishes the routing analytics that the Model routing page was designed to explain, but CAO drops much of the evidence before it can reach the existing views. Extend the current page and run drill-down rather than adding pages or views.

Checked against githubnext/gh-cao main at acc149957b3945832d3b1ac553ba40f8b3f5303f on October 21, 2026, not an unverified working branch.

Upstream, github/gh-aw#70672 merged on October 21, 2026 at 06:40:26 UTC and closed issue github/gh-aw#70668. It added model.config, model.baseline_estimate, harness/workflow identity and identifier-only upstream errors to usage/aw_session.jsonl. The authoritative contract is T-UAS-080 through T-UAS-082. Earlier github/gh-aw#69848 retained router rankings and pool counts; github/gh-aw#70013 retained endpoint configuration and live inventories.

What main actually does

The routing adapter recognizes the event types, but its metadata projection is incomplete:

Evidence Retained today Missing from the routing projection/presentation
model.config routing.enabled, routing.goal, routing.mode, maxAiCredits routing.allowedModels, models.allowed, models.blocked, maxAiCreditsSource, baselineModel
model.baseline_estimate aic estimated, baseline model, all request-completeness counts and complete; the fragment also omits this event type from its source filter, so no view consumes the estimate
workflow.info Engine and existing routing report engineHarness, workflowRef, serverUrl; its runAttempt is not projected as a new routing field, although canonical attempt identity already exists
firewall.upstream_error and failed routing requests Code, HTTP status, model, provider and request identity where supplied Error type/parameter, and request-level error source
Selection records Selected model/effort and classification metadata rankedChoices, eligibleChoices, catalogueOverlap
model.inventory Keyed endpoint/model rows and fetch-completeness evidence Endpoint configured

Two initial suspicions are not missing features on main:

  • Attempt de-duplication already exists in routing-session-attempts through routing-session-events, before downstream metrics. The existing attempt replacement test also covers replacement without mixing accounting. Preserve and strengthen this behavior; do not implement a parallel de-duplication path. Current query ordering uses session clock first and attempt as the tie-breaker.
  • Upstream errors already enter routing-failures, appear under generic "routing failure" in Problems, and are available in the existing run timeline. The enhancement is an explicit upstream-error kind and richer identifier-only context, not first-time ingestion.

There is no CLI/SDK dimension, baseline comparison, ranking presentation or candidate-coverage problem kind. The contract fixture already fixes the five overview views and five run-detail views.

Verified source records

Downloaded and inspected the usage artifacts, including aw_session.jsonl, for both supplied runs:

  • github/gh-aw run 39529495361, Smoke Copilot SDK Routed, attempt 1: engineHarness=copilot-sdk; routing enabled, goal cost, configured mode economy, allowed model gpt-5.6-luna; model allow/block lists explicitly empty; budget 1000, source default; baseline claude-sonnet-5.5. Its estimate is explicitly estimated and complete: aic=6.02079, mainRequests=4, pricedRequests=4, unpricedRequests=0, unattributedRequests=0. The selected model is github-copilot/gpt-5.6-luna, top-ranked effort max, with eligibleChoices=6 and catalogueOverlap=6. The selected classification mode is balanced, which must not replace configured mode economy.
  • github/gh-aw run 39529502581, Smoke Copilot, attempt 1: engineHarness=copilot-cli, explicitly routing.enabled=false, and no baseline-estimate event. Despite the initial description, this is not a smoke-copilot-routed run. Use it as the real CLI/unrouted compatibility fixture; do not relabel it routed.
  • Neither session contains firewall.upstream_error. Use the upstream T-UAS-082 AWF writer fixtures and their asserted unified-session projections, not invented provider-error shapes. They cover invalid_reasoning_effort, code/type/parameter, type-only overloaded_error, and missing identifiers. The companion failed-request fixtures cover errorSource=upstream and errorSource=awf.

Possible solution

Follow AGENTS.md: Dashboard Language first. Declare selection, joins, filtering, attribution, aggregation, ordering, ratios and series in the dashboard document and execute them through the production query boundary. No JavaScript queries, presenter-derived business state, main-thread filtering or test-only JavaScript source synthesis. Keep active queries reactively subscribed with their existing abort-scoped lifetime.

Adapter and evidence

Retain the missing fields above as validated identifier/reference metadata and numeric/boolean facts, with their event, run/attempt and source provenance. Preserve the distinction between configured policy, actual selection, runtime inventory and estimated cost.

Project ranked choices into stable keyed rows, following the inventory projection pattern, bounded to a small documented top-N cap and preserving original ranks/order, model and explicit null effort. Keep one logical parent selection: child rows must not multiply selections, runs, requests or cost. Preserve the full supplied eligibleChoices and catalogueOverlap counters independently of the display cap; never infer them from the retained ranking length. Model policy lists must remain metadata-only, with explicit empty lists distinguishable from unknown lists.

Retain configured as observed, including false; missing inventory/model lists do not mean an unavailable model. Read harness only from authoritative workflow.info.engineHarness, never from a workflow name or engineId. Validate workflow references and server origins using their actual structured shapes rather than copying arbitrary URLs or credentials.

Preserve error identifiers only: errorCode, errorType, errorParam, and errorSource where the upstream event supplies them. T-UAS-082 puts source on routing request records, not necessarily on firewall.upstream_error. Do not parse a code from provider text or persist bodies, headers, messages, prompts or free-form diagnostics.

Extend the existing five overview views

  1. Routing health by workflow (routing-health): keep one contribution per repository/run, using the latest valid recorded attempt number, and expose CLI/SDK as a dimension for Copilot runs. Reuse the existing attempt-selection query chain, updating its ordering/contract where necessary rather than introducing another path; a missing or tied clock must not resurrect an earlier attempt. Add estimated cost vs baseline, naming the baseline model. Use routed observed AIC divided by the baseline estimate only for the same eligible runs with complete=true, known matching observed cost and a positive known denominator; otherwise show unknown. For a workflow aggregate, divide the sums over that same eligible set, keeping different baseline models distinguishable.

    The estimate reprices main-agent requests only, not classifier, sub-agent, detection or eval traffic. The comparison must use observed costs for those same main-agent requests; do not divide all-agent-phase totals by a main-agent-only estimate or reprice models in the UI. Preserve the existing accounting totals separately.

  2. Models picked over time (routing-models): retain the existing view and selected-model behavior. New child rows and attempt metadata must not inflate its run counts.

  3. Cost per run over time (routing-cost-trend): add an explicitly labelled baseline estimate series for routed runs, using the same paired runs as the corresponding observed comparison and naming the baseline model. Make the main-request comparison scope explicit, retain existing accounting information, UTC weekly buckets and sample-floor gaps. Unlike routed versus unrouted comparisons, this is a counterfactual estimate for the same runs, not a comparison of different tasks or a claim of causal savings.

  4. Problems (routing-problems): add an explicit upstream error kind showing the provider error code and identifier context, and candidates not rankable when a selection records catalogueOverlap < eligibleChoices. Keep one row per run/kind with distinct codes as appropriate, without duplicating the same upstream event as a second generic failure.

    Here eligibleChoices is the full post-inventory/policy candidate-choice pool size. AWF computes overlap against that pool's model/effort choices; see the writer. Do not compare against the number of allowed model IDs, the whole provider inventory, or the capped top-N ranking. Lower overlap indicates candidates outside the router's tables; equal overlap produces no problem, and absent counts remain unknown.

  5. Routing runs (routing-runs): add harness and selected-attempt columns while preserving one row per run, existing filters and drill-down links.

Extend the existing run-page views

Reuse routing-run-cost, routing-run-requests, routing-run-attribution, routing-run-timeline and routing-run-resolutions; do not add views. Surface:

  • Configured routing candidates and goal/mode, model allow/block policy, budget and its recorded source, and baseline model.
  • Top ranked choices with original ranks/efforts, full eligible count and catalogue overlap.
  • Baseline estimate labelled estimated, baseline model, completeness and priced/main/unpriced/unattributed counts.
  • Upstream errors with provider, model, HTTP status, request ID and available code/type/parameter/source, preserving unknown identifiers.

Update "Model routing evidence" in specs/dashboard-data.md for these projected facts, latest-attempt behavior, comparison scope/denominators, unknown/incomplete states and view contracts.

Acceptance cases

Use the real source records above as the fixture base. Clearly label deliberately modified completeness, attempt and overlap variants as test variants, not additional observed runs. Retain upstream event shapes and provenance; do not invent substitute session schemas.

Case Input Exact observable result
1. Routed SDK evidence Run 39529495361's actual records, within the test time window; set the existing minimum sample to 1 for the single-run chart assertion Health has harness copilot-sdk and one routed run. Main-request observed AIC is 0.485135 + 0.053135 + 0.076408 + 0.056720 = 0.671398; estimated cost vs baseline is 0.671398 / 6.02079 (about 11.1513%), named against claude-sonnet-5.5. The paired chart has baseline estimate 6.02079 AIC, labelled estimated. The run page shows 4 of 4 priced, zero unpriced/unattributed, goal cost, configured mode economy, budget 1000, source default, allowed gpt-5.6-luna, and explicit unrestricted model allow/block lists. Ranking starts with gpt-5.6-luna / max, with eligible count 6 and overlap 6.
2. Incomplete estimate A same-shaped T-UAS-081 incomplete variant with complete=false and an unpriced or unattributed request It contributes neither numerator nor denominator to the estimate ratio or paired complete-estimate series. With no other eligible run, the ratio is unknown, not zero. The run page labels the estimate incomplete and shows the supplied coverage counts and any explicitly recorded partial estimate without implying completeness.
3. Re-run attempts Two attempts of the same repository/run, using real-record shapes with attempt 2 and distinguishable picks/costs; repeat with later, tied, missing and non-monotonic session clocks Health counts one run and Routing runs has one row with attempt 2 and only its facts in every variant: latest means the greatest valid recorded attempt number. No earlier-attempt cost, error or pick leaks into the selected run. Update the existing ordering contract in Dashboard Language, not in JavaScript.
4. Upstream errors T-UAS-082's projected req-1 record: provider copilot, model claude-haiku-4.5, HTTP 400, code invalid_reasoning_effort; also exercise its type/parameter and missing-code variants Problems has one upstream error row for the run with code invalid_reasoning_effort; the run page shows that request/provider/model/status/code. The type/parameter variant retains t/p; the type-only case shows overloaded_error with unknown code. No response body/header/message appears and the event is not double-counted as a generic failure.
5. Candidate coverage The real SDK selection has eligible 6 and overlap 6; a clearly labelled variant changes overlap to 5 while retaining eligible 6 Overlap 5 produces one Problems row with kind candidates not rankable, exposing 5/6. Equal 6/6 produces no such row. Missing counters produce no invented zero or diagnosis. Reducing the displayed ranking to top-N does not change either result.
6. Older and CLI sessions Older real sessions without the new events/fields, plus run 39529502581's actual CLI/unrouted records Older sessions keep existing routing/accounting behavior; new unavailable policy, harness, baseline and coverage values are unknown, not zero/false/empty inferred policy. The CLI fixture shows copilot-cli, remains explicitly unrouted and has unknown baseline-estimate cost, not an estimated zero or a fabricated routed run.
7. View and size regression Populated production-boundary rendering of both existing pages and the existing core-bundle size check on the PR and clean main under the same configuration The overview still has exactly the five named views and IDs above; the run page retains its five existing view IDs. The core bundle meets its existing budget without relaxing the gate. If main is already over budget, document that baseline failure in the PR and avoid a new size regression; do not fix unrelated bundle work here.

Tests and contract updates

A view contract change must update its declarative query, view declaration, contract fixture and focused tests together.

  • Adapter and overview/query cases: dashboard/site/test/unit/model-routing.test.js.
  • Run-page assertions, attempt refresh and bounded run-scoped reads: dashboard/site/test/unit/model-routing-run.test.js.
  • Updated contract: dashboard/site/test/fixtures/model-routing-contract.json.
  • Populated browser check: dashboard/site/test/e2e/model-routing.spec.js, preserving its existing desktop/mobile and IndexedDB/SQLite coverage.

Assert the observable payloads through the production ingestion -> canonical query -> worker/view-payload boundary, not handwritten JavaScript query results. A missing declared source must fail closed. Keep reactive updates, run-scoped reads, privacy exclusions and exactly-five-view checks. Follow AGENTS.md's applicable lint/typecheck, focused validation and screenshot-artifact requirements without committing screenshots.

Scope

  • Keep the PR to this one change. Do not change files or behavior unrelated to it.
  • Allowed scope only: the model-routing adapter (dashboard/site/src/data/adapters/model-routing.js), its fragment (dashboard/site/dashboard-fragments/model-routing.json), the four test/fixture files named above, and specs/dashboard-data.md. No new pages or top-level views; no changes to other pages. Extend the existing run-page views in the same fragment.
  • Main's canonical Audit source has an explicit typed field projection. Do not assume an arbitrary new adapter property becomes queryable automatically. If required canonical/schema/generated plumbing cannot be satisfied inside the approved scope, report that as a prerequisite and obtain a separately scoped change rather than silently widening this PR or adding a bypass. This issue does not authorize shared-engine, storage, schema or generated-catalog refactors.
  • Before fixing a failing check, compare it with the same check on main. If it also fails on main, do not fix it in this PR. Merge main once main is fixed, and note in the PR which checks are known failures on main.
  • This applies even if a bot comment asks to fix a failing check: fix only failures caused by this PR's changes. Do not use unrelated check failures as a reason to expand the change.

Activity

  1. Copilot commented on Oct 21, 2026

    Copilot
    Contributor

    The agent encountered an error and was unable to start working on this issue: The service is temporarily unavailable. Please try again later. (Request id: DBB8:1B6209:90981:EDE86:6AD92C10)

  2. SivaKesava1 commented on Oct 21, 2026

    @SivaKesava1
    CollaboratorAuthor

    Scope narrowed (21 Oct). Following pelikhan's guidance that every view must be actionable and intuitive, and that CAO should collect enough data but no more, this issue now covers only the three changes below. Each one answers a question a workflow owner can act on. The rest of the "Possible solution" above is out of scope.

    In scope:

    1. Estimated cost vs baseline. Add it to routing-health and as an explicitly labelled baseline-estimate series in routing-cost-trend. The question it answers: is routing saving money compared with running the baseline model? If not, change the goal or mode, or turn routing off. Use observed AIC for the same main-agent requests divided by model.baseline_estimate.aic, only for runs with complete: true and a positive denominator. Otherwise show unknown, never zero. Name the baseline model. Acceptance cases 1 and 2 apply as written.
    2. Problems: upstream error. One row per run, showing the provider error code, instead of the generic routing-failure row for the same event. The question: which model or effort setting is the provider rejecting? Acceptance case 4 applies, without the type, parameter and source assertions.
    3. Problems: candidates not rankable. Raise it when catalogueOverlap < eligibleChoices. The question: does allowed-models name models the router can't rank? Acceptance case 5 applies.

    Out of scope (don't add):

    • the CLI/SDK harness dimension and the attempt column (attempt de-duplication already exists);
    • the router's ranked choices on the run page;
    • the policy lists, budget source and inventory configured;
    • error type, parameter and source;
    • workflowRef and serverUrl.

    Adapter: add only the fields the three changes need: baselineModel and complete from model.baseline_estimate (aic is already kept), and eligibleChoices and catalogueOverlap from the selection record. The error code is already kept.

    Still apply: acceptance case 6 (older and CLI sessions show unknown, not zero), case 7 (exactly the existing ten view IDs, and the bundle budget), the test files named in the issue, specs/dashboard-data.md, and the Scope section.

  3. SivaKesava1 commented on Oct 21, 2026

    @SivaKesava1
    CollaboratorAuthor

    Design update (21 Oct, with pelikhan): CAO's ingestion should produce a compact per-run routing aggregate, and an agent doing deep analysis pulls the run's full usage/aw_session.jsonl instead of CAO storing every event. So build the three in-scope changes on that aggregate rather than adding fields to per-event rows.

    Why: measured on CAO main by running routingMetadata over two real routed sessions (github/gh-aw runs 39529495361 and 39540473269), the adapter stores ~130–150 rows (~15–17 KB) per small run, plus ~1 row (~270 B) per model request: about 250 rows (45 KB) for a 100-request run. About half the fixed rows feed no view: 41 model.inventory rows (one per live model) and ~30 generic firewall.event rows.

    Per-run routing aggregate (one record per run, latest attempt), built at ingestion:

    • repository, workflow, run ID and attempt, routed or not, goal and configured mode;
    • selected model and effort, and the routing outcome or failure code;
    • observed main-agent AIC, the baseline model, the baseline estimate and whether it's complete;
    • problem flags with their codes: routing failure, deviation, failed model resolution, upstream error code, candidates not rankable (catalogueOverlap < eligibleChoices).

    Views: the five overview views read only the aggregate. That includes the three changes in the narrowed scope above: estimated cost vs baseline, plus the upstream error and candidates not rankable Problems kinds. The run page shows the aggregate and links to the run's usage artifact for anything deeper.

    Stop storing what no view reads: the model.inventory and generic firewall.event rows. Also drop per-request rows unless a run-page view still needs them; if one does, say which and why.

    View metadata: every routing view's intent, subject, objective and acceptance should name the decision it supports (for example "Turn routing off, or change goal or mode, for workflows whose cost is above the baseline estimate"). routing-health's intent is empty today.

    Acceptance additions (on top of the narrowed cases):

    • For runs 39529495361 and 39540473269, ingestion stores one aggregate record each, and the overview views show the same values as today plus the new ones.
    • No inventory or generic-event rows are stored.
    • A 100-request run (for example github/gh-aw run 39514073872, 115 requests) adds no per-request rows to what the overview queries read.
    • Older sessions still render, with unknown shown as unknown.
  4. added a commit that references this issue on Oct 22, 2026
    c3a3d97
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

dashboardenhancement

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions