Routing Learning
Model routing chooses a model and reasoning effort for each run from the task in front of it. Set learning: observe under model-routing to record which model and effort ran, whether the workflow completed its task, and what it cost without changing which model runs. Set learning: true to enable live routing learning, letting the firewall keep a reliable incumbent, test promising rivals, suspend failing models, and switch when the workflow’s own evidence warrants it.
For example, if the router’s pick for an issue triage workflow moves from model B to model A, learning: observe keeps running A as today while recording what live learning would have chosen. With learning: true, once model B has a strong record on that workflow, the firewall serves B, tests cheaper eligible rivals within strict exposure limits (at most every other eligible run for queued workflows, or quarter-hour test turns bounded by each rival’s concurrency capacity for overlapping workflows), and switches incumbents only when a rival’s measured record clears its need.
Turn it on
Section titled “Turn it on”Add learning: observe (or learning: true for live routing learning) to the top-level model-routing block of a routed workflow:
---on: issues: types: [opened]permissions: contents: read issues: readengine: copilotmodel: router/balancedmodel-routing: learning: truesafe-outputs: add-comment:---Read the new issue and post one suggested next step.To turn it on for every eligible workflow in a repository, set the default in .github/workflows/aw.json and recompile:
{ "model_routing": { "learning": "observe" }}A workflow’s own learning value wins, then the first import that sets learning, then the repository default. The default is off. Supported values are observe, true, and false. Set learning: false to stop learning and recording without disabling routing or deleting history. To roll back from live routing learning, set learning: observe (keeps recording evidence while restoring ordinary routing) or learning: false, and recompile the workflow.
Live routing learning requires AWF v0.29.21 or newer (the default pin) and a matching apiProxy image. If a workflow explicitly pins an older firewall version or apiProxy image, compilation emits a warning, keeps the explicit pin unchanged, runs the workflow in observe mode, and omits the pre-run summary file.
Learning does not enable routing or require a shortlist. If you also use allowed-models, declare the list once, alongside learning or in a separate import, and use a literal router model value as usual.
Which workflows take part
Section titled “Which workflows take part”A workflow takes part when its main agent’s model is chosen by AWF model routing on a Copilot, Claude, or Codex engine: model: router, a fixed level such as router/balanced, the default routing for workflows without a model, or a model expression that resolves to a router value. It does not require tools.repo-memory, and it must emit a conclusion job to publish the unified session (workflows that use tools.comment-memory without safe-outputs omit conclusion; add a safe-outputs block to make them eligible). It must not be a work-queue worker, a reusable workflow (on: workflow_call), a workflow triggered only by pull request events (pull_request, pull_request_review, or pull_request_review_comment), or run experiments. A workflow that sets learning: observe or learning: true itself, or through an import, fails to compile with the reason when it does not qualify; the repository default skips such workflows silently. If a workflow combines a pull request trigger with a default-branch trigger (such as workflow_dispatch or issue_comment), explicit opt-in emits a compile-time warning that pull request runs will be skipped. pull_request_target is eligible because it executes from the default branch.
At run time, gh-aw records only the first attempt of a run whose workflow definition comes from the default branch, so re-runs and pull request runs are not recorded. Every first attempt is recorded once the agent job has run, whether the run succeeded or failed.
What is recorded
Section titled “What is recorded”After the run’s conclusion job has published its unified session, the push_routing_history job reads three things from it: the routing verdict (whether the run’s result counts as evidence about the model and effort AWF selected, and if not, why), the model and effort AWF selected, and the run’s cost as AWF priced it. It appends one line per run to runs.jsonl:
{"run": "44156334376", "number": 812, "attempt": 1, "at": "2026-11-19T17:02:40Z", "generation": "<definition hash>", "scope": "copilot/cost/shared", "mode": "observe", "role": "observe", "pair": "github-copilot/model-a@high", "outcome": "failure", "credits": 12.0, "counted": true, "note": null}A run counts as a success or a failure only when the verdict says its result was about the selected model. Otherwise its line explains why it did not count, for example infrastructure, cancelled or rate_limited, or no_agent when AWF did not route the run or its agent made no request. If a run’s own save fails, the next save finds the run in the workflow’s run list and records it as unsaved. If a re-run is already in progress, the writer checks the first attempt without waiting for the re-run to finish.
state.json keeps, for each model and effort, its recent outcomes with their credits and token counts, its average cost, current streak and a summary of its success rate. It also tracks verified reconciliation coverage (reconciled_through and unresolved_runs) independently of runs.jsonl’s 500-line retention window and last_run, so an older run that ages out of runs.jsonl is never charged twice and an incomplete or failed run-list lookup never advances coverage past a gap. When a run number is absent from an unfiltered page, it is kept in unresolved_runs unless a single unfiltered page brackets both sides of the gap and confirms that the higher listed neighbor is older than 5 minutes (treating it as deleted rather than persisting in unresolved_runs); a gap straddling the page 1 / page 2 boundary is kept unresolved rather than assumed deleted. Providers report a request’s input count either with or without its cached tokens. When AWF’s record does not say which, Anthropic counts are treated as excluding cached tokens, OpenAI counts as including them, and for Copilot (or other providers) an input count smaller than the cached count is taken to exclude it and any other to include it, so a Copilot run’s token counts are close but not always exact, while its credits are what AWF priced. Editing the workflow starts a new generation: earlier failures are forgiven and successes are kept, a run of the older definition that finishes late does not count against the new one, and reconciliation continues from the previous verified floor so a failed save on the first run of a new definition is not dropped. Records are shared across routing levels unless the workflow chooses its level at run time, in which case each level keeps its own.
last_run is the highest recorded run number, not proof that every preceding result was saved. For example, in an established history, if run 12 saves while run 11 is still active, coverage can reach 12 with 11 listed in unresolved_runs. A missing entry in an Actions listing is not proof that 11 saved. Only the writer settles that obligation. Older histories without reconciled_through do not yet report verified coverage.
On an empty history, the first save records its own run and sets reconciled_through to its own run number with unresolved_runs: [], making zero Actions run-list calls and skipping pre-opt-in history. To prevent an out-of-order earlier run from running a live test after a higher-numbered first writer has already established coverage, prepare_routing_history denies live exploration whenever run_number <= reconciled_through unless run_number is explicitly listed in unresolved_runs. On subsequent healthy sequential runs (run_number <= reconciled_through + 1 with empty unresolved_runs), push_routing_history likewise makes zero Actions listing calls.
When earlier runs or tracked unresolved_runs do need reconciliation, push_routing_history fetches at most 2 newest unfiltered pages (200 runs) per save invocation, including push-conflict retries, and checks jobs only for eligible non-success runs. If a push-conflict retry exhausts the 2-call listing budget, the writer saves its own observation without advancing reconciled_through and defers reconciliation to a later save (which gets a fresh 2-call budget). If the gap from reconciled_through exceeds 200 runs, the writer saves its own observation without advancing reconciled_through; if an entry in unresolved_runs ages past 200 runs, reconciled_through may still advance for newer runs, but the aged entry remains pending in unresolved_runs. In either case, live exploration stays paused until an operator runs gh aw routing reset <workflow>. Existing histories left with unfinished legacy pre-first-write coverage (reconciled_through: 0 or a legacy first_write_run field) should also run gh aw routing reset <workflow> to start fresh. This reset deliberately discards learned evidence through the reset point; it does not recover missing observations.
What the judge asks
Section titled “What the judge asks”After the agent starts on a learning run, the evals job asks one built-in question. On Copilot workflows, the routing judge prefers microsoft-decision-1-1 via /v1/systemone. It falls back once to the workflow’s configured /v1/decisions model on HTTP 403 or 404, or on HTTP 400 or 422 with a recognized model-unavailable or unsupported-model error code. Other errors, including rate limits, server errors, and network failures, do not switch models. When the judge records a failure status, it names System One if no fallback was attempted, or the configured model if the fallback was attempted. The System One request keeps the judge instructions and untrusted run evidence in separate, labeled messages within its state string. OpenAI-configured evals continue calling /v1/decisions directly, and workflow-defined evals keep using the workflow’s configured model. The question depends on the run’s result:
- Quality, for passing runs: Did the visible output genuinely complete the task or validly report that no action was needed? The judge checks the instructions and proposed safe outputs for clear fake passes, such as refusals or TODO placeholders. It does not review patches, verify unseen tests, or read routing history. The judge does not see the selected model’s name or model names found in the local AWF catalog when available.
- Environment, for failing or incomplete runs: Was the cause outside the model’s control? The judge sees the instructions, detected error categories, any incomplete reports or output validation errors, and the last 15 non-reasoning events from the redacted
agent-session.jsonl. It falls back to the agent log when there are no usable session events. It also reads up to 20 recent routing history entries from the same workflow definition: if another model succeeded under the same limits, hitting a call or credit cap is a model limitation. Model names are replaced with labels likeModel A.
A generic infrastructure_error report does not make an otherwise passing run incomplete. When a run does need an environment diagnosis, the judge receives a bounded list of report details without that generic reason. If the run reports that secret redaction failed, no evidence is sent to the judge.
The routing history keeps the quality answer for a pass, the environment answer and error categories for a failure, and neither answer for a skipped run. Check the routing history step summary or gh aw routing status to see the answers. The answers do not change routing, how a run counts, or its failure report. The evidence sent to the judge is not added to the evals artifact or routing history. The built-in judge skips runs if the workflow’s own evals could not be evaluated or the current model identity is unavailable for anonymization.
While Decisions usage is unpriced, the daily credit guard’s artifact backend can estimate the whole run at its configured per-run credit limit. The judge does not add a dependency to the repo-memory ledger, which continues to stage evals usage only for workflows with their own evals questions.
The branch
Section titled “The branch”Each workflow’s history lives on its own branch, memory/adaptive-routing/<workflow>, named after the lock file without .lock.yml, so renaming the workflow file starts a new history. The first save creates the branch from its own root commit, and every commit is made through the GitHub API, which signs it. gh-aw never force-pushes or deletes the branch.
The agent never sees or writes the history. The branch is not checked out for the agent and is not in its prompt, and no repo-memory entry may use a branch under memory/adaptive-routing/, whether it names one directly or through an expression that resolves to one at run time, so the agent’s own memory can never reach it.
The added job and permission
Section titled “The added job and permission”Opting in adds the push_routing_history job and enables the built-in judge in the evals job. The history writer runs after conclusion whenever the agent job ran, with contents: write to save the history and actions: read to list the workflow’s runs. It has no concurrency group. When several runs finish together, each save is committed only on the branch head it read; if another run saved first, the save reads the newer files and applies its run again, so every run lands once. If the save still cannot land, the job fails and the run shows the failure. Dry-run compilations (--dry-run) omit the judge and history writer, so dry-run executions are neither recorded nor charged as unsaved.
Opting in also adds a trusted prepare_routing_history step in the agent job (on AWF v0.29.21+) that needs contents: read (plus actions: read for live or overlapping workflows); explicit denials such as permissions: {} or contents: none / actions: none are never widened. The agent’s prompt and non-learning behavior are unchanged. Opting in also ensures the agent job uploads the small agent-output-fallback artifact even when the workflow declares no explicit safe-outputs: (or relies on auto-injected issue creation), gated on the same secret redaction and recovery-envelope validation steps. Alongside safe outputs, usage totals, and classified execution error categories (agent-errors.jsonl), that fallback artifact preserves token-usage.jsonl, model-routing.jsonl, and adaptive-selection.jsonl (when present) across AWF’s firewall log layouts, an allowlisted upstream-error status file (agent/upstream-errors-fallback.jsonl, containing only the event discriminator, request_id, and HTTP status without headers or response bodies), and a content-free main-agent refusal indicator (agent/routing-refusal.json). If the large agent artifact upload times out, conclusion recovers the same routing.observation verdict and selection receipt from agent-output-fallback alone, without altering the full agent artifact when both are present.
Branch rulesets
Section titled “Branch rulesets”Commits to the history are signed, so they satisfy rulesets on memory/** that require signed commits. The job saves with the workflow’s GITHUB_TOKEN, so a ruleset that restricts who can update memory/** must allow GitHub Actions to update memory/adaptive-routing/**; otherwise the save fails and the run reports it.
Retention
Section titled “Retention”The history keeps the model and effort, the verdict, the credits and the token counts of each run, and never prompts or agent output. In state.json, each model and effort keeps its newest 50 outcomes within 60 days; runs.jsonl keeps the last 500 runs. Every earlier version of both files remains in the branch’s Git history. To remove the history entirely, delete the branch by hand; the next run starts a new one.
Status and reset
Section titled “Status and reset”gh aw routing status lists the routing histories in the repository. Give it a workflow to see that workflow’s evidence: for each scope, the incumbent, next intended action, whether all_suspended was triggered, and every model and effort with its runs, expected and hopeful success rates as of the last save, average credits, streak, tests and suspension. It also reports no_turn skip counts with capacities used and the reasons recent runs did not count. Add --json for machine-readable output.
gh aw routing status issue-triagegh aw routing reset <workflow> starts a history afresh. It reads the workflow’s latest run number and, in one commit that lands only if no run saved in the meantime, stops every run up to it from counting, empties the recorded evidence, and clears reconciliation obligations at or below the reset point while preserving any obligations above it. It keeps runs.jsonl and never deletes the branch. It needs write access to the repository.
When every model adaptive routing would try has failed since the workflow last succeeded, live learning holds the workflow on its best-known model. The model still runs, but failures during the hold don’t count against it. The next successful run or an edit to the workflow ends the hold.
The failure issue and the routing history step summary explain the hold. In observe mode they show what live learning would have done, without changing which model runs. Use gh aw routing status <workflow> to see the recorded routing state.
Verify an observe pilot
Section titled “Verify an observe pilot”For an unreleased build, record the full gh-aw commit SHA. Build the compiler from that commit, pass the same SHA to compile --gh-aw-ref, and check that the workflow lock uses github/gh-aw/actions/setup@<SHA> before running it. The flag pins the runtime actions; it does not change the compiler you invoked. For example, the reviewed observe baseline includes model-routing.learning and the writer fixes for pagination, deleted runs and active re-runs.
Record the first opted-in Actions run ID, not the first successful save. For an eligible workflow, an observation is due when the first attempt uses the default-branch workflow definition, runs the agent and is not a dry run. Check that its push_routing_history job succeeded and its run ID appears once in runs.jsonl. If the opening run owed no save (for example, a pull_request run using a PR ref), record why and check the first eligible attempt without moving the pilot boundary.
Record the history branch head when the last pilot writer finishes. Compare the eligible first attempts from Actions with the rows at that revision by run ID, checking for missing or duplicate rows. Use the writer result from attempt 1 even if the run was later re-run. If the snapshot does not cover the entire pilot, use earlier branch revisions to recover rows that rolled off, counting each appended row only once.
A row with note: "unsaved" accounts for a failed save; it does not recover the observation. If two eligible writers failed before the first successful save and history shows neither ID, report both missing IDs. Zero unsaved rows in history does not prove that every observation was saved.
Limits
Section titled “Limits”- Observe mode only records evidence; it never changes which model runs and makes no recommendation.
- A history belongs to one workflow file in one repository; renaming the file starts a new history. Reusable workflows (
on: workflow_call) cannot take part, because each caller numbers its own runs. - A run that ends before the agent job starts, or whose usage artifact was never published, is not recorded by its own save.
- A failed or cancelled run whose agent ran and whose
push_routing_historyjob did not succeed (whether it failed, was cancelled, timed out, or was skipped) is charged asunsavedby a later save once history is established. Bothprepare_routing_historyandpush_routing_historyread at most 2 newest unfiltered pages (200 runs) per invocation, covering default-branch,pull_request_target, and ineligible runs together. When countingin_flightruns,prepare_routing_historyderives active runs from those same 1 to 2 unfiltered pages (without separate per-status queries) and ignores expired non-completed runs: pre-start runs (requested,pending,queued) older than 30 minutes in overlapping mode (wherestale_runrejects them if they later start) and any non-completed run (includingwaitingorin_progress) older thanmax(24 hours, 30 min + max_run_time)in either mode. - If a workflow falls more than 200 runs behind
reconciled_through, the writer saves its own observation without advancingreconciled_through. If an entry inunresolved_runsages past 200 runs,reconciled_throughmay still advance for newer runs while that aged entry stays pending inunresolved_runs. In both cases, live exploration stays paused until an operator runsgh aw routing reset <workflow>.