Model Routing

An issue triage workflow might get a one-line question today and a hard-to-reproduce bug tomorrow. With model: router, the main agent can use a less expensive model for the question and a more capable one for the bug. Routing chooses a model and reasoning effort for each run, not for each message.

Use routing when the work varies. Pin a model instead if the workflow needs a particular capability or you want the same model every time. Routing is experimental; it does not guarantee success or cap spending.

Set model: router in your workflow’s frontmatter. This workflow reads each new issue and posts one suggested next step:

---
on:
issues:
types: [opened]
permissions:
contents: read
issues: read
copilot-requests: write
engine: copilot
model: router
safe-outputs:
add-comment:
---
Read the issue. Suggest one next step that would help the author, and explain why.

If your workflow already pins a model under engine, remove that pin so the top-level choice takes effect. Run gh aw compile and commit the updated workflow and lock file together. This example uses GitHub Copilot authentication and the default firewall.

Set model toWhen to use it
routerLet each task determine the level. Start here for a workflow that handles a mix of requests.
router/economyFavor lower cost for routine work, such as labeling issues or summarizing activity.
router/balancedUse a consistent middle ground for general work, such as reviewing issues for missing information.
router/robustAim for a higher chance of success when a missed finding or a second attempt would be costly.

These are levels, not model names. Two runs at the same level need not use the same model.

An authored main-agent model: auto or model: copilot/auto is deprecated: on eligible workflows using AWF v0.29.21 or newer, it routes the same way as model: router (preserving GitHub Copilot inference for copilot/auto on Claude and Codex). Where routing does not apply (for example with model-routing: false, engine.fallback-models, engine.model-catalog: false, an incompatible model policy, a custom engine, or an older AWF pin), auto emits a deprecation warning. Run gh aw fix --write to rewrite eligible routed workflows to model: router; for non-routed workflows, omit model (with model-routing: false, and set engine.model-provider: github on Claude or Codex if migrating from copilot/auto to keep GitHub Copilot inference), or pin an explicit model or alias.

The deprecated nested engine.model-routing.goal: cost-speed requires an AWF pin older than v0.29.17. With the default firewall, choose a cost-routing level explicitly; cost-speed is not an alias for cost.

To let the main agent choose between specific models, give it a shortlist alongside a literal router value:

model: router
model-routing:
allowed-models: [gpt-5.6-luna, gpt-6-sol]

Use exact model names or model aliases, not wildcard patterns. Declare the list once, either in the workflow or in a shared import.

The shortlist does not restrict sub-agents. For example, a Claude sub-agent can still use its own model while the main agent chooses between the two GPT models above, if the engine supports that combination. Copilot SDK mode supports mixed families; Copilot CLI mode needs the sub-agent and the selected main model to be in the same family. To restrict every model request in the main agent’s job, including sub-agent requests, use a model policy instead. A shortlist cannot override that policy.

Default routing for workflows without a model

Section titled “Default routing for workflows without a model”

Eligible workflows using GitHub Copilot inference on AWF v0.29.21 or newer already route when no model is set. Workflows pinned to an older AWF release without router fallback keep their non-routed default when model is omitted (while expression-driven dynamic routing continues to work on older routing-capable AWF pins). To keep your usual model overrides and engine default without routing, omit model and set:

model-routing: false

Don’t combine the opt-out with a router value or shortlist. A configured runtime model override can take precedence over implicit routing, but does not bypass an explicit model: router.

Routing picks models from the live model catalogue. With engine.model-catalog: false (for example, for Azure AI Gateway), implicit routing is not applied and model: router fails compilation.

Copilot and Pi can route on GitHub Copilot. Claude and Codex can also route on GitHub Copilot with model-provider: github; Claude chooses among Claude models and Codex among GPT models. The Gemini engine does not support routing.

Aider, DeepSeek Harness, and OpenCode can opt in on GitHub Copilot by importing their routing-capable definition (shared/aider.md, shared/deepseek-harness.md, or shared/opencode.md) and setting model: router (or router/economy, router/balanced, or router/robust). They require both AWF and the apiProxy image at v0.29.22 or newer, an enabled model catalogue, and the default GitHub Copilot inference target. AWF limits ranking and fallback to endpoints and efforts each launcher can use. Aider and OpenCode support Chat Completions. DeepSeek Harness supports Messages, Responses, and Chat Completions, with efforts minimal through max or omitted, but not explicit none. The launcher applies the result or stops before launch, without a second selection. Use copilot/auto to keep non-routed tier selection.

