Skip to content

fix: recover retired and unavailable models with compatible choices - #10763

Merged
lpcox merged 2 commits into
mainfrom
lpcox-retired-unavailable-model-recovery
Oct 28, 2026
Merged

lpcox merged 2 commits into
mainfrom
lpcox-retired-unavailable-model-recovery

Conversation

@lpcox

@lpcox lpcox commented Oct 28, 2026

Copy link
Copy Markdown
Collaborator

Summary

  • Recover known-retired Copilot IDs before dispatch, preferring the advertised suggested replacement. Recover concrete IDs missing from an authoritative native Copilot catalog, and model-specific upstream 400/404 rejections on HTTP Responses, Chat Completions, and Messages paths.
  • Choose only same-backend, available, compatible, policy-permitted automatic alternatives. Preserve the client protocol/endpoint, tools, streaming, structured/multimodal features, explicit effort, known context/output limits, and captured pricing metadata. Unknown feature support fails closed; automatic recovery never changes credentials/providers or handles auth/policy/rate-limit failures.
  • Keep configured fallback ordering ahead of automatic upstream alternatives, bound automatic substitutions to three per request, and preserve model-policy, multiplier, credit, invocation, enclave-capability, and per-attempt budget enforcement. Emit structured warnings and retain original/replacement routing and token-usage evidence.
  • Respect global/per-engine and strict-alias opt-outs, scoped-auto selection, and routing classifiers. Package the new module in the proxy image and document the behavior.

WebSocket boundary

WebSocket tunnels are opaque, so this intentionally does not rewrite only the handshake or replay a live session: later frames may contain incompatible features or another model. Known-retired/catalog-unavailable handshake models fail explicitly; clients can use HTTP inference for compatible automatic recovery or choose an available model before upgrading.

Validation

  • Full API-proxy Jest suite: 133 suites, 2,879 tests passed (npm test --prefix containers/api-proxy -- --runInBand).
  • Final focused recovery/cross-provider/ordered-fallback/routing/WebSocket regressions after the final evidence changes: 5 suites, 176 tests passed.
  • npm run build, Markdown lint on docs/api-proxy-sidecar.md, and git diff --check passed.
  • Regression coverage includes preferred/absent/incompatible retirement suggestions, policy/multiplier/credit filtering, feature/effort/context/output compatibility, upstream not-supported/not-found, bounded exhaustion, unchanged valid requests, stable snapshots/endpoints, strict alias opt-out, enclave capability/request ceilings, and routing/WebSocket behavior.

No pricing catalog/source changes are included. Separate pricing PR #10757 is not duplicated or bundled. No live credentialed-provider or container integration run was performed.

Prefer compatible policy-permitted retirement replacements and bounded same-backend catalog alternatives. Preserve explicit fallback ordering, request features, guards, enclave attempt budgets, pricing snapshots, and routing evidence. Keep opaque WebSocket sessions fail-closed.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Copilot-Session: 58f067de-fd39-4522-aed4-c6bbc3f07e61
Copilot AI max review requested due to automatic review settings October 28, 2026 01:00
@github-actions

github-actions Bot commented Oct 28, 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-10763 artifact from the workflow run
  2. Unzip and open index.html in your browser

Built from commit 9db8b1d

@github-actions

github-actions Bot commented Oct 28, 2026 •

Copy link
Copy Markdown
Contributor

✅ Coverage Check Passed

Overall Coverage

Metric Base PR Delta
Lines 93.62% 93.63% ➡️ +0.01%
Statements 92.11% 92.12% 📈 +0.01%
Functions 91.22% 91.22% ➡️ +0.00%
Branches 86.19% 86.20% 📈 +0.01%
📁 Per-file Coverage Changes (2 files)
File Lines (Before → After) Statements (Before → After)
src/enclave/host-executor-server.ts 91.2% → 91.2% (+0.00%) 89.8% → 90.1% (+0.29%)
src/nvx/one-shot-adapter.ts 82.9% → 83.4% (+0.56%) 80.2% → 80.7% (+0.52%)

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

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

Automatic model recovery can reject valid requests, reduce output capacity, and bypass alias fallback opt-outs because of compatibility checks and inconsistent catalogue snapshots.

8 open issues
What changed in this PR

Extends AWF’s API proxy to recover retired and unavailable models using compatible alternatives from the same backend.

Changes:

  • Adds catalogue-based HTTP recovery before dispatch and after model-specific upstream rejections.
  • Adds compatibility filtering, bounded substitutions, recovery telemetry, and opt-out handling while keeping WebSocket sessions opaque.
  • Packages the recovery module and adds documentation and regression coverage.
