Skip to content

Support engine.model-routing for Claude and Codex on native Anthropic/OpenAI providers #73051

Done

Description

@SivaKesava1

Request

Allow engine.model-routing for Claude on native Anthropic and Codex on native OpenAI, using the provider-scoped routing already shipped in AWF. Workflows should be able to keep their own provider API keys and provider billing instead of moving inference to GitHub Copilot merely to enable routing.

Keep existing GitHub Copilot routing unchanged, including Claude/Codex with model-provider: github and the Copilot and pi engines. This is a gh-aw integration feature, not a new router or an AWF upgrade.

Verified background and corrections

Verified on October 29, 2026 against gh-aw main at 28f2101d8af447fdb90ffd70dd2579e4ad64a21c, AWF main at 492391885dc25aeae354afeb4d19b0659c3fbabf, and AWF v0.29.0 at b8eaea207ed8c217256096c10485077aad5ff6cc. The relevant native-routing contract, maintained API metadata, classifier/controller, and three cost tables are present in v0.29.0; do not rely on unrelated post-release changes on AWF main.

gh-aw blocks native routing today. validateModelRouting accepts only the resolved github provider. Default Claude therefore fails with the stated reason that task-level routing requires GitHub Copilot inference but Claude resolves to "anthropic"; default Codex similarly resolves to "openai". The fix suggested today is engine.model-provider: github.

The compiled AWFModelRoutingConfig has no provider field, and the config builder emits no apiProxy.routing.provider. AWF consequently defaults to copilot. Explicit/alias candidates are qualified with github-copilot/ in model_routing_candidates.go; omitted Claude/Codex candidates become github-copilot/claude-* or github-copilot/gpt-* in modelRoutingDefaultCandidates. The existing modelRoutingEngineNativeProviders map is only an alias-family compatibility hint: it does not enable native inference.

The docs accurately describe gh-aw's present restriction, but their AWF rationale is stale. The getting-started text, engine table, alias explanation, "GitHub Copilot models only" limitation, and troubleshooting row all describe Copilot-only routing. The statement that benchmark data and discovery cover only Copilot is no longer true of AWF. Update these consistently when the integration ships; do not imply native routing already works in gh-aw.

AWF already ships native routing. github/gh-aw-firewall#9223, "Add native OpenAI and Anthropic model routing", merged on September 30, 2026, and is listed in v0.28.28's release notes, published that day. Its merge commit is an ancestor of v0.29.0, which is gh-aw's default firewall version. The existing gh-aw routing floor is v0.28.29; independent routing.candidateModels support requires v0.28.33 plus a compatible API-proxy image. Preserve those version/image checks.

AWF's routing specification accepts provider: copilot (default), openai, or anthropic. Native routing requires the matching configured provider and its native HTTPS target, not a custom gateway. Routing does not switch credentials or translate across providers. This is a restriction of native task routing, not a claim that AWF has no other, separately configured fallback/translation features.

Table coverage is real, but is not an executable-model guarantee. Each of cost-economy.json, cost-balanced.json, and cost-robust.json ranks these native IDs alongside github-copilot/ IDs:

Provider Unique model IDs in each table
anthropic/ claude-haiku-4-5, claude-haiku-5-5, claude-opus-4-8, claude-opus-5, claude-opus-5-5, claude-sonnet-5, claude-sonnet-5-5
openai/ gpt-5.4, gpt-5.4-mini, gpt-5.5, gpt-5.6-luna, gpt-5.6-sol, gpt-5.6-terra, gpt-6-astra, gpt-6-luna, gpt-6-sol, gpt-6.1-sol

The proposed counts of 7 and 10 are unique models, not model/effort arms: the tables contain 31 Anthropic and 55 OpenAI model/effort pairs apiece. A ranked ID must still be discovered for the selected provider, survive the model policy/candidate filter, have usable endpoint/effort metadata, and overlap the router's rankings.