Crush can also opt in with a routing-capable shared/crush.md import and the same Copilot, catalogue, and AWF requirements. It uses Chat Completions for the routed model even if Crush would use Responses for a fixed pin to that model. It forwards the selected reasoning effort, or leaves the field out if AWF did not select one. copilot/auto keeps its existing non-routed tier selection.

On AWF v0.29.21 and newer (when the apiProxy image is also v0.29.21 or newer), gh-aw passes each engine’s supported API endpoints in apiProxy.routing.endpoints so AWF excludes models the engine cannot drive before router ranking or fallback selection. Engines that support automatic selection declare their static defaults under engine.options.model-selection in the bundled or repository-maintained shared definitions. The build packages the same capabilities with the compiler and the setup action. See the Automatic Model Selection Specification for the full rules. Workflow- and runtime-specific settings narrow those defaults further: Copilot SDK on native Anthropic uses /v1/messages, a configured Copilot CLI wire API narrows to its single endpoint, and a static Pi engine.config.model.api narrows to its matching endpoint.

Workflows pinned to an older AWF release or an older apiProxy image omit apiProxy.routing.endpoints so older AWF strict config schemas remain compatible.

When apiProxy.routing.endpoints is present, Pi uses AWF’s selected endpoint for the main agent, even if Pi’s local model catalogue prefers another API. For example, a /responses selection uses Pi’s openai-responses API even when the catalogue prefers Chat Completions. Pi stops before launch if the selection conflicts with engine.config.model.api. Without endpoint constraints, Pi keeps its catalogue-based API resolution and verifies the resulting endpoint against AWF. Pi also uses that compatibility path, with a warning, if the runtime AWF configuration file is missing.

With AWF and apiProxy v0.29.22 or newer, gh-aw also emits apiProxy.routing.supportedEfforts from the engine’s supported-efforts declaration. It applies effort-min-versions to pinned engines, for example excluding max before Pi 1.3.0. Naturally effort-free models remain eligible. Older AWF pins omit this field.

Non-routed built-in launches (copilot, claude, codex, and pi, such as model-routing: false with model omitted or unshadowed auto) use the same static endpoint and effort contract via AWF’s read-only POST /select-model endpoint when sandboxed on AWF v0.29.22+, so non-routed automatic selection picks the same model, endpoint, and effort as router fallback. Concrete pins (GH_AW_MODEL_AGENT_*, COPILOT_PROVIDER_WIRE_MODEL, CLI -m/--model, Codex config.toml model, or an authored models[""] alias) bypass automatic selection. When an unlisted concrete pin is bound unambiguously to a configured provider and wire API and AWF recovery or engine.fallback-models is active, Copilot SDK and Pi hand it off to AWF; ambiguous multi-provider Copilot SDK pins or Pi pins lacking catalog API metadata and engine.config.model.api still fail clearly at launch. With engine.model-catalog: false, gh-aw omits apiProxy.models, makes zero selector calls, and passes the configured model verbatim.

For non-routed Pi on GitHub Copilot, the opt-in offline launch fixture verifies three combinations using current setup, Pi v1.6.0, and a mocked AWF proxy. To run it, set GH_AW_PI_TEST_CLI to the Pi executable and GH_AW_PI_TEST_COMPILER to a locally built gh-aw executable, then run npm --prefix actions/setup/js run test:js -- pi_v1_live.test.cjs from the repository root.

Pi lock inputsAWF and apiProxy fixtureLaunch result
Launch-step excerpt from the smoke lock before the selector integrationv0.29.22, selector advertisedaw-gateway/auto, no selector call
Fresh compile with model-routing: false and copilot/autov0.29.21, selector not advertisedaw-gateway/auto, no selector call
Same workflow, freshly compiledv0.29.22, selector advertisedOne selector call; Pi uses the returned model, API and effort. The unified session records the selected model and effort.