File Description
docs/​api-proxy-sidecar.md Documents recovery behavior, safeguards, and WebSocket limits.
containers/​api-proxy/​websocket-proxy.js Rejects unavailable handshake models without rewriting sessions.
containers/​api-proxy/​upstream-retry.js Prioritizes model fallback after eligible upstream rejections.
containers/​api-proxy/​upstream-http.js Combines configured fallbacks with bounded automatic candidates.
containers/​api-proxy/​server.websocket.test.js Covers unavailable-model upgrade rejection.
containers/​api-proxy/​server.model-recovery.test.js Adds recovery, compatibility, policy, budget, and retry regressions.
containers/​api-proxy/​routing-observation.test.js Tests separate original-selection and recovery evidence.
containers/​api-proxy/​routing-observation.js Records recovery details in routing telemetry.
containers/​api-proxy/​proxy-request.js Identifies authoritative native Copilot catalogues.
containers/​api-proxy/​providers/​copilot-auth.js Clarifies alias fallback versus request recovery in comments.
containers/​api-proxy/​model-recovery.js Implements availability checks, candidate filtering, and recovery records.
containers/​api-proxy/​model-config.js Marks strict-alias requests to disable automatic recovery.
containers/​api-proxy/​guards/​retired-model-guard.js Updates comments to explain recovery-before-rejection behavior.
containers/​api-proxy/​Dockerfile Includes the recovery module in the proxy image.
containers/​api-proxy/​body-handler.js Invokes pre-dispatch recovery in the body-transform pipeline.

Review effort: Max

Comment thread containers/api-proxy/body-handler.js Outdated
Comment on lines +226 to +227
const recovered = recoverRequestModel(body, provider, req, requestId, logRequest);
if (recovered) body = recovered;
Comment thread containers/api-proxy/body-handler.js Outdated
Comment on lines +225 to +228
if (isWritableMethod) {
const recovered = recoverRequestModel(body, provider, req, requestId, logRequest);
if (recovered) body = recovered;
}
Comment thread containers/api-proxy/model-config.js Outdated
Comment on lines +151 to +154
const requested = parseBodyAsObject(body)?.model;
const alias = typeof requested === 'string' && Object.entries(MODEL_ALIASES?.models || {})
.find(([key]) => key.toLowerCase() === requested.split('?')[0].toLowerCase())?.[1];
if (alias?.fallback === false && req) req.awfModelRecoveryDisabled = true;
Comment on lines +39 to +44
const records = recoveryRecords(provider, req);
if (provider === 'copilot' && req?.awfModelCatalogAuthoritative && records.length > 0 &&
nativeModel(model, provider).toLowerCase() !== 'auto' &&
!records.some(record => record.id.toLowerCase() === nativeModel(model, provider).toLowerCase())) {
return { reason: 'model_unavailable' };
}
Comment thread containers/api-proxy/model-recovery.js Outdated
Comment on lines +73 to +76
const outputLimit = record.capabilities?.limits?.max_output_tokens;
const requestedOutput = parsed.max_tokens ?? parsed.max_completion_tokens ?? parsed.max_output_tokens;
if (requestedOutput !== undefined &&
(!Number.isFinite(outputLimit) || requestedOutput > outputLimit)) return false;
Comment thread containers/api-proxy/model-recovery.js Outdated
Comment on lines +126 to +128
for (const child of Object.values(value)) {
if (child && typeof child === 'object') pendingContent.push(child);
}
Comment on lines +240 to +241
const automaticRecovery = isAutomaticRecoveryEnabled(provider, req) &&
recoveryRecords(provider, req).length > 0;
Comment on lines +277 to +280
? getAutomaticRecoveryCandidates({
model: attempted[0].model, provider,
body: origin.sourceBody, url: req.url, req, isPermitted,
}).map(model => `${provider}/${model}`)
@github-actions

github-actions Bot commented Oct 28, 2026 •

Copy link
Copy Markdown
Contributor

🔌 Smoke Services — All services reachable! ✅

🔌 Service connectivity validated by Smoke Services

@github-actions

github-actions Bot commented Oct 28, 2026 •

Copy link
Copy Markdown
Contributor

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

🔑 BYOK report filed by Smoke Copilot BYOK

@github-actions

Copy link
Copy Markdown
Contributor

🔑 Smoke Copilot BYOK AOAI (api-key) is testing Azure OpenAI BYOK (api-key) mode on this pull request...

@github-actions

github-actions Bot commented Oct 28, 2026 •

Copy link
Copy Markdown
Contributor

✨ The prophecy is fulfilled... Smoke Codex has completed its mystical journey. The stars align. 🌟

🔮 The oracle has spoken through Smoke Codex

@github-actions

Copy link
Copy Markdown
Contributor