The maintained routing metadata covers OpenAI gpt-5.4 and gpt-5.4-2026-03-05; Anthropic claude-opus-5-5, claude-opus-5, claude-sonnet-5-5, claude-sonnet-5, claude-opus-4-6/4-7/4-8, claude-sonnet-4-6, claude-fable-5-1/5, and claude-mythos-5-1/5 plus the explicitly maintained claude-mythos-preview* pattern. Thus "exact mapping" must not be read as excluding that documented preview wildcard. Other family members do not automatically inherit routing support: o3, gpt-5-nano, and gpt-5.4-mini can yield no_route. Metadata coverage alone also does not add an ID to the router tables.

Motivation and related issue. The supported way to retain Claude/Codex while routing today is to move their inference to Copilot with model-provider: github, changing the inference credential and bill. Native routing should retain the provider-key path; AWF's own AI-credit accounting/guardrails are not the same thing as a Copilot invoice. #73045 is related motivation, not a Copilot-only routing defect: it concerns unreachable detection/evals gateway URLs for non-Anthropic-provider configurations, also affects BYOK, and does not require routing. Do not fix #73045 in this feature PR.

Integration findings

1. Native discovery, listeners, and harness startup

Native route API-proxy listener Agent protocol / upstream API Host credential
Claude / Anthropic api-proxy:10001 /v1/messages to api.anthropic.com ANTHROPIC_API_KEY
Codex / OpenAI api-proxy:10000 /responses, forwarded as /v1/responses to api.openai.com Existing CODEX_API_KEY or OPENAI_API_KEY secret path

Copilot is the separate listener on port 10002. Native provider adapters fetch /v1/models with the provider's authentication, and AWF builds the routing catalogue from those discovered IDs plus runtime/maintained metadata. See Anthropic adapter, OpenAI adapter, and routing catalogue.

Both harnesses call fetchAWFReflect, which currently fetches http://api-proxy:10000/reflect by default. An OpenAI key is not needed merely to read this management endpoint. AWF's adapters bind stub listeners even when inference credentials are absent, and every provider listener serves aggregate reflection before rejecting unconfigured inference. The comment in gh-aw saying port 10000 starts only with OpenAI credentials is stale; do not implement a new discovery service or require a second provider key. See adapter defaults and server request handling.

The agent-visible contract is /reflect.routing.status: selected with selection.provider, canonical selection.model, bare selection.wire_model, selection.effort, and selection.endpoint; the private routing selection.json is not a harness input. Provider-specific endpoints[] supply the configured listener/base URL, discovered models, and routing_models metadata. See AWF reflection state.

Use real native metadata in fixtures: when derived from the maintained mapping, routing_models[].supported_endpoints contains protocol names such as ["messages"] or ["chat_completions", "responses"], not necessarily path strings. buildRoutingModelMetadata emits that shape. The existing smoke helper only trims endpoint strings, and its servedModel comparison strips provider prefixes and normalizes Claude dash-form versions to dots. Native smokes therefore need protocol-to-path comparison and explicit native provider/wire-ID assertions; existing provider-blind comparisons alone cannot prove native routing. See smoke identity/endpoint helpers and capability comparison.

Harness changes are required, not merely possible. resolveAWFModelRoutingSelection currently accepts only Copilot provider aliases and looks up model availability/metadata only in GitHub endpoints. Make this shared path provider-aware and require agreement between the selected provider, the engine's resolved provider, and a configured matching endpoint. A missing native endpoint must fail closed, not fall back to another provider that happens to list the same model.

The existing Claude child-env builder already resolves ANTHROPIC_BASE_URL by provider. The existing Codex provider setup resolves OPENAI_BASE_URL and rewrites [model_providers.openai-proxy].base_url in config.toml; wire_api remains responses. Reuse these paths and the existing topology-aware URL handling.

The Claude log suffix selected_endpoint=/chat/completions comes from the existing Copilot endpoint-override path: the harness can use Messages while retaining the router's originally selected endpoint for diagnostics. It is not the native Anthropic endpoint. Native Anthropic selects Messages; the maintained OpenAI GPT-5.4 route uses Responses. Do not carry a Copilot endpoint override onto a native route without provider-scoped capability evidence.

2. Classifier model and credentials