Threat detection keeps its lightweight detection default. When sandboxed on AWF v0.29.22+ with the catalogue enabled and /reflect advertising POST /select-model, it uses tier selection only for an effective, unshadowed auto model, using its own engine’s provider, endpoint, and effort constraints. For example, safe-outputs.threat-detection.model: auto opts into tier selection, while leaving the detector model at detection makes no selector calls. An explicit detector model wins over an inherited main model; otherwise, defaults honor GH_AW_DEFAULT_DETECTION_MODEL at compilation and the runtime GH_AW_MODEL_DETECTION_* and GH_AW_DEFAULT_MODEL_* overrides. If a Copilot detector model expression evaluates to an empty string, the runtime overrides take priority over the compile-time fallback. Automatically selected detector engines retain the main engine’s catalogue opt-out. An explicit threat-detection.engine is an independent configuration and can opt into or out of the catalogue itself. Catalogue-disabled detectors make zero selector calls.

On the same supported AWF runs, Copilot CLI sub-agents that declare model: auto use tier selection after the main model resolves. The child uses the session’s provider and wire endpoint, and the main model’s family when known. For example, a Claude session on Chat Completions launched with medium selects only a Claude child that can use medium on that endpoint. Without a configured effort, the pinned CLI uses medium for reasoning-capable models and omits effort for models without reasoning. The child’s definition gets the selected model, not a separate effort setting, and usage/aw_session.jsonl records the selection under the child’s role.

An omitted or inherited child model makes no selector call. Concrete pins, a workflow-defined models.auto, and catalogue-disabled, older-AWF, or unsandboxed runs keep their existing behavior. In both Copilot drivers, a workflow-declared child named main is rejected; a repository child with that name is warned and skipped for model resolution.

On the same supported AWF runs, Copilot SDK sub-agents with an explicit unshadowed auto selector (including a configured <provider>/auto prefix and optional ?effort=...) also use POST /select-model through the shared sub-agent selection path. Unlike CLI mode, Copilot SDK allows mixed model families across endpoints that the SDK’s registered providers can drive independently (such as copilot-responses and copilot-completions on GitHub Copilot). Providers with a single wire-API registration (such as native OpenAI on Chat Completions or Responses, or native Anthropic on /v1/messages) narrow child selection to their existing SDK binding instead of sending a child down an incompatible wire API. The harness binds the selected wire model to the matching SDK provider registration, forwards any selected effort to the custom agent’s reasoningEffort setting (or omits it for an effort-free selection, rejecting a contradictory omitted-effort pick on the main model when the main session sets a reasoning effort), and records the bound selection under the child’s role in usage/aw_session.jsonl after applying it. Explicit pins, omitted or inherited models, reserved main checks, workflow-defined models.auto, engine.model-catalog: false, unsupported-provider responses, and older-AWF or unsandboxed compatibility paths remain unchanged.

Claude inline sub-agents with unshadowed model: auto also use POST /select-model on sandboxed AWF v0.29.22+ when the selector is advertised and the catalogue is enabled. Selection stays within the configured provider, Claude model family, and /v1/messages. If the main session sets CLAUDE_CODE_EFFORT_LEVEL=medium, for example, the selector requires medium for the child too. Without an environment override, Claude Code 2.1.257+ uses the selected effort in the generated agent definition, including the bare-mode plugin copy, or leaves the field unset when AWF selects omission. Older pins without an override select for omitted effort. An explicit request such as model: auto?effort=high fails before launch if Claude cannot apply it. The child’s applied effort is recorded under its role in usage/aw_session.jsonl.

The Claude CLI flag --effort is a session default, not a per-agent override. When an automatic child has no effort of its own and selects the same concrete model as the main agent, Claude Code 2.1.257+ fails directly because the selector already evaluated all supported Claude efforts and returned none for that model; older pins that requested omitted effort (supported_efforts: []) verify that exact model with AWF for the inherited CLI default and record that effort. The CLI default does not constrain a child using a different model or one with its own selected effort.

On this selector path, a tracked Claude repository agent declaring built-in auto is left unchanged with a warning and gets no selector call or resolved-model record. inherit, omitted models, workflow-defined models.auto, and catalogue-disabled, older-AWF, or unsandboxed behavior are unchanged.