💎 Smoke Gemini is crystallizing results on this pull request...

@github-actions

github-actions Bot commented Oct 28, 2026 •

Copy link
Copy Markdown
Contributor

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

📰 BREAKING: Report filed by Smoke Copilot

@github-actions

github-actions Bot commented Oct 28, 2026 •

Copy link
Copy Markdown
Contributor

✅ Smoke Copilot BYOK AOAI (Entra) completed. Copilot AOAI BYOK (Entra) mode operational. 🔓

🪪 BYOK (AOAI Entra) report filed by Smoke Copilot BYOK AOAI (Entra)

@github-actions

github-actions Bot commented Oct 28, 2026 •

Copy link
Copy Markdown
Contributor

Smoke Cloud Hypervisor completed. Cloud Hypervisor + Copilot passed.

Cloud Hypervisor + Copilot smoke test by Smoke Cloud Hypervisor

@github-actions

github-actions Bot commented Oct 28, 2026 •

Copy link
Copy Markdown
Contributor

✅ Smoke Claude passed

Generated by Smoke Claude for #10763

@github-actions

github-actions Bot commented Oct 28, 2026 •

Copy link
Copy Markdown
Contributor

📡 Smoke OTel Tracing reports failed. OTel tracing regression detected. ⚠️

📡 OTel tracing validated by Smoke OTel Tracing

@github-actions

github-actions Bot commented Oct 28, 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 from Security Guard · haiku45 · ~9 AIC · ⊞ 6.0K · ◷

Generated by Security Guard for #10763

@github-actions

github-actions Bot commented Oct 28, 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 Oct 28, 2026 •

Copy link
Copy Markdown
Contributor

✅ Build Test Suite completed successfully!

Generated by Build Test Suite for #10763

@lpcox
lpcox deployed to aoai-model October 28, 2026 01:27 — with GitHub Actions Active
@github-actions

github-actions Bot commented Oct 28, 2026 •

Copy link
Copy Markdown
Contributor

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

Tested by Smoke Chroot

@lpcox
lpcox enabled auto-merge (squash) October 28, 2026 01:29
@github-actions

Copy link
Copy Markdown
Contributor

Services smoke test: FAIL

  • ❌ Redis PING: connection refused
  • ❌ pg_isready: no response
  • ❌ psql SELECT 1: connection refused

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

@github-actions

Copy link
Copy Markdown
Contributor

Smoke Test: Copilot BYOK (Direct) Mode

✅ GitHub MCP connectivity (merged PRs retrieved)
✅ github.com reachability (HTTP 200)
✅ File write/read test (smoke test file confirmed)
✅ BYOK inference test (direct mode via api-proxy → api.githubcopilot.com)

Status: PASS — Direct BYOK mode (COPILOT_PROVIDER_API_KEY) working correctly.

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

@github-actions github-actions Bot added the smoke-copilot-network-isolation Copilot network-isolation egress smoke test label Oct 28, 2026
@github-actions

This comment has been minimized.

@github-actions

This comment has been minimized.

@github-actions

github-actions Bot commented Oct 28, 2026 •

Copy link
Copy Markdown
Contributor

Smoke Cloud Hypervisor completed. Cloud Hypervisor + Copilot passed.

Cloud Hypervisor + Copilot smoke test by Smoke Cloud Hypervisor

@github-actions

Copy link
Copy Markdown
Contributor

🪪 Smoke Copilot BYOK AOAI (Entra) is testing Azure OpenAI BYOK (Entra / GitHub OIDC) mode on this pull request...

@github-actions

Copy link
Copy Markdown
Contributor

🔌 Smoke Services is testing service connectivity for this pull request...

@github-actions

Copy link
Copy Markdown
Contributor

📡 Smoke OTel Tracing is starting OTel tracing validation...

@github-actions

Copy link
Copy Markdown
Contributor

🔑 Smoke Copilot BYOK is testing direct BYOK mode on this pull request...

@github-actions

github-actions Bot commented Oct 28, 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 from Security Guard · haiku45 · ~9 AIC · ⊞ 6.0K · ◷

Generated by Security Guard for #10763

@github-actions

github-actions Bot commented Oct 28, 2026 •

Copy link
Copy Markdown
Contributor

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

Tested by Smoke Chroot

@github-actions

github-actions Bot commented Oct 28, 2026 •

Copy link
Copy Markdown
Contributor

✅ Build Test Suite completed successfully!

Generated by Build Test Suite for #10763

@github-actions

Copy link
Copy Markdown
Contributor

💎 Smoke Gemini is crystallizing results on this pull request...

@github-actions

github-actions Bot commented Oct 28, 2026 •

Copy link
Copy Markdown
Contributor