There is no single hard-coded native classifier model and no additional classifier key/configuration to add to gh-aw. AWF supplies the same provider-scoped, policy-filtered candidate pool to /classify; the router orders the offered model/effort pairs by classification_choices. The proxy checks context capacity, tries up to two eligible classifier choices, and executes through that provider's authenticated adapter. The selected primary model can differ from the classifier. See classifier ordering, controller, and provider executor.

The table's first native preferences include anthropic/claude-haiku-5-5:high and openai/gpt-5.6-luna:high, but these are preferences, not guaranteed calls. Missing metadata/discovery excludes them. For a shortlist containing only the maintained claude-sonnet-5, the first matching table preference is medium; for only gpt-5.4, it is high, subject to capacity/availability checks. Runtime classifier_model and classifier_effort are the evidence of what actually ran. A missing positive context limit excludes a model from classifier preflight even if it can remain a primary routing candidate.

3. Effort on native providers

Claude's routed path sets ANTHROPIC_MODEL and CLAUDE_CODE_EFFORT_LEVEL, removes fixed model/effort CLI overrides, and clears the effort variable when selection effort is null. Codex injects the selected bare model plus -c model_reasoning_effort="..." after removing fixed overrides. Reuse this engine-specific handling. See Claude routing, Codex routing, and shared effort mapping.

The native request shapes to verify are Anthropic output_config.effort and OpenAI Responses reasoning.effort. AWF uses these same shapes for its own classifier and observes them in agent requests; see classifier request construction and native observation tests. A launch log alone does not prove the CLI sent the selected effort.

Do not infer native model capabilities from the harness's accepted effort vocabulary or Copilot metadata. The maintained Anthropic entries advertise low, medium, high, max; native GPT-5.4 advertises none, low, medium, high, xhigh. Neither justifies blindly copying a Copilot smoke's expected max onto native GPT-5.4.

The blanket statement "Haiku has no effort on Copilot" is too broad: the existing Claude smoke specifically excludes claude-haiku-4.5. On the native path, neither Haiku family has maintained routing effort metadata in the pinned mapping; Haiku 5 explicitly says its effort levels are unverified. A table entry is not enough to make either eligible. Unknown effort support must not be treated as an explicit empty effort list or an effortless choice.

4. Families, aliases, and policy

Keep Claude restricted to claude-* and Codex to gpt-*. AWF not crossing providers does not replace this harness/protocol restriction: an OpenAI-discovered model is not automatically a Codex-compatible GPT Responses model.

For native routing, emit bare native candidates: defaults ["claude-*"] and ["gpt-*"], and exact IDs unchanged. Expand aliases from the selected native namespace, not by stripping github-copilot/ from today's output. For example, the shared sonnet alias includes anthropic/*sonnet*; intersect that with Claude's family to emit claude-*sonnet*. This matches Anthropic claude-sonnet-5-5 without converting it to Copilot claude-sonnet-5.5.

Preserve exact-ID precedence over aliases using the active provider catalogue; keep allowed-models as exact names/aliases, not newly allowed user-authored globs. Normalize a matching provider-qualified exact entry to the native candidate; reject a mismatched provider prefix rather than silently retargeting it. Aliases with no compatible entries must fail clearly.

Make candidate-policy intersection and omitted-family policy checks provider-aware too: copilotQualifiedModelPolicyRule and related helpers currently assume Copilot. Native bare patterns and matching anthropic/ or openai/ policy patterns must work; github-copilot/claude-* must not authorize Anthropic. Keep models.allowed/blocked as the request policy and routing.candidateModels as a narrower router/classifier shortlist. Do not rewrite the global shared alias table or apply Claude's Copilot-only dash-to-dot modelOverrides on native Anthropic.

5. Unsupported targets and provider interactions

Checking only the model-provider string is insufficient. Allow github, or the engine's own native provider, and validate the effective routing target. Claude/OpenAI, Codex/Anthropic, other provider values, and native-provider routing on Copilot/pi remain outside this feature.

Reject authored custom targets/BYOK gateways/Azure OpenAI even when the provider label is anthropic, openai, or github. Use the existing target/BYOK resolution paths: engine.api-target, relevant engine.env base URLs, supplemental gateway configuration, and Azure configuration can change the destination independently of the provider label. See target resolution and AWF target construction.

