Skip to content

Default workflows without a model to balanced routing on Copilot #76312

Done

Description

@SivaKesava1

Summary

Make task-level model routing the default for eligible main-agent workflows that have not chosen a model or routing configuration. Use goal: cost and mode: balanced, only on the GitHub Copilot inference provider. Preserve explicit choices, repository/organization model variables, unsupported configurations, and secondary-agent behavior. Add an explicit opt-out: engine.model-routing: false.

This is a compiler default, not a bulk rewrite of workflow sources to pin different models.

Current behavior and corrections

Code was checked against main at 1e0f35fda7ee.

  • The workflow schema requires only on; a model is optional.
  • A frontmatter-key census of the 365 root .github/workflows/*.md files with an on key finds 221, not 219, without top-level model or engine.model. Of these, 75 already declare engine.model-routing, leaving 146 without either model or routing; one more declares an override recognized by isModelRoutingOverrideEnvKey, leaving 145 before resolving imports and other eligibility restrictions. These are source counts, not the number of locks this change should affect.
  • Copilot's fallback constant is CopilotBYOKDefaultModel = "auto". The alias map first tries copilot/auto, then large, whose first alternative is sonnet. Thus auto -> large -> sonnet describes a fallback path, not an unconditional resolution to a permanently fixed model. Current fixtures observe Sonnet 5.5.
  • Claude Code does not simply choose its own default: applyClaudeModelEnvVars supplies the phase-specific variable, then GH_AW_DEFAULT_MODEL_CLAUDE, then SonnetDefaultModel, currently claude-sonnet-5.
  • Explicit routing currently suppresses the ordinary model-variable fallback. warnRoutedModelOverrides warns about fixed settings visible in workflow configuration, including recognized engine.env entries. It does not inspect repository/organization variable values at compile time or necessarily warn when those external variables are set.

Existing-run evidence

All five supplied runs were audited using a Windows dev CLI built from the main SHA above, reporting gh aw version dev-1e0f35fda7ee, not the installed stable v1.0.1. Audits used the full run URLs, --no-baseline, --artifacts usage, and --json. All five Actions conclusions are success; each unified session contains one agent-phase firewall.model_routing event with data.stage: selection and objective cost/balanced. Artifacts identify AWF v0.29.10 and router 0.3.0.

Workflow / run Engine, on Copilot inference Selected model / effort Agent-phase AIC, including classifier Recorded all-phase AIC
avenger / 42634790791 Copilot CLI claude-sonnet-5.5 / high 24.98 26.29
daily-vulnhunter-scan / 42568697673 Claude Code claude-sonnet-5.5 / high 25.17 26.04
static-analysis-report / 42563040467 Claude Code claude-sonnet-5.5 / high 61.04 62.92
sergo / 42557907411 Claude Code claude-sonnet-5.5 / high 80.70 82.06
daily-action-setup-security-audit / 42551029660 Copilot SDK gpt-6.1-terra / high 18.39 19.46

The last column sums recorded agent/classification, threat-detection, and available eval usage. Agent/detection costs come from per-request firewall.token_usage.data.aic, not repeated cumulative totals; eval costs come from usage.report.data.totalAic. In particular, Sergo rounds to 82.1, not 82.0, at one decimal. The audit's routing/agent cost is not the whole-workflow total.

#75843 made AWF v0.29.10 gh-aw's default. Its shipped cost/balanced table uses schema v2, per-cell rankings. The table-update commit, authored by rabeckett, records github/gh-aw-firewall#11198. These runs demonstrate working selections with those shipped tables, including keeping Sonnet for four tasks; they are not a controlled quality or savings experiment.

Limits on the proposed savings claims: The supplied pre-routing medians of 131, 152, 287, 200, and 79 AIC were not independently reproduced from an identified baseline sample. Relative to those supplied medians, the recorded totals imply approximately 59-83% lower cost, not a measured general 60-80% routing effect. Workload, model generation, engine, and token-volume differences can contribute; a successful Actions conclusion does not establish equivalent task quality.

The GH-AWTrace paper, full text, and dataset card establish a log cohort of 23 June-21 September 2026; the run-metadata inventory extends back to August 2025. They do not report the proposed 62% review/analysis share, 34/48-credit successful-run medians, or a balanced-routing replay of 375k credits over 7,001 successful runs with about half choosing Sonnet and 35% savings. No public reproducible analysis for those derived figures was obtained, so they are not presented here as verified results. Attach the cohort, classification/accounting queries, table revision, and replay method before using those figures; a replay would still be a counterfactual estimate, not observed savings or validated success on the newly selected models.

Intended behavior

  1. Eligibility: Apply cost/balanced routing only to the main agent, after resolving workflow/imported engine settings and explicit-choice provenance, but without mistaking compiler-synthesized fallback models for author choices. Supported engines are copilot, claude, codex, and pi, and the effective inference provider must be GitHub Copilot. Claude/Codex must retain their current model-family and API restrictions. Do not select Copilot credentials merely because a workflow grants copilot-requests: write.
  2. No explicit model choice: Neither the workflow nor its resolved imports choose top-level model, engine.model, or engine.model-routing, and no engine.env key is an override under isModelRoutingOverrideEnvKey in pkg/workflow/model_routing.go. Preserve the helper's case-insensitive rules: MODEL, suffixes _MODEL, _MODEL_ID, _MODEL_NAME, and prefixes GH_AW_MODEL_AGENT_, GH_AW_MODEL_DETECTION_, GH_AW_MODEL_EVALS_, GH_AW_DEFAULT_MODEL_. Explicit aliases, model: auto, expressions, and empty/ambiguous declarations must not accidentally become implicit opt-ins.
  3. Conservative capability gating: Reuse validateModelRouting, provider-target resolution, AWF version/image gates, and model-policy rules. No AWF sandbox, an unsupported engine/provider, incompatible pinned AWF/images, an explicit fallback-model chain, custom model-bearing configuration/arguments, or an incompatible custom execution path must not turn a previously valid workflow into a routing error. When safe eligibility is uncertain, retain today's behavior, without a new routing warning. Do not change sandbox versions, credentials, harness/SDK mode, sub-agent models, or policy to force eligibility.
  4. Runtime precedence decision: activation, before AWF starts. The compiled lock must resolve the existing Actions vars.GH_AW_MODEL_AGENT_<ENGINE> and vars.GH_AW_DEFAULT_MODEL_<ENGINE> inputs for the applicable engine at run time, with the phase-specific agent variable winning over the default. For implicit/default routing only, a nonempty configured variable selects the legacy non-routed execution path. Propagate that activation decision consistently to prompt preparation, AWF configuration, model environment/arguments, and model metadata. There must be no classifier call or routing selection event. Do not implement this by letting AWF select a route and then overriding it in the harness: that is too late. Do not inspect the compiler machine's environment or snapshot variable values during compilation. Invalid configured models retain existing validation/error behavior, rather than silently falling back to routing.
  5. Explicit routing is unchanged: An authored/imported routing block keeps its goal, mode, shortlist, policy behavior, and existing precedence over fixed-model settings and external fallback variables. Track implicit versus explicit provenance internally; do not add an invented field to the AWF config.
  6. Opt-out: Accept the literal boolean false at engine.model-routing, alongside the existing routing object; do not add a top-level model-routing field or treat true as a new shorthand. Preserve the explicit false through extraction/import merging instead of collapsing it into an absent/nil routing configuration. It disables the implicit default without pinning a model and retains the existing fallback-variable behavior.
  7. Discoverability: Emit one informational compile notice per workflow when the implicit default is emitted, explaining cost/balanced routing and the opt-out. Make clear that runtime model variables can bypass it. This must not increase warning counts or produce routing notices for excluded workflows.
  8. Documentation: Update docs/src/content/docs/reference/model-routing.md, the shared reference/engines.md, and the relevant reference/engines/{copilot,claude,codex,pi}.md pages. Explain eligibility, the new default, runtime-variable precedence, opt-out, explicit-model/explicit-routing preservation, provider limitations, and possible cost/quality variation. Existing advice to opt into routing and start with mode: auto must distinguish explicit configuration from the new implicit balanced default.

Code and fixture anchors

  • Configuration/schema: pkg/parser/schemas/main_workflow_schema.json (engine_config and its references), EngineConfig, and applyEngineModelRoutingField in pkg/workflow/engine.go.
  • Resolution/provenance: setupEngineAndImports, resolveEngineFromIncludesAndImports, and mergeImportedModelRoutingConfigs in pkg/workflow/compiler_orchestrator_engine.go; workflow validation/defaulting in compiler_orchestrator_workflow.go.
  • Routing/capabilities: isModelRoutingEnabled, isModelRoutingOverrideEnvKey, validateModelRouting, modelRoutingProvider, and generateModelRoutingConversationStep in model_routing.go; provider-target checks in model_routing_targets.go.
  • Lock/runtime wiring: BuildAWFConfigJSON in awf_config_build.go, BuildAWFCommand in awf_command_builder.go, activation steps/outputs, and the engine model-env builders, including addCopilotModelEnv and applyClaudeModelEnvVars. Update only the paths needed to carry the implicit/explicit distinction and pre-AWF decision.
  • Real routed lock shapes are in .github/workflows/avenger.lock.yml and .github/workflows/daily-action-setup-security-audit.lock.yml. Current generated AWF fields are experimental.modelRouting, apiProxy.routing.objective.goal, apiProxy.routing.objective.mode, apiProxy.routing.task.conversationFile, and container.images.router. The generated step is Prepare model-routing conversation, and the harness flag is GH_AW_MODEL_ROUTING. GitHub routing does not require inventing a new provider field.
  • Reuse compileRoutedWorkflowSource and agentAWFConfigFromLock in pkg/workflow/model_routing_aliases_test.go to decode actual emitted configuration. Extend current model-routing/model-variable tests rather than asserting against imagined lock structure.

Acceptance cases and named tests

The names below are proposed regression tests, not claims that they already exist. Compiler tests must compile small Markdown/frontmatter fixtures and inspect the generated lock's parsed config, step/env wiring, and diagnostics.

Case Required observation Proposed test
A A Copilot/GitHub workflow with no model or routing emits apiProxy.routing with cost/balanced, the existing conversation-file field, experimental.modelRouting, and the digest-pinned router image. It emits one informational notice. A real run with model variables unset records firewall.model_routing, data.stage: selection, in usage/aw_session.jsonl. TestCompileDefaultModelRouting_Copilot in pkg/workflow/model_routing_test.go; verify a subsequent authorized run separately.
B Adding top-level model: claude-sonnet-5.5 leaves today's non-routed lock behavior unchanged. Cover engine.model, an explicit alias/auto, expressions, and an imported model as subcases; no default notice. TestCompileDefaultModelRouting_ExplicitModelUnchanged in model_routing_test.go.
C engine.model-routing: false is schema-valid and produces the existing non-routed execution/fallback behavior without pinning a model. Test false surviving import merging; no router image, routing configuration, conversation step, or default notice. TestCompileDefaultModelRouting_ExplicitFalse in model_routing_test.go, plus extraction/schema cases alongside existing tests.
D An explicit routing block keeps its own goal/mode and shortlist, including non-balanced modes and imported routing. Runtime fallback variables do not disable explicit routing. TestCompileDefaultModelRouting_ExplicitRoutingUnchanged in model_routing_test.go.
E The same no-model Copilot lock contains the runtime variable guard. Activation tests cover neither variable, each variable alone, and both with the agent variable winning. With an override, the materialized config has no routing, the model environment is populated, and the harness does not require a routing selection. A real run with GH_AW_DEFAULT_MODEL_COPILOT set records the configured/effective model and no agent routing selection in aw_session.jsonl; use an authorized test repository, not a settings change on the production repository. TestCompileDefaultModelRouting_RuntimeOverrideGuard in model_routing_test.go; activation-path TestDefaultModelRoutingActivationHonorsModelVariables in pkg/workflow/model_env_vars_test.go, exercising the generated decision/config path with stubs.
F Claude with model-provider: github, copilot-requests: write, and no model gets balanced routing with Claude-family candidates. Claude/Anthropic-key and Codex/OpenAI-key no-model fixtures retain today's non-routed behavior. Also cover supported Codex/GitHub and Pi/GitHub paths and their existing restrictions; do not silently omit supported engines. TestCompileDefaultModelRouting_ProviderMatrix in model_routing_test.go, reusing fixtures/helpers from model_routing_native_test.go.
G Gemini, Agy/custom engines, no-AWF workflows, and incompatible/ambiguous configurations compile as before, with no new routing error, warning, or default notice. Include recognized engine.env overrides, old/unknown image capability, fallback-model chains, and incompatible custom execution/model settings. TestCompileDefaultModelRouting_IneligibleUnchanged in model_routing_test.go.
H With compiler inputs/pins held constant, one-shot recompilation changes only locks of workflows that resolve to an eligible no-model/no-routing configuration. Explicitly modeled, explicitly routed, opted-out, unsupported, and ambiguously configured workflows retain their previous locks. List every changed workflow and why it is eligible in the PR; do not use the raw 221-file count as the expected diff. TestRecompileDefaultModelRouting_EligibleLocksOnly, backed by a before/after eligibility manifest and lock diff, alongside the fixture tests.

Retain and extend TestCompiledRoutedWorkflowDoesNotRouteDetectionOrEvals, TestRoutedEnginesDoNotRouteThreatDetection, and actions/setup/js/model_routing_contract.test.cjs to prove that implicit routing does not leak into threat detection/evals or change sub-agent models. In particular, preserve Copilot CLI cross-family sub-agent compatibility; do not enable SDK mode as an unrelated workaround. Test ambiguous/incompatible cases conservatively.

The existing runs above validate today's explicit routing, not this proposed default or case E. No new run was dispatched for this investigation. Implementation live checks require their own explicit authorization and the repository's exact-revision review/compile gates.

Non-goals

  • Changing workflows with explicit model, engine.model, or an existing routing block; changing native model: auto semantics.
  • Default routing on native Anthropic/OpenAI keys, custom gateways, or other providers. Native routing already exists, but coverage is incomplete: the v0.29.10 mapping gives OpenAI routing effort metadata only to exact GPT-5.4 IDs, while Anthropic has metadata for several families but gaps such as Haiku. See Complete routing effort metadata for current OpenAI and Anthropic models gh-aw-firewall#10030. This is not a claim that Anthropic has no routable models.
  • Changing threat-detection, eval, or sub-agent model choices; router tables, classifier, or AWF.
  • Economy/robust defaults, per-task defaults, new credentials/provider migrations, or unrelated workflow/prompt changes.
  • Guessing whether an ambiguous workflow chose a model. Keep today's behavior instead.

Related: #70297 concerns team-configurable defaults; #74970 concerns native Auto semantics. This issue is specifically the implicit cost/balanced compiler default and preservation of explicit choices.

Scope

  • Keep the PR to this one fix. 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; 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.

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