✨ The prophecy is fulfilled... Smoke Codex has completed its mystical journey. The stars align. 🌟

🔮 The oracle has spoken through Smoke Codex

@github-actions

github-actions Bot commented Oct 28, 2026 •

Copy link
Copy Markdown
Contributor

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

📰 BREAKING: Report filed by Smoke Copilot

@github-actions

github-actions Bot commented Oct 28, 2026 •

Copy link
Copy Markdown
Contributor

✅ Smoke Claude passed

Generated by Smoke Claude for #10763

@lpcox
lpcox enabled auto-merge (squash) October 28, 2026 02:13
@github-actions

Copy link
Copy Markdown
Contributor

Smoke test:

  • fix: warn instead of rejecting models without pricing ✅ merged PR read
  • chore: upgrade gh-aw workflows to v1.0.1 ✅ PR detail read
  • Playwright github.com title ❌ browser sandbox failure
  • Temp file write/read ✅
  • AWF build ✅
  • Discussion comment ✅

Overall: FAIL

🔮 The oracle has spoken through Smoke Codex
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

EGRESS_RESULT allow=pass deny=pass

  • ✅ Allowed domain (api.github.com): 200
  • ✅ Blocked domain (example.com): blocked
  • Overall: PASS — @lpcox

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

@github-actions

Copy link
Copy Markdown
Contributor

fix: warn instead of rejecting models without pricing ✅
chore: upgrade gh-aw workflows to v1.0.1 ✅
MCP connectivity: ✅
GitHub.com connectivity: ✅
File write/read: ✅
BYOK inference: ✅
Running in direct BYOK mode (COPILOT_PROVIDER_API_KEY + COPILOT_PROVIDER_BASE_URL) via api-proxy → Azure OpenAI (Foundry, o4-mini-aw)
Overall: PASS
@lpcox

🔑 BYOK (AOAI api-key) report filed by Smoke Copilot BYOK AOAI (api-key)
Add label ready-for-aw to run again

@github-actions

Copy link
Copy Markdown
Contributor

Smoke Test: Claude Engine Validation

  • API status: ✅ PASS
  • gh check: ✅ PASS
  • File status: ✅ PASS

Overall result: PASS

Generated by Smoke Claude for #10763 · claude · haiku45 · ~34 AIC · ⊞ 6.1K · ◷
Add label ready-for-aw to run again

@github-actions

Copy link
Copy Markdown
Contributor

Smoke Copilot (@lpcox)

  • ✅ GitHub MCP: "fix: prebuild local images before smoke services execution"
  • ✅ GitHub.com connectivity (200)
  • ✅ File write/read

Overall: PASS

📰 BREAKING: Report filed by Smoke Copilot
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 ✅ PASS
.NET json-parse ✅ N/A ✅ PASS
Go color ✅ pass ✅ PASS
Go env ✅ pass ✅ PASS
Go uuid ✅ pass ✅ PASS
Java gson ❌ not run ❌ FAIL
Java caffeine ❌ not run ❌ FAIL
Node.js clsx ✅ all passed ✅ PASS
Node.js execa ✅ all passed ✅ PASS
Node.js p-limit ✅ all passed ✅ PASS
Rust fd ✅ 1/1 passed ✅ PASS
Rust zoxide ✅ 1/1 passed ✅ PASS

Overall: 7/8 ecosystems passed — FAIL

Java failures:

  • mvn compile first failed with Could not create local repository at /home/runner/.m2/repository (not writable).
  • Retrying with -Dmaven.repo.local pointed at a temp directory failed with PluginResolutionException: ... (internal_error) java.security.InvalidAlgorithmParameterException: the trustAnchors parameter must be non-empty. The JVM truststore is empty or unusable, so Maven can't reach Maven Central over HTTPS.

Notes:

  • .NET needed XDG_RUNTIME_DIR set to a writable directory, because /run/user/1001 is missing.
  • The build-test label was not added because of the Java failures.

Generated by Build Test Suite for #10763 · copilot · auto · ~26 AIC · ⊞ 5.7K · ◷
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.15 Python 3.12.15 ✅ YES
Node.js v24.21.0 v22.23.2 ❌ NO
Go go1.22.12 go1.22.12 ✅ YES

Result: Not all tests passed (Node.js mismatch), so the smoke-chroot label was not added.

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

@lpcox
lpcox merged commit d344c2c into main Oct 28, 2026
130 of 140 checks passed
@lpcox
lpcox deleted the lpcox-retired-unavailable-model-recovery branch October 28, 2026 02:52

This branch had an error being deployed

1 failed deployment
aoai-model — 7c994e80 Deployed Oct 28, 2026 by lpcox via conclusion #2195
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.

3 participants