Correction to "still rejected": today's routing validator rejects native providers, but has no explicit routing-target check; merely relaxing its provider condition would be insufficient. The new diagnostics should name the unsupported provider/target and say to use the matching native HTTPS endpoint (or actual GitHub Copilot), remove the custom target, or remove model-routing. Do not tell a supported native-key workflow that it must switch to Copilot. Preserve AWF's runtime native-adapter check for effective runtime configuration.

Intended behavior and implementation plan

  1. Validation: Allow Claude with omitted model-provider or explicit anthropic, and Codex with omitted provider or explicit openai, while retaining GitHub support and rejecting unsupported provider/target combinations. Use a consistent effective provider across validation, config generation, credentials, and harness startup. Preserve existing firewall, image/version, family, and policy checks.
  2. Config: Emit apiProxy.routing.provider: anthropic or openai only for native routing. Preserve omission for Copilot so existing lock serialization stays unchanged. Retain the current objective, task.conversationFile, experimental.modelRouting, and digest-pinned image manifest.
  3. Candidates: Generate native exact/family/alias patterns and provider-aware policy intersections. Keep authored and resolved routing information consistent in compiled metadata. No new routing tables, speculative capability mappings, model additions, or global alias rewrite.
  4. Harnesses: Adapt the shared awf_model_routing.cjs selection/availability/metadata checks and their Claude/Codex callers. Reuse native base-URL discovery and effort injection, retain strict model/provider/endpoint validation, and leave Copilot endpoint overrides unchanged. Keep real provider credentials in AWF's sidecar and the existing sandbox placeholder isolation.
  5. Docs: Update docs/src/content/docs/reference/model-routing.md, including the limitation heading/rationale, engine table, troubleshooting row, getting-started authentication text, and alias/provider descriptions. Explain native discovery/metadata limits, provider billing versus AWF accounting, and unsupported gateways. Correct the directly relevant stale reflection-port comment.
  6. Smokes: Add both smoke-claude-routed-anthropic and smoke-codex-routed-openai, modelled on the existing routed smokes and post-step assertions. Use native-key credentials and simple tasks. Use a maintained/discovered shortlist such as native claude-sonnet-5 and gpt-5.4 for predictable integration coverage; exercise omitted family defaults in compiler tests. Do not copy Claude's copilotInventory: true or Codex's expectSelectedEffort: "max" into native smokes. Adapt directly relevant evidence helpers for native protocol metadata and explicit provider/wire-ID checks. Require native-provider inventory and actual requested-effort evidence without weakening the existing Copilot checks.

Acceptance cases

