Skip to content

Choose model routing with model: router and router/economy|balanced|robust - #76617

Merged
SivaKesava1 merged 11 commits into
mainfrom
copilot/choose-model-routing
Nov 11, 2026
Merged

SivaKesava1 merged 11 commits into
mainfrom
copilot/choose-model-routing

Conversation

Copilot AI commented Nov 10, 2026 •

Copy link
Copy Markdown
Contributor

Today a workflow asks for routing with a separate engine.model-routing block that has two required fields, and in practice the goal is always cost. This PR lets a workflow choose routing through its model value instead:

model: router/economy   # same as engine.model-routing: {goal: cost, mode: economy}
Value Equivalent engine.model-routing
router goal: cost, mode: auto
router/economy goal: cost, mode: economy
router/balanced goal: cost, mode: balanced
router/robust goal: cost, mode: robust

engine.model-routing is unchanged, and so is the implicit default for workflows with no model.

Compiler

  • Normalization (pkg/workflow/model_router_value.go): once model precedence is resolved, a router value is turned into the existing CopilotModelRoutingConfig, and the main model is cleared.
    • Precedence: engine.model beats top-level model, and a workflow's own model beats an imported one.
    • Because the existing routing path is reused, the AWF config, routing validation and lock output need no changes.
    • Clearing the main model keeps threat detection and evals from being routed.
    • models.allowed/models.blocked still narrow the choice, and Claude and Codex keep their model family.
    • An explicit router value counts as an explicit choice, so the implicit-default notice and its run-time model-variable bypass don't apply to it.
  • Rejections:
    • Unknown router/* values, including router/auto and router/Economy. The error lists the valid values.
    • Parameters such as ?effort=high.
    • A router value combined with engine.model-routing (including one that is imported), with engine.model-routing: false, or with engine.fallback-models.
    • A router value in models.allowed, models.blocked, fallback-models, model-routing.allowed-models, or a models: alias, and an alias named router.
    • A router value for a sub-agent, threat detection (model or engine.model), evals, or an enclave agent.
    • Unsupported engines, providers and endpoints get the same errors as engine.model-routing. One consequence: Copilot with a custom api-target still compiles, as it does with engine.model-routing today.
  • The model routing config recorded for each run (GH_AW_INFO_MODEL_CONFIG) gains a routing.requested field. Apart from that field, the lock for a router value matches the lock for the equivalent engine.model-routing block.

Run-time guard (generate_aw_info.cjs)

  • If the main model arrives through an expression or variable (for example ${{ vars.MODEL }} or GH_AW_DEFAULT_MODEL_COPILOT), resolves to a router value, and the run isn't routed, activation fails with ERR_CONFIG before the agent starts.

Audit

  • gh aw audit shows routing.requested (for example router/economy) as the requested model, next to the model the router picked.
  • The copy of the run info under the agent directory is untrusted, so audit ignores its model_config.
  • AwInfo gains ModelConfig, and the unified-session and logs JSONL schemas are updated to match.

Docs

  • The Model Routing reference now leads with model: router. It says a workflow with no model already behaves like model: router, and keeps engine.model-routing for goal: cost-speed and shortlists.
  • Updated: the engines, frontmatter, glossary and model-tables pages, the descriptions of model and engine.model in the workflow schema, and .github/aw/syntax-engine.md and debug-model-engine-misconfiguration.md.
  • The alias spec gets a new §9.4 that reserves router and the router/ namespace.

Not in this PR

These follow the issue's out-of-scope list:

  • Deprecating engine.model-routing, or a gh aw fix codemod for it.
  • Accepting router values in model variables, experiments or sub-agents (only the run-time guard is added).
  • Pointing the small and large aliases at router values.
  • Moving existing workflows to router values. No lock files change.

Copilot AI changed the title [WIP] Refactor model routing to be included in model block Choose model routing with model: router and router/economy|balanced|robust Nov 10, 2026
Copilot AI requested a review from SivaKesava1 November 10, 2026 22:27
@github-actions

Copy link
Copy Markdown
Contributor

Category: feature | Risk: medium | Score: 62 (impact 35 + urgency 13 + quality 14) | Action: batch_review | Batch: pr-batch:eligible-copilot

Generated by 🔧 PR Triage Agent · copilot · mai11 · ~5 AIC · ⌖ ~1 AIC · ⊞ 14.9K · ◷

@SivaKesava1
SivaKesava1 marked this pull request as ready for review November 11, 2026 02:08
Copilot AI adaptive review requested due to automatic review settings November 11, 2026 02:08
@github-actions

github-actions Bot commented Nov 11, 2026 •

Copy link
Copy Markdown
Contributor

✅ PR Code Quality Reviewer completed the code quality review.

PR Code Quality Reviewer

Outcome: reported_action

The agent completed and reported one or more actions. The no-op output is a completion signal, not a claim that no action was taken.

Agent messages are omitted from this comment. The category uses structured run status, not interpretation of agent prose.

Generated from PR Code Quality Reviewer · gpt56 · ~5 AIC · ⌖ ~2 AIC · ◇ ~1 AIC · ⊞ 1.6K · ◷

🔎 Code quality review by PR Code Quality Reviewer

@github-actions

github-actions Bot commented Nov 11, 2026 •

Copy link
Copy Markdown
Contributor

✅ PR Specification Reviewer completed successfully!

Commit pushed: 49bfe05

Generated by PR Specification Reviewer for #76617

@github-actions

github-actions Bot commented Nov 11, 2026 •

Copy link
Copy Markdown
Contributor

✅ Test Quality Sentinel completed test quality analysis.

Test Quality Sentinel

Outcome: reported_no_action

The agent completed and reported no action. A no-op output alone does not verify that all required work was completed or that publication was possible.

Agent messages are omitted from this comment. The category uses structured run status, not interpretation of agent prose.

Generated from Test Quality Sentinel · routed: haiku55 xhigh · ~1 AIC · ⌖ ~2 AIC · ◇ ~1 AIC · ⊞ 7.2K · ◷

🧪 Test quality analysis by Test Quality Sentinel

@github-actions

github-actions Bot commented Nov 11, 2026 •

Copy link
Copy Markdown
Contributor

🧠 Matt Pocock Skills Reviewer has completed the skills-based review. ✅

🧠 Reviewed using Matt Pocock's skills by Matt Pocock Skills Reviewer

@github-actions

github-actions Bot commented Nov 11, 2026 •

Copy link
Copy Markdown
Contributor

✅ Ponytail Reviewer completed successfully!

Generated by Ponytail Reviewer for #76617

@github-actions

github-actions Bot commented Nov 11, 2026 •

Copy link
Copy Markdown
Contributor

✅ Design Decision Gate 🏗️ completed the design decision gate check. See the comment below for the result and any generated ADR draft.

🏗️ ADR gate enforced by Design Decision Gate 🏗️

@github-actions github-actions Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What this change does: It lets workflows select model routing through the model value and records that choice for audit.

Should fix

  1. Reuse the existing model configuration parser for the runtime guard. It avoids maintaining two readers for the same routing state.

Verdict: Ship after simplification.
Lean: -13 lines possible.

Generated by ✂️ Ponytail Reviewer for #76617 · codex · routed: gpt61 medium · ~8 AIC · ⌖ ~1 AIC · ⊞ 181
Comment /ponytail to run again

Comment thread actions/setup/js/generate_aw_info.cjs Resolved
@github-actions

Copy link
Copy Markdown
Contributor

Comment Memory

Peek at saved memory (pr-code-quality-reviewer)
reviewed_at: 2026-11-11T02:11:20Z
review_event: COMMENT
top_themes: [reserved router namespace validation]
files_reviewed: [pkg/workflow/model_router_value.go, actions/setup/js/generate_aw_info.cjs, pkg/cli/model_routing.go, pkg/cli/logs_models.go]
comment_count: 1

Note

This comment is managed by comment memory.

Expand the saved memory block to view or edit the persistent context for this thread.
Edit only the text inside the backtick fences; workflow metadata and the footer are regenerated automatically.

Learn more about comment memory

🔎 Code quality review by PR Code Quality Reviewer · copilot · gpt50 · ~5 AIC · ⌖ ~2 AIC · ⊞ 1.6K · ◷
Comment /review to run again

@github-actions github-actions Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Found one correctness issue in router namespace validation.

Finding

  • Alias keys under models: only reject the exact key router, allowing reserved router/* names such as router/economy to be defined and collide with routing syntax.

No tests were run; this was a static diff review.

🔎 Code quality review by PR Code Quality Reviewer · copilot · gpt50 · ~5 AIC · ⌖ ~2 AIC · ⊞ 1.6K
Comment /review to run again

Comment thread pkg/workflow/model_router_value.go Resolved

Copilot AI commented Nov 11, 2026

Copy link
Copy Markdown
Contributor Author

@copilot

🍳 A little prep to help this PR along! Copilot assignment requested for the following outstanding work:...

Latest main was already included by merge commit 5797fa7; make merge-main completed with no tree changes. The failing check is GO-2026-6859 in net/http on Go 1.27.3, fixed in 1.27.4, and I confirmed the same failure on main. Per the scope note, I left the toolchain upgrade out of this PR.

@github-actions

Copy link
Copy Markdown
Contributor

Triage

Generated by 🔧 PR Triage Agent · copilot · mai11 · ~6 AIC · ⌖ ~2 AIC · ⊞ 14.9K · ◷

@gh-aw-bot

Copy link
Copy Markdown
Collaborator

@copilot

🍳 The prep is done, but CI needs another taste test. Copilot's assigned task has finished; these checks are still failing: Completed task

  • lint-go-govulncheck (FAILURE) — Check run

Please address the remaining CI failures on this PR's existing branch. No merging or CI triggering.

Structured data
{
  "completed_task": 42967278259,
  "head": "fe7589eb871eb6ad6a98d89bff040c64e7403203",
  "kind": "ci-follow-up",
  "schema_version": "1",
  "state": "dd4ddd0b8ee8cf4d925a9e8e5215e651b4bc20a5a4170ca260783b9ba1488632",
  "work": [
    "4ce4dd407e604d374ecd66edfd2afc18c54e2d0b3733dbac37ac8e9c8834fdba"
  ],
  "workflow": "pr-sous-chef"
}

Generated by 👨🍳 PR Sous Chef · pi · routed: haiku55 xhigh · ~2 AIC · ⌖ ~2 AIC · ⊞ 6.9K · ◷
Comment /souschef to run again

Copilot AI commented Nov 11, 2026

Copy link
Copy Markdown
Contributor Author

@copilot

🍳 The prep is done, but CI needs another taste test. Copilot's assigned task has finished; these checks are still failing: [Completed task](https://github.com/github/gh-aw/actions/runs/42...

Synced the branch with latest main in 35bd71f, which includes Go 1.27.4 and matching toolchain baseline updates. The latest main CGO govulncheck passed with 1.27.4. No PR merge or workflow dispatch was performed.

@github-actions

Copy link
Copy Markdown
Contributor

Category: feature | Risk: medium | Score: 76/100 (impact 40 + urgency 21 + quality 15). Recommended action: batch_review. Batch: pr-batch:copilot-platform. Reason: this is the largest scope item in the set and merits a grouped review alongside the other automation changes.

Generated by 🔧 PR Triage Agent · copilot · mai11 · ~5 AIC · ⌖ ~2 AIC · ⊞ 15.9K · ◷

@github-actions

Copy link
Copy Markdown
Contributor

Category: feature | Risk: medium | Priority: medium | Score: 76/100 (impact 40 + urgency 21 + quality 15)
Recommended action: batch_review | Batch: pr-batch:copilot-ops

Generated by 🔧 PR Triage Agent · copilot · mai11 · ~6 AIC · ⌖ ~2 AIC · ⊞ 15.9K · ◷

@SivaKesava1

Copy link
Copy Markdown
Collaborator

Verification at 35bd71f, merged with current main (fd2f0cf) in a local checkout:

  • Checks: 66/66 green (50 passed, 16 skipped). lint-go-govulncheck passes now that main is on Go 1.27.4; the branch's own bump was reverted, so go.mod isn't part of this diff.
  • Lock drift: recompiling all workflows at the merged head changes 0 lock files. The 3 changed locks (daily-caveman-optimizer, daily-doc-healer, smoke-claude-copilot) only add GH_AW_INFO_MODEL_FALLBACK for expression models, from the fallback-variable guard fix.
  • Equivalence: compiling the same workflow both ways gives identical locks, apart from "requested" in GH_AW_INFO_MODEL_CONFIG and the source hash:
    • model: router and model-routing: {goal: cost, mode: auto}
    • model: router/economy and mode: economy
    • model: router at the top level and under engine:
  • Tests: pkg/workflow and pkg/cli routing, router and audit tests pass; JS generate_aw_info and routing_analytics pass (104/104).
  • Review: all review threads are resolved (4 Copilot code review findings fixed in 9f793ff, 1a96198 and 4a7f886).

No workflow is moved to model: router in this PR; that's a separate follow-up after merge.

@SivaKesava1
SivaKesava1 requested a review from pelikhan November 11, 2026 18:46
@SivaKesava1
SivaKesava1 merged commit 43d6e84 into main Nov 11, 2026
67 checks passed
@SivaKesava1
SivaKesava1 deleted the copilot/choose-model-routing branch November 11, 2026 18:47
@rabeckett

Copy link
Copy Markdown
Collaborator

@copilot Thanks, this matches #76599. A few things before it's ready:

  1. Please add the ADR. The Design Decision Gate's draft was never pushed, because the bundle touched a file outside its allowed list. Add docs/adr/76617-choose-model-routing-with-router-model-values.md based on the gate's summary, and link it in the PR body. It should record the alternatives we considered:

    • keeping only engine.model-routing
    • a separate top-level key, which would leave two settings for one decision and couldn't be used by sub-agents or the model variables
    • bare values such as any or economy, which don't say that a router is choosing
    • router/auto, rejected because "auto" already means Copilot's Auto, gh-aw's auto alias, cursor/auto, kiro/auto and openrouter/auto
  2. Please reject router values in three more places, with an error that points to model:

    • a model variable in engine.env, such as COPILOT_MODEL
    • a --model argument in engine.args
    • safe-outputs.assign-to-agent.model

    Routing is set up only from the main agent's model, so the compiler has to see the value there. Today all three compile without a warning. In the first two, the router value goes to the engine CLI as if it were a model name, no routing is configured, and the run-time guard doesn't see it. In the third, it goes to the Copilot cloud agent.

  3. The description says no lock files change, but three Claude lock files gain GH_AW_INFO_MODEL_FALLBACK for the run-time guard. Please mention that.

@github-actions

Copy link
Copy Markdown
Contributor

🎉 This pull request is included in a new release.

Release: v1.2.3

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Choose model routing with model: router

5 participants