Pi sub-agents that explicitly declare unshadowed auto within the parent’s provider also use POST /select-model on sandboxed AWF v0.29.22+ with the catalogue enabled. Selection respects engine.config.model.api and excludes max on Pi 1.0 to 1.2. The selected endpoint and thinking level are applied to the child, and provenance is recorded under its role in usage/aw_session.jsonl. An effort-free selection explicitly disables child thinking rather than inheriting a shared default.

Pi shares one gateway entry per model ID. If an automatic child picks a model whose entry cannot support its endpoint or reasoning settings, Pi asks AWF for another eligible model in the same provider without changing the main model or pins. Startup still fails if there is no compatible alternative; configure a common API or pin a different child model. Omitted models still inherit the parent with zero selector calls. Concrete pins, shadowed models.auto aliases, catalogue-disabled runs, and older-AWF or unsandboxed compatibility paths are unchanged. The sub-agent name main is reserved.

Workflow-declared Codex sub-agents with unshadowed model: auto use the same selector when sandboxed on AWF v0.29.22+ with the catalogue enabled. Codex restricts the choice to the configured provider and /responses. It requests an explicit effort even when the child does not specify ?effort=, because a role that omits model_reasoning_effort can inherit the parent or spawn-default effort. For example, gpt-5.3-codex at medium produces a TOML role with model = "gpt-5.3-codex" and model_reasoning_effort = "medium". The generated choice is recorded under the child’s role in usage/aw_session.jsonl. An omitted model or inherit makes no selector call. Concrete models, shadowed models.auto, and older-AWF, catalogue-disabled, or unsandboxed compatibility paths are unchanged.

For Claude on Anthropic or Codex on OpenAI, set a router value explicitly. Routing uses your configured provider and its billing; it does not switch accounts or providers to find a model.

The routing tables in Agent Workflow Firewall (AWF) v0.29.21, the version gh-aw uses by default, include these GitHub Copilot model IDs:

FamilyGitHub Copilot model IDs
Claudeclaude-haiku-5.5, claude-sonnet-5, claude-sonnet-5.5, claude-opus-5.5
GPT 5.6gpt-5.6-luna, gpt-5.6-sol, gpt-5.6-terra
GPT 6gpt-6-astra, gpt-6-luna, gpt-6-sol
GPT 6.1gpt-6.1-sol, gpt-6.1-terra
GPT 6.2gpt-6.2-sol
Geminigemini-3.8-flash, gemini-4-argon, gemini-4-carbon, gemini-4-hydrogen
MAImai-code-1.1-flash, mai-code-2, mai-code-2-flash

For native OpenAI, the tables use the same GPT IDs. For native Anthropic, they use claude-haiku-5-5, claude-sonnet-5, claude-sonnet-5-5, and claude-opus-5-5.

At least one model must be enabled for the workflow’s provider account and compatible with its engine endpoints, model policy, and shortlist. On AWF v0.29.21 and newer, if none of the eligible models is in the router tables (or if the router cannot choose), AWF falls back deterministically to the highest-tier eligible model available instead of failing before the agent starts. For example, if an account or shortlist only enables gpt-5.3-codex and gpt-5-nano (neither of which is in the router tables), AWF skips the classifier call and selects gpt-5.3-codex over gpt-5-nano because standard coding models outrank lightweight models, recording selection_source=fallback and fallback_reason=no_route in the unified session. The run only fails before the main agent starts when no compatible model at all exists in the account, policy, and shortlist (or on AWF pins older than v0.29.21, which do not support fallback). If the workflow pins a different AWF version, check that version’s routing tables.

Run gh aw audit <run-url> and look at Model Routing. Compare the level you requested, the model and effort selected, and the cost with the work the agent actually produced. Use gh aw logs to compare several runs before deciding whether to change the level.

If the router found no eligible model, use gh aw audit <run-url> --models to see which models were available for that run, then check whether your engine, shortlist, or policy ruled them out. Widen the shortlist if appropriate; the router won’t pick a model outside it.

Updating an existing workflow after a compiler warning? See Migrate routing settings. For the normative contract covering routed and non-routed automatic selection across main agents, threat detection, and sub-agents, see the Automatic Model Selection Specification.