The following test names are proposed. Extend existing test files/helpers rather than constructing a different config or record dialect. In particular, reuse the compiled-lock extraction approach in model_routing_aliases_test.go: the real lock writes awf-config.json through a shell-escaped printf, and the test decodes that payload.

  1. Claude on Anthropic - TestModelRoutingClaudeNativeProviderCompile. Compile a Claude workflow with goal: cost, mode: economy, and omitted allowed-models, with subcases for omitted provider and explicit anthropic. Assert apiProxy.routing.provider is anthropic, candidateModels is exactly ["claude-*"], and the agent execution retains ANTHROPIC_API_KEY: ${{ secrets.ANTHROPIC_API_KEY }} and GH_AW_LLM_PROVIDER: anthropic. No Copilot credential substitution, Copilot model override map, or github-copilot/ routing candidate. Scope that last assertion to the native route: unrelated jobs and the shared multi-provider alias table need not be stripped. Add the harness case native Anthropic selection applies model, effort, and Messages endpoint using real-shaped reflection, including claude-sonnet-5-5, to assert the bare model, matching listener, and CLAUDE_CODE_EFFORT_LEVEL.

  2. Codex on OpenAI - TestModelRoutingCodexNativeProviderCompile. Equivalent omitted/explicit provider subcases produce provider: openai and exactly ["gpt-*"]. Preserve both existing OpenAI/Codex execution-key assignments from ${{ secrets.CODEX_API_KEY || secrets.OPENAI_API_KEY }}, without changing to Copilot inference. Add native OpenAI selection applies model, effort, and Responses endpoint to the harness tests: native gpt-5.4, matching port 10000/base URL, wire_api: responses, selected model argument, and model_reasoning_effort override. Both harness suites must reject wrong-provider, absent/unconfigured-endpoint, unavailable-model, incompatible-endpoint, and unsupported-effort selections without cross-provider fallback.

  3. Native allowed-models, aliases, and policy - TestModelRoutingNativeAllowedModelsAndAliases. allowed-models: [claude-sonnet-5] emits that exact native ID. The sonnet alias yields native family-constrained patterns matching claude-sonnet-5-5, not a forced dot-form ID or Copilot candidate. Cover exact dash-form IDs, matching/mismatched provider qualification, active-provider exact-ID precedence, and native allow/block intersection, including an entirely excluded family. Keep direct wildcard entries in allowed-models invalid.

  4. Unsupported providers/targets - TestModelRoutingRejectsUnsupportedProviderTargets. Cover Claude custom api-target, Anthropic/OpenAI custom base URLs, BYOK gateway configuration, Azure OpenAI labelled openai, cross-provider engine choices, and unsupported Copilot/pi native choices. Errors identify the incompatible provider/target and give an actionable alternative. Genuine default/native HTTPS targets compile. Existing runtime failure tests continue to fail closed when no native route or required metadata is available; do not manufacture effort support for Haiku or unsupported GPT IDs to make a test pass.

  5. Copilot regression - TestModelRoutingCopilotLocksUnchanged. Using identical source inputs, compiler version, and pins, existing smoke-claude-routed, smoke-codex-routed, and avenger compiles produce byte-identical locks. Retain omitted routing.provider, existing github-copilot/ candidates, provider credentials/base URLs, effort behavior, and endpoint-override diagnostics. Include existing Copilot and pi routed fixtures in the regression set; no incidental generated lock churn.

  6. Native evidence contract and live smokes - TestNativeRoutingSmokeEvidence, plus smoke-claude-routed-anthropic and smoke-codex-routed-openai. Add fixture-based assertions grounded in AWF's native selection/observation tests and the existing captured routing JSONL, then require successful native smoke evidence from the merged workflows on main.

    The raw model-routing.jsonl selection has event: model_routing, stage: selection, native provider/selected_provider, canonical selected_model such as anthropic/claude-sonnet-5 or openai/gpt-5.4, bare wire_model, selected_effort, and the native endpoint. Reflection uses routing.selection.model/effort; it is not the raw record shape. Request records use bare requested_model and request-side selected_model, requested_effort, provider, pathname, request_id, routed, terminal outcome, and HTTP status. Do not mistake raw mode (a routing profile) for the harness log's mode=awf-routed.

    Require the classifier and successful main-agent requests to use the native provider; the main request must use the selected model and effort on Messages/Responses, with routed: as_selected and successful terminal evidence, correlated with token usage where available. Native selection/provider/effort mismatches must fail the fixture assertions, including the same wire model on the wrong provider and a Copilot dot-form ID substituted for an Anthropic dash-form ID. Cover maintained-only symbolic endpoint metadata as well as runtime path-form metadata. Preserve raw snake_case fields versus the unified-session parser's camelCase fields. The existing runner/proxy-based checks in smoke_model_routing_assertions.cjs must report PASS for execution/evidence, selection, classifier, model, and endpoint checks, plus requested-effort checks for both native smokes. A green workflow, agent-authored success issue, or launch log alone is insufficient.

AWF's current audit contract is advisory about the selected route: other policy-permitted sub-agent models can be recorded as deviations. This feature must not turn the main-agent shortlist into an all-request pin or change sub-agent policy. The live smoke above is deliberately a simple main-agent exercise.

This issue records source/lock verification, not a completed provider-key live run. Live smoke execution is a post-implementation acceptance requirement and must follow the repository's execution authorization gates; filing this issue does not authorize dispatch.

Scope

  • Keep the PR to this one feature. Do not change files or behavior unrelated to it.
  • 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. Once main is fixed, merge main into the PR, 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.

Metadata

Metadata

Labels

compilerenhancementmodel-routing

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions