Skip to content

feat(api-proxy): constrain routing candidate efforts before ranking - #10425

Closed
SivaKesava1 with Copilot wants to merge 2 commits into
mainfrom
copilot/model-routing-constrain-candidate-efforts
Closed

SivaKesava1 with Copilot wants to merge 2 commits into
mainfrom
copilot/model-routing-constrain-candidate-efforts

Conversation

Copilot AI commented Oct 21, 2026 •

Copy link
Copy Markdown
Contributor

AWF routing can pick a model/effort pair the provider supports but the consuming engine refuses. For example, Codex rejected gpt-5.6-luna:max at startup even though a runnable gpt-5.6-sol:medium was ranked second. This PR adds an optional, caller-supplied effort allowlist and applies it to the candidate pool before the classifier and route requests are made.

apiProxy:
  routing:
    allowedEfforts: [minimal, low, medium, high, xhigh]   # e.g. Codex
    objective: { goal: cost, mode: auto }
    task: { conversationFile: /tmp/gh-aw/routing-conversation.json }

Config surface

  • allowedEfforts is added to apiProxy.routing in docs/awf-config.schema.json, regenerated into src/awf-config-schema.json, and typed in ModelRoutingConfig. The schema requires a non-empty list of unique values drawn from the seven contract efforts.
  • routing-config.js performs the same validation at proxy startup, rejecting non-arrays, empty lists, unknown values and duplicates. Invalid values cause an error and are never silently dropped.
  • The field reaches the proxy through the existing AWF_ROUTING_CONFIG spread, so no CLI wiring changes are needed.

Candidate filtering (routing-candidates.js)

  • Filtering runs after the existing model-policy, catalogue and protocol checks. A pair is removed only when its explicit effort is outside the list.
  • Pairs with no effort (e.g. claude-haiku-4.5, efforts: []) stay eligible and are not treated as none.
  • If filtering removes every choice, routing fails with the existing non-retryable no_route code, and the classifier and router are never called. The detail names the constraint:
    The routing.allowedEfforts constraint (minimal) excludes every eligible model choice
  • There is no clamping and no restoring of excluded choices. Selection and per-request comparison work as before.
  • When the field is omitted, the candidate pool and choice IDs are identical to today's.

Audit and /reflect

  • allowed_efforts is added to classification, selection and failure records, but only when the constraint is configured.
  • It is also added to the routing-persistence.js allowlist, so it reaches model-routing.jsonl.
  • /reflect routing shows allowed_efforts in every status (pending, selected, failed) when configured. Audits can then tell an excluded arm from one the router merely ranked lower.
  • Docs are updated: docs/awf-config-spec.md (field table, semantics, audit-record contract) and docs/api-proxy-sidecar.md (/reflect).

Tests

  • The six regression tests named in the issue are in containers/api-proxy/routing-effort-constraint.test.js.
  • The schema half of config_schema_rejects_unknown_constrained_effort is in src/config-file-validation.test.ts.
  • The fixture replaying the reported ranking is explicitly labelled as a projection of the run summary into AWF's raw snake_case selection-record shape, not a downloaded artifact.

Out of scope

The gh-aw side is a separate github/gh-aw follow-up: emitting each engine's accepted efforts into this field, version-gating that emission, and adding a routed Codex smoke test.

Copilot AI changed the title [WIP] Add effort constraint to model routing feat(api-proxy): constrain routing candidate efforts before ranking Oct 21, 2026
Copilot AI requested a review from SivaKesava1 October 21, 2026 20:38
@github-actions

Copy link
Copy Markdown
Contributor

Documentation Preview

Documentation has been built for this PR.

Download preview artifact

To view locally:

  1. Download the docs-preview-pr-10425 artifact from the workflow run
  2. Unzip and open index.html in your browser

Built from commit e899985

@github-actions

Copy link
Copy Markdown
Contributor

✅ Coverage Check Passed

Overall Coverage

Metric Base PR Delta
Lines 93.41% 93.41% ➡️ +0.00%
Statements 91.85% 91.85% ➡️ +0.00%
Functions 91.00% 91.00% ➡️ +0.00%
Branches 85.92% 85.92% ➡️ +0.00%

Coverage comparison generated by scripts/ci/compare-coverage.ts

@rabeckett

Copy link
Copy Markdown
Collaborator

Is the list of supported efforts independent of the model or model family?

For instance, can codex not support max for 5.6 models but support it for gpt 6 models?

Do we need to combine allowed models and efforts together into a single allowed list (e.g., gpt-5.6-luna:[low,medium,high,xhigh] )?

@SivaKesava1

Copy link
Copy Markdown
Collaborator

Good question. I checked, and it changes the fix.

Effort support is per model, and AWF already handles that part. AWF builds candidates from each model's live supported_reasoning_efforts. Today Copilot lists:

  • none..max for gpt-5.6-* and gpt-6-luna/-sol;
  • low..max for gpt-6.1-sol and the Claude 5.x models;
  • low..xhigh for gpt-5.3-codex;
  • none at all for claude-haiku-4.5.

So a model that doesn't offer max is never ranked at max. A combined gpt-5.6-luna:[low,…] allowlist would duplicate the catalogue, and we'd have to keep it in sync as models change.

The engine list in gh-aw is about what the client accepts, and for Codex it looks stale. mapAWFRoutingEffort (added in gh-aw#66723 on 7 Oct) allows Codex only minimal..xhigh. But Codex 0.163.0, gh-aw's current pin, parses none, minimal, low, medium, high, xhigh and max (and any other non-empty value as a custom effort) and sends it unchanged: ReasoningEffort in codex-rs/protocol/src/openai_models.rs at rust-v0.163.0.

To check, I ran Codex on Copilot in our sandbox with gpt-5.6-luna and -c model_reasoning_effort="max". The run completed and all 6 /responses requests returned 200. AWF's records don't include the request effort, so this shows Codex accepts max and Copilot didn't reject the requests, not the exact value on the wire.

So the failure in #10424 is gh-aw refusing an effort the engine and the model both support. The simpler fix is in gh-aw: update the Codex set in mapAWFRoutingEffort to match the pinned Codex, and add a routed Codex smoke. I'd hold this PR unless we want allowedEfforts as an author-facing policy, for example to cap cost. That would be a separate feature, not this bug fix. @lpcox what do you think?

@SivaKesava1

Copy link
Copy Markdown
Collaborator

Closing: as discussed above, AWF already ranks only the efforts each model advertises, and the Codex failure in #10424 comes from gh-aw's stale per-engine effort list (Codex 0.163.0 accepts none..max). The fix moves to gh-aw. If we later want an author-facing effort cap as a cost policy, that's a separate feature. Thanks @rabeckett for the question.

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Model routing: constrain candidate efforts before ranking to avoid unsupported Codex selections

3 participants