Skip to content

fix: restrict automatic model selection to models that can serve an agent - #11740

Merged
lpcox merged 6 commits into
mainfrom
fix/auto-skip-non-agent-models
Nov 17, 2026
Merged

lpcox merged 6 commits into
mainfrom
fix/auto-skip-non-agent-models

Conversation

@rabeckett

@rabeckett rabeckett commented Nov 17, 2026 •

Copy link
Copy Markdown
Collaborator

Fixes #11741

When AWF picks a model the caller didn't name (an alias wildcard, family-version replacement, or middle-power fallback), it currently chooses from every model the provider lists. That includes models the provider itself says can't run an agent. In github/gh-aw#76961, copilot/gpt-6* matched gpt-6-luna-decisions, an evaluation model that only serves /v1/decisions, and every agent turn failed before producing output. The earlier github/gh-aw#72353 was the same problem with gpt-5.6-luna-utility, which isn't enabled in the Copilot picker. Excluding models by name would keep missing the next variant, so this PR makes the decision from the provider's own metadata instead.

AWF already applied this kind of check in a few places (provider-scoped auto, Copilot auto on Responses, automatic recovery), each with its own inline copy, but alias resolution and fallback never used it. The new automatic-selection.js defines it once. A model can't be selected automatically when the provider's model list for the run marks it model_picker_enabled: false, or lists supported_endpoints that include none of Chat Completions, Responses, or Messages. A model without that metadata stays selectable, so incomplete metadata never empties a catalogue. Explicit choices are untouched: a model ID requested directly, or an alias entry written without * (such as gh-aw's evals: ["copilot/gpt-6-luna-decisions"]), still resolves as written.

The resolver applies the rule to wildcard matches, family-version replacement and both middle-power fallback paths, and logs which matches it skipped. The three existing call sites now use the shared predicate. Because filterResolvableAliases goes through the same resolver, an alias whose only matches are excluded is no longer advertised in /reflect or models.json. /reflect also publishes the decision per model as routing_models[].automatic_selection_eligible, with automatic_selection_reason (model_picker_disabled or no_agent_endpoint) when it's false. The rule is specified in docs/awf-config-spec.md §12.8 and summarized in docs/api-proxy-sidecar.md.

Using the Copilot catalogue from the failed run's /reflect snapshot and gh-aw's built-in alias table:

Alias Before After
large gpt-6-luna-decisions gpt-5.3-codex
gpt-5 gpt-5.6-luna-utility gpt-5.3-codex
agent, copilot gpt-41-copilot (picker-disabled) gpt-5.3-codex
gpt-6 gpt-6-luna-decisions not advertised; a direct request degrades through middle-power fallback
evals, or gpt-6-luna-decisions by ID gpt-6-luna-decisions unchanged

This change alone isn't enough for github/gh-aw#76961. For the Copilot engine, gh-aw resolves auto in its harness before AWF sees the request, so gh-aw's resolver needs to read automatic_selection_eligible and pick up an AWF release containing this change. That follow-up is github/gh-aw#78800.

Testing

  • New resolver tests in model-resolver-resolution.test.js use the real catalogue from the issue. They cover each exclusion reason on its own, explicit IDs and exact entries being kept, missing metadata staying selectable, and fallback candidates. management.test.js covers the new /reflect fields. The behaviour tests fail without the change.
  • The full api-proxy suite was run on Linux (arm64, Node 24): 161 of 162 suites pass. The one failure, the npm pack smoke in catalogue-proxy.test.js, timed out in my local environment and fails the same way on main.
  • npm run test:reflect-smoke passes (28/28), and markdownlint passes on both changed docs.
  • automatic-selection.js is added to the api-proxy Dockerfile's explicit COPY list, and the Docker-staged loading test passes.

Alias wildcards, family-version replacement, and middle-power fallback chose
from every discovered model, so a pattern such as copilot/gpt-6* could pick a
Decisions-only evaluation model or a utility model that is not enabled in the
Copilot picker, and every agent turn then failed (github/gh-aw#76961,
github/gh-aw#72353).

automatic-selection.js now defines, in one place, when AWF may choose a model
the caller did not name: the provider's model list must not mark it as
picker-disabled or advertise only non-agent endpoints. Models without that
metadata stay selectable, and explicit IDs and exact alias entries are kept.
The resolver applies the rule to wildcard matches and fallbacks, scoped auto,
Copilot Responses auto, and recovery share it, and /reflect publishes it per
model as automatic_selection_eligible so harness-side resolvers can match.

Co-authored-by: Copilot <[email protected]>
Copilot AI adaptive review requested due to automatic review settings November 17, 2026 17:55
@rabeckett rabeckett added the model-routing Model routing selection, compatibility, and diagnostics label Nov 17, 2026
@github-actions

Copy link
Copy Markdown
Contributor

🚀 Security Guard has started processing this pull request

@github-actions

github-actions Bot commented Nov 17, 2026 •

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-11740 artifact from the workflow run
  2. Unzip and open index.html in your browser

Built from commit c252b2f

@rabeckett rabeckett changed the title Restrict automatic model selection to models that can serve an agent fix: restrict automatic model selection to models that can serve an agent Nov 17, 2026

Copilot AI 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.

🟡 Changes recommended

An explicitly empty supportedEndpoints array is treated as missing metadata, allowing models that advertise no supported endpoints to be selected and reported as eligible.

1 open issue
What changed in this PR

This PR centralizes provider-metadata checks so AWF avoids automatically selecting models that cannot serve an agent, while preserving explicit model choices.

Changes:

  • Applies shared eligibility checks to wildcard aliases, fallback selection, scoped auto, and recovery.
  • Exposes automatic-selection eligibility and exclusion reasons through /reflect.
  • Adds regression coverage, documentation, and Docker packaging for the shared helper.
File Description
docs/​awf-config-spec.md Defines automatic-selection rules and explicit-choice exceptions.
docs/​api-proxy-sidecar.md Documents selection filtering and reflection fields.
containers/​api-proxy/​scoped-auto-model.js Uses the shared predicate for scoped auto.
containers/​api-proxy/​model-resolver.js Filters wildcard and fallback candidates.
containers/​api-proxy/​model-resolver-resolution.test.js Tests exclusions, explicit choices, and fallback behavior.
containers/​api-proxy/​model-recovery.js Uses the shared predicate for recovery candidates.
containers/​api-proxy/​model-body-rewriter.js Applies shared eligibility checks to Copilot Responses auto.
containers/​api-proxy/​management.test.js Tests reflected eligibility and exclusion reasons.
containers/​api-proxy/​management.js Publishes per-model automatic-selection metadata.
containers/​api-proxy/​Dockerfile Includes the new helper in the container image.
containers/​api-proxy/​automatic-selection.js Implements shared provider-metadata eligibility checks.

Review effort: Balanced (adaptive)

An explicit empty list is provider evidence, not missing metadata, and the
routing catalogue already treats it that way. Only an absent list keeps a
model selectable.

Co-authored-by: Copilot <[email protected]>
@github-actions

Copy link
Copy Markdown
Contributor

✅ Copilot review passed with no inline comments.

@rabeckett Add the ready-for-aw label to this PR to trigger agentic CI smoke tests.

@github-actions

github-actions Bot commented Nov 17, 2026 •

Copy link
Copy Markdown
Contributor

✅ Coverage Check Passed

Overall Coverage

Metric Base PR Delta
Lines 94.16% 94.16% ➡️ +0.00%
Statements 92.76% 92.77% ➡️ +0.01%
Functions 93.30% 93.34% 📈 +0.04%
Branches 87.14% 87.15% 📈 +0.01%
📁 Per-file Coverage Changes (2 files)
File Lines (Before → After) Statements (Before → After)
src/commands/main-action-cleanup.ts 97.9% → 96.9% (-1.03%) 98.0% → 97.0% (-0.99%)
src/routing/bootstrap.ts 90.0% → 91.0% (+1.00%) 85.2% → 86.5% (+1.34%)

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

@github-actions

github-actions Bot commented Nov 17, 2026 •

Copy link
Copy Markdown
Contributor

🛡️ Smoke Copilot Network Isolation confirmed the egress allowlist is enforced. ✅

🛡️ Egress verdict from Smoke Copilot Network Isolation

@github-actions

github-actions Bot commented Nov 17, 2026 •

Copy link
Copy Markdown
Contributor

✅ Security Guard completed successfully!

Security Guard

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 by Security Guard for #11740 · copilot · auto (Claude Sonnet 5.5) · ~14 AIC · ⊞ 9K · ◷

@github-actions

github-actions Bot commented Nov 17, 2026 •

Copy link
Copy Markdown
Contributor

✅ Smoke Copilot BYOK completed. Copilot BYOK mode operational. 🔓

🔑 BYOK report filed by Smoke Copilot BYOK

@github-actions

github-actions Bot commented Nov 17, 2026 •

Copy link
Copy Markdown
Contributor

📰 VERDICT: Smoke Copilot has concluded. All systems operational. This is a developing story. 🎤

Smoke Copilot

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.

📰 BREAKING: Report filed by Smoke Copilot

@github-actions

github-actions Bot commented Nov 17, 2026 •

Copy link
Copy Markdown
Contributor

📡 Smoke OTel Tracing completed. All tracing scenarios validated. ✅

📡 OTel tracing validated by Smoke OTel Tracing

@github-actions

github-actions Bot commented Nov 17, 2026 •

Copy link
Copy Markdown
Contributor

🔌 Smoke Services — All services reachable! ✅

🔌 Service connectivity validated by Smoke Services

@github-actions

Copy link
Copy Markdown
Contributor

🔮 The ancient spirits stir... Smoke Codex awakens to divine this pull request...

@github-actions

github-actions Bot commented Nov 17, 2026 •

Copy link
Copy Markdown
Contributor

✅ Build Test Suite completed successfully!

Warning

Firewall blocked 1 domain

The following domain was blocked by the firewall during workflow execution:

  • 169.254.169.254

To allow these domains, add them to the network.allowed list in your workflow frontmatter:

network:
  allowed:
    - defaults
    - "169.254.169.254"

See Network Configuration for more information.

Generated by Build Test Suite for #11740 · copilot · routed: haiku55 xhigh · ~4 AIC · ⊞ 6.1K · ◷

@github-actions

github-actions Bot commented Nov 17, 2026 •

Copy link
Copy Markdown
Contributor

✅ Smoke Claude passed

Generated by Smoke Claude for #11740 · claude · haiku45 · ~36 AIC · ⊞ 6.4K · ◷

@github-actions

github-actions Bot commented Nov 17, 2026 •

Copy link
Copy Markdown
Contributor

Chroot tests passed! Smoke Chroot - All security and functionality tests succeeded.

Smoke Chroot

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.

Tested by Smoke Chroot

@github-actions

github-actions Bot commented Nov 17, 2026 •

Copy link
Copy Markdown
Contributor

Smoke Cloud Hypervisor completed. Cloud Hypervisor + Copilot passed.

Cloud Hypervisor + Copilot smoke test by Smoke Cloud Hypervisor

@lpcox

lpcox commented Nov 17, 2026

Copy link
Copy Markdown
Collaborator

@github-actions

Copy link
Copy Markdown
Contributor

Smoke Test: Copilot Network Isolation ✅

Result: PASS

Both egress checks completed successfully:

Check Expected Result Status
Allow allowlisted domain (api.github.com) HTTP 200 HTTP 200 ✅ PASS
Block non-allowlisted domain (example.com) Connection failed Connection blocked (SNI guard) ✅ PASS

EGRESS_RESULT allow=pass deny=pass

The firewall correctly:

  • ✅ Permits HTTPS traffic to allowlisted domains
  • ✅ Blocks HTTPS traffic to non-allowlisted domains using SNI verification

🛡️ Egress verdict from Smoke Copilot Network Isolation
Add label ready-for-aw to run again

@github-actions github-actions Bot added smoke-copilot-network-isolation Copilot network-isolation egress smoke test smoke-services labels Nov 17, 2026
@github-actions

Copy link
Copy Markdown
Contributor

Smoke services: ✅ Redis PONG · ✅ pg_isready · ✅ SELECT 1. Overall: PASS

🔌 Service connectivity validated by Smoke Services
Add label ready-for-aw to run again

@github-actions

Copy link
Copy Markdown
Contributor

Chroot Version Comparison

Runtime Host Version Chroot Version Match?
Python Python 3.12.16 Python 3.12.16 YES
Node.js v24.22.2 v2.98.0 NO
Go go1.22.12 go1.22.12 YES

Result: ALL_TESTS_PASSED=false. The Node.js version inside the chroot does not match the host. v2.98.0 is not a Node.js release version for this host's Node 24 line, so node in the chroot probably resolves to a different binary. The smoke-chroot label was not added.

Tested by Smoke Chroot
Add label ready-for-aw to run again

@github-actions

Copy link
Copy Markdown
Contributor

Smoke OTel Tracing results

  • ✅ Scenario 1, module load: containers/api-proxy/otel.js loads and exports startRequestSpan, setTokenAttributes, setBudgetAttributes, endSpan, endSpanError, routerCallTracing, shutdown, isEnabled, plus test hooks.
  • ✅ Scenario 2, test suite: otel*.test.js ran 3 suites, 75/75 tests passed.
  • ✅ Scenario 3, env forwarding: GITHUB_AW_OTEL_TRACE_ID and GITHUB_AW_OTEL_PARENT_SPAN_ID are forwarded in env-passthrough.ts. GH_AW_OTLP_ENDPOINTS, OTEL_EXPORTER_OTLP_ENDPOINT, and the trace-context IDs are forwarded in api-proxy-env-config.ts.
  • ✅ Scenario 4, token tracker: onUsage hook is present in token-tracker-http.js. upstream-token.js calls setTokenAttributes and setBudgetAttributes.
  • ⏳ Scenario 5, diagnostics: Pending. The post-step has not run yet because the agent is still executing. The api-proxy sidecar is enabled, but its log directory did not exist at check time. The only exported span so far is gh-aw.agent.setup in /tmp/gh-aw/otel.jsonl, which is not an api-proxy span. Re-check once the post-step completes.

No unexpected failures, so no issue was filed.

📡 OTel tracing validated by Smoke OTel Tracing
Add label ready-for-aw to run again

@github-actions

Copy link
Copy Markdown
Contributor

Smoke Test: Claude Engine

Check Result
API status ✅ PASS
GitHub check ✅ PASS
File status ✅ PASS

Overall result: PASS

Generated by Smoke Claude for #11740 · claude · haiku45 · ~36 AIC · ⊞ 6.4K · ◷
Add label ready-for-aw to run again

@github-actions

Copy link
Copy Markdown
Contributor

🔥 Smoke Test: Copilot (@rabeckett)

Assignees: none

Overall: PASS

📰 BREAKING: Report filed by Smoke Copilot
Add label ready-for-aw to run again

@github-actions

Copy link
Copy Markdown
Contributor

Cloud Hypervisor + Copilot smoke test

  1. Merged PR lookup: PASS
  2. github.com connectivity: PASS (HTTP 200)
  3. File write/read: PASS
  4. example.com blocked: PASS (HTTP 000)

Overall: PASS

Cloud Hypervisor + Copilot smoke test by Smoke Cloud Hypervisor
Add label ready-for-aw to run again

@github-actions

Copy link
Copy Markdown
Contributor

Smoke Test

  • Evaluate native macOS sandboxing with Seatbelt and pf
  • Refactor NVX confinement into focused modules
  • GitHub reads: ✅
  • Playwright title check: ❌
  • File write/read: ✅
  • Build (npm ci && npm run build): ✅
  • Overall status: FAIL

🔮 The oracle has spoken through Smoke Codex
Add label ready-for-aw to run again

@github-actions

Copy link
Copy Markdown
Contributor

Smoke Test: Copilot BYOK (Direct Mode) ✅ PASS

Test Result
GitHub MCP ✅ Connected (PRs: #11706, #11704)
github.com ✅ HTTP 200
File I/O ✅ Read verified
BYOK Inference ✅ Working (api-proxy → api.githubcopilot.com)

Mode: Direct BYOK (COPILOT_PROVIDER_API_KEY) via api-proxy sidecar
Author: @rabeckett | Status: Ready

🔑 BYOK report filed by Smoke Copilot BYOK
Add label ready-for-aw to run again

@github-actions

Copy link
Copy Markdown
Contributor

🏗️ Build Test Suite Results

Ecosystem Project Build/Install Tests Status
Bun elysia ✅ 1/1 passed ✅ PASS
Bun hono ✅ 1/1 passed ✅ PASS
C++ fmt ✅ N/A ✅ PASS
C++ json ✅ N/A ✅ PASS
Deno oak N/A 1/1 passed ✅ PASS
Deno std N/A 1/1 passed ✅ PASS
.NET hello-world ✅ N/A (run OK) ✅ PASS
.NET json-parse ✅ N/A (run OK) ✅ PASS
Go color ✅ 1/1 passed ✅ PASS
Go env ✅ 1/1 passed ✅ PASS
Go uuid ✅ 1/1 passed ✅ PASS
Java gson ✅ 1/1 passed ✅ PASS
Java caffeine ✅ 1/1 passed ✅ PASS
Node.js clsx ✅ script passed (no count) ✅ PASS
Node.js execa ✅ script passed (no count) ✅ PASS
Node.js p-limit ✅ script passed (no count) ✅ PASS
Rust fd ✅ 1/1 passed ✅ PASS
Rust zoxide ✅ 1/1 passed ✅ PASS

Overall: 8/8 ecosystems passed — PASS

Environment workarounds (runner setup, not project failures):

  • .NET: First-run CLI failed on missing /run/user/1001. Re-ran with XDG_RUNTIME_DIR set to a temp dir and DOTNET_SKIP_FIRST_TIME_EXPERIENCE=1.
  • Java: ~/.m2 is root-owned, so Maven used -Dmaven.repo.local under the temp dir. The Temurin cacerts symlinks are dangling (/etc/ssl/certs/adoptium is missing), so Maven used a temp truststore built from the system CA bundle with TLS verification on. The ~/.m2/settings.xml proxy config was written as specified.
  • Node.js: The npm test scripts print only "All tests passed!", so no per-test counts are available.
  • Bun/Deno: Not preinstalled; installed via their official install scripts.

Warning

Firewall blocked 1 domain

The following domain was blocked by the firewall during workflow execution:

  • 169.254.169.254

To allow these domains, add them to the network.allowed list in your workflow frontmatter:

network:
  allowed:
    - defaults
    - "169.254.169.254"

See Network Configuration for more information.

Generated by Build Test Suite for #11740 · copilot · routed: haiku55 xhigh · ~4 AIC · ⊞ 6.1K · ◷
Add label ready-for-aw to run again

Copilot AI commented Nov 17, 2026

Copy link
Copy Markdown
Contributor

@copilot fix this failing ci check https://github.com/github/gh-aw-firewall/actions/runs/44148014872/job/134268335958?pr=11740

I traced the failure to the dependency audit, not this PR’s code: both the main-package and docs-site audit jobs fail the high/critical vulnerability gate. The same two jobs also fail on main (e050769), and this PR does not change either package lockfile. I’m not changing unrelated dependencies or weakening the audit here; this needs a separate dependency-remediation change. Local audit reproduction was blocked because the configured npm registry is unreachable from this environment.

Copilot AI requested a review from lpcox November 17, 2026 18:56
lpcox and others added 4 commits November 17, 2026 11:08
Accept three current docs advisories that cannot affect the static deployment.

Keep all other high or critical findings fail-closed. Expire the exceptions on December 1.

Co-authored-by: Copilot App <[email protected]>
Apply the expiring picomatch acceptance to the root package audit.

Keep all unrelated high and critical findings fail-closed.

Co-authored-by: Copilot App <[email protected]>
Ignore low and moderate causes when evaluating a high or critical transitive finding.

Continue requiring every high or critical path to match an unexpired acceptance.

Co-authored-by: Copilot App <[email protected]>
Update the workflow contract test for the expiring npm audit allowlists.

Keep assertions for fail-closed advisory-service handling and pinned execution.

Co-authored-by: Copilot App <[email protected]>
@lpcox
lpcox merged commit 221d9db into main Nov 17, 2026
44 of 46 checks passed
@lpcox
lpcox deleted the fix/auto-skip-non-agent-models branch November 17, 2026 19:51
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.

Alias wildcards and fallback can choose models that can't serve an agent

4 participants