Skip to content

Fix model-policy config propagation to api-proxy and prevent exact-model family rewrites#6299

Merged
lpcox merged 3 commits into
mainfrom
copilot/fix-api-proxy-models-issue
Jul 16, 2026
Merged

Fix model-policy config propagation to api-proxy and prevent exact-model family rewrites#6299
lpcox merged 3 commits into
mainfrom
copilot/fix-api-proxy-models-issue

Conversation

Copilot AI commented Jul 16, 2026

Copy link
Copy Markdown
Contributor

apiProxy.allowedModels and apiProxy.disallowedModels from --config were mapped but dropped before WrapperConfig, so AWF_ALLOWED_MODELS/AWF_DISALLOWED_MODELS never reached the api-proxy container. Separately, resolver family fallback could rewrite a specifically requested model even when the provider advertised that exact model.

  • Config pipeline: preserve model policy fields end-to-end

    • Added allowedModels / disallowedModels to the validation→assembly path:
      • validateLogAndLimits result
      • assembleAndValidateConfig(...) inputs to buildConfig(...)
      • buildConfig(...) output WrapperConfig
    • This makes config-file policy fields actually available to api-proxy env construction, aligning behavior with existing buildModelPolicyEnv(...) support.
  • Resolver behavior: exact advertised model wins

    • In containers/api-proxy/model-resolver.js, resolveModel(...) now checks for an exact provider-advertised match before GPT-5 family alias fallback.
    • Prevents silent substitution like gpt-5.6-solgpt-5.6-luna when gpt-5.6-sol is already available.
  • Regression coverage

    • Added/updated tests for:
      • config mapping for allowedModels / disallowedModels
      • pass-through into config assembly/build outputs
      • resolver exact-match precedence over family fallback
// New resolver precedence behavior
const r = resolveModel(
  'gpt-5.6-sol',
  { 'gpt-5': ['openai/gpt-5*'] },
  { openai: ['gpt-5.6-terra', 'gpt-5.6-luna', 'gpt-5.6-sol', 'gpt-5.5'] },
  'openai'
);
// now resolves to the exact requested model
expect(r.resolvedModel).toBe('gpt-5.6-sol');

Copilot AI changed the title [WIP] Fix apiProxy.allowedModels and disallowedModels issue in proxy container Fix model-policy config propagation to api-proxy and prevent exact-model family rewrites Jul 16, 2026
Copilot AI requested a review from lpcox July 16, 2026 14:31
Copilot finished work on behalf of lpcox July 16, 2026 14:31
@lpcox
lpcox marked this pull request as ready for review July 16, 2026 14:43
Copilot AI review requested due to automatic review settings July 16, 2026 14:44

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.

Pull request overview

Propagates API-proxy model policies through configuration assembly and adjusts model resolution precedence.

Changes:

  • Preserves allowed/disallowed model lists through WrapperConfig.
  • Prioritizes exact advertised models over GPT-5 family fallback.
  • Adds regression tests for mapping, validation, building, and resolution.
Show a summary per file
File Description
src/config-file-mapping.test.ts Tests policy-field mapping.
src/commands/validators/log-and-limits.ts Passes policy fields through validation.
src/commands/validators/log-and-limits.test.ts Tests validator propagation.
src/commands/validators/config-assembly.ts Forwards policies into config construction.
src/commands/validators/config-assembly.test-utils.ts Updates assembly fixtures.
src/commands/build-config.ts Adds policies to WrapperConfig.
src/commands/build-config.test.ts Tests config output.
containers/api-proxy/model-resolver.js Adds exact-match precedence.
containers/api-proxy/model-resolver.test.js Tests exact-match behavior.

Review details

Tip

Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

  • Files reviewed: 9/9 changed files
  • Comments generated: 2
  • Review effort level: Medium

Comment on lines +288 to +298
const direct = providerModels.find(m => m.toLowerCase() === key);
if (direct && _isModelPermittedByPolicy(direct, modelPolicyConfig)) {
log.push(`[model-resolver] direct match: "${requestedModel}" → "${direct}"`);
return {
resolvedModel: direct,
log,
fallback: fallbackConfig.enabled
? { activated: false, selection_method: 'middle_power_median', reason: 'direct_match' }
: undefined,
};
}
Comment on lines +54 to +55
allowedModels: logAndLimits.allowedModels,
disallowedModels: logAndLimits.disallowedModels,
@lpcox

lpcox commented Jul 16, 2026

Copy link
Copy Markdown
Collaborator

@copilot address review feedback

- model-resolver.js: when an advertised model is policy-blocked,
  return null instead of falling through to GPT-5 family alias
- Add regression test for exact-but-denied model behavior
- Add assembly handoff test for allowedModels/disallowedModels

Copilot AI commented Jul 16, 2026

Copy link
Copy Markdown
Contributor Author

@copilot address review feedback

Both review issues addressed in the latest commit:

model-resolver.js (lines 288-298): The direct-match block now checks policy first and returns null unconditionally if the advertised model is denied — matching the _resolveDirectMatch pattern exactly. A denied-but-advertised model can no longer fall through to the GPT-5 family alias. Regression test added: gpt-5.6-sol denylisted → null, not rewritten to gpt-5.6-luna.

config-assembly.ts (lines 54-55): Added a model policy config assembly handoff test in config-assembly-api-proxy.test.ts that passes non-empty allowedModels/disallowedModels into assembleAndValidateConfig and asserts the buildConfig mock receives both values. This test would fail if those two lines were removed.

@github-actions

Copy link
Copy Markdown
Contributor

✅ Copilot review passed with no inline comments.

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

@github-actions

github-actions Bot commented Jul 16, 2026

Copy link
Copy Markdown
Contributor

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

@github-actions

github-actions Bot commented Jul 16, 2026

Copy link
Copy Markdown
Contributor

Contribution Check completed successfully!

@github-actions

github-actions Bot commented Jul 16, 2026

Copy link
Copy Markdown
Contributor

Smoke Copilot BYOK AOAI (api-key) reports failed. AOAI BYOK (api-key) mode investigation needed...

@github-actions

github-actions Bot commented Jul 16, 2026

Copy link
Copy Markdown
Contributor

🔑 Smoke Copilot PAT PAT auth validated. All systems operational. ✅

@github-actions

github-actions Bot commented Jul 16, 2026

Copy link
Copy Markdown
Contributor

🔌 Smoke Services — All services reachable! ✅

@github-actions

github-actions Bot commented Jul 16, 2026

Copy link
Copy Markdown
Contributor

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

@github-actions

github-actions Bot commented Jul 16, 2026

Copy link
Copy Markdown
Contributor

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

@github-actions

github-actions Bot commented Jul 16, 2026

Copy link
Copy Markdown
Contributor

Smoke Gemini completed. All facets verified. 💎

@github-actions

github-actions Bot commented Jul 16, 2026

Copy link
Copy Markdown
Contributor

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

@github-actions

github-actions Bot commented Jul 16, 2026

Copy link
Copy Markdown
Contributor

Smoke Claude passed

@github-actions

github-actions Bot commented Jul 16, 2026

Copy link
Copy Markdown
Contributor

Build Test Suite completed successfully!

@github-actions

github-actions Bot commented Jul 16, 2026

Copy link
Copy Markdown
Contributor

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

@github-actions

github-actions Bot commented Jul 16, 2026

Copy link
Copy Markdown
Contributor

Security Guard failed. Please review the logs for details.

@github-actions

github-actions Bot commented Jul 16, 2026

Copy link
Copy Markdown
Contributor

Smoke Copilot BYOK AOAI (Entra) reports failed. AOAI BYOK (Entra) mode investigation needed...

@github-actions

github-actions Bot commented Jul 16, 2026

Copy link
Copy Markdown
Contributor

Smoke Copilot BYOK completed. Copilot BYOK mode operational. 🔓

@github-actions

Copy link
Copy Markdown
Contributor

✅ Coverage Check Passed

Overall Coverage

Metric Base PR Delta
Lines 98.92% 98.96% 📈 +0.04%
Statements 98.86% 98.90% 📈 +0.04%
Functions 99.35% 99.35% ➡️ +0.00%
Branches 95.06% 95.06% ➡️ +0.00%
📁 Per-file Coverage Changes (1 files)
File Lines (Before → After) Statements (Before → After)
src/log-directory-setup.ts 96.2% → 100.0% (+3.78%) 96.3% → 100.0% (+3.71%)

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

@github-actions

Copy link
Copy Markdown
Contributor

Thanks for the clear description and regression coverage. One contribution-guideline item is still missing: please reference any related issue, as required under Pull request requirements in CONTRIBUTING.md ("Clear description of what the PR does" and "Reference any related issues"). If there is no related issue, please state that explicitly in the PR description.

Warning

Firewall blocked 1 domain

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

  • awmgmcpg

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

network:
  allowed:
    - defaults
    - "awmgmcpg"

See Network Configuration for more information.

Generated by Contribution Check for #6299 · 3.45 AIC · ⊞ 19.2K ·
Add label ready-for-aw to run again

@github-actions

Copy link
Copy Markdown
Contributor

Smoke Test: Copilot PAT Auth

Test Result
GitHub MCP connectivity ✅ PAT auth confirmed (PR context resolved)
GitHub.com HTTP ⚠️ Pre-step data unavailable (template vars unexpanded)
File write/read ⚠️ Pre-step data unavailable (template vars unexpanded)

Overall: PARTIAL${{ steps.smoke-data.outputs.* }} expressions were not expanded before agent invocation.

PR author: @lpcox | Auth mode: PAT (COPILOT_GITHUB_TOKEN)

Warning

Firewall blocked 1 domain

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

  • awmgmcpg

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

network:
  allowed:
    - defaults
    - "awmgmcpg"

See Network Configuration for more information.

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

@github-actions

Copy link
Copy Markdown
Contributor

🔬 Smoke Test Results

Test Result
GitHub MCP ✅ Connected
GitHub.com HTTP ⚠️ Pre-step output unexpanded
File Write/Read ⚠️ Pre-step output unexpanded

Overall: PARTIAL — MCP connectivity confirmed; pre-step template vars were not substituted.

Author: @lpcox

Warning

Firewall blocked 1 domain

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

  • awmgmcpg

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

network:
  allowed:
    - defaults
    - "awmgmcpg"

See Network Configuration for more information.

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

@github-actions

Copy link
Copy Markdown
Contributor

Smoke Test: Claude Engine Validation

Check Result
API Status ✅ PASS
GH Check ✅ PASS
File Status ✅ PASS

Overall Result: PASS

Warning

Firewall blocked 1 domain

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

  • awmgmcpg

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

network:
  allowed:
    - defaults
    - "awmgmcpg"

See Network Configuration for more information.

Generated by Smoke Claude for #6299 · 55.4 AIC · ⊞ 3.3K ·
Add label ready-for-aw to run again

@github-actions

Copy link
Copy Markdown
Contributor

Smoke Test: Copilot BYOK (Direct) — PASS

  • ✅ GitHub MCP connectivity (PR list verified)
  • ✅ GitHub.com HTTP 200
  • ✅ File write/read: smoke-test-copilot-byok.txt exists
  • ✅ BYOK inference: prompt received and processed

Running in direct BYOK mode (COPILOT_PROVIDER_API_KEY) via api-proxy → api.githubcopilot.com

Overall: PASS | @lpcox

Warning

Firewall blocked 1 domain

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

  • awmgmcpg

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

network:
  allowed:
    - defaults
    - "awmgmcpg"

See Network Configuration for more information.

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

@github-actions

Copy link
Copy Markdown
Contributor

Smoke Test: API Proxy OpenTelemetry Tracing

Scenario Result Notes
S1: Module Loading ✅ Pass otel.js loads successfully; exports: startRequestSpan, setTokenAttributes, setBudgetAttributes, endSpan, endSpanError, shutdown, isEnabled (+ internal helpers)
S2: Test Suite ✅ Pass 59/59 tests pass across otel.test.js and otel-fanout.test.js (2 suites)
S3: Env Var Forwarding ✅ Pass src/services/agent-environment-credentials.ts auto-forwards OTEL_* vars; covered by tests in agent-environment-credentials.test.ts
S4: Token Tracker Integration ✅ Pass onUsage callback exists in token-tracker-http.js (line 343) as the OTEL hook point
S5: OTEL Diagnostics ✅ Pass File fallback exporter (/var/log/api-proxy/otel.jsonl) active when no endpoint configured; fan-out exporter routes through Squid when endpoints set

All 5 scenarios pass. The OTEL tracing integration is fully functional.

Warning

Firewall blocked 1 domain

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

  • awmgmcpg

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

network:
  allowed:
    - defaults
    - "awmgmcpg"

See Network Configuration for more information.

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

@github-actions

Copy link
Copy Markdown
Contributor

Smoke Test Results

Overall status: FAIL

Warning

Firewall blocked 1 domain

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

  • localhost

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

network:
  allowed:
    - defaults
    - "localhost"

See Network Configuration for more information.

💎 Faceted by Smoke Gemini
Add label ready-for-aw to run again

@github-actions

Copy link
Copy Markdown
Contributor

Smoke Test: GitHub Actions Services Connectivity

Check Result
Redis PING host.docker.internal unreachable (name resolution failure)
PostgreSQL pg_isready ❌ No response
PostgreSQL SELECT 1 ❌ Connection failed

Overall: FAIL

Agent runs inside AWF sandbox (172.30.0.20/24) with no route to service containers — host.docker.internal is not resolvable and the runner host IP (10.1.0.150) is unreachable from within the sandboxed network.

Warning

Firewall blocked 1 domain

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

  • awmgmcpg

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

network:
  allowed:
    - defaults
    - "awmgmcpg"

See Network Configuration for more information.

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

@github-actions

Copy link
Copy Markdown
Contributor

Smoke Test Results — Docker Sbx

Test Result
GitHub MCP connectivity ✅ Connected (PR data filtered by secrecy policy)
GitHub.com HTTP ⚠️ Template vars unresolved — data unavailable
File write/read ⚠️ Template vars unresolved — data unavailable

Overall: INCONCLUSIVE — pre-step template variables (${{ steps.smoke-data.outputs.* }}) were not substituted before agent invocation.

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

@github-actions

Copy link
Copy Markdown
Contributor

Smoke test results:

  • Upgrade gh-aw extension to latest pre-release and recompile workflows: ✅
  • chore: upgrade gh-aw extension to v0.82.10 (pre-release): ✅
  • Fix model-policy config propagation to api-proxy and prevent exact-model family rewrites: ❌
  • File write/read: ✅
  • Build: ❌
    Overall status: FAIL

Warning

Firewall blocked 2 domains

The following domains were blocked by the firewall during workflow execution:

  • awmgmcpg
  • registry.npmjs.org

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

network:
  allowed:
    - defaults
    - "awmgmcpg"
    - "registry.npmjs.org"

See Network Configuration for more information.

🔮 The oracle has spoken through Smoke Codex
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 passed ✅ PASS
Go env passed ✅ PASS
Go uuid passed ✅ PASS
Java gson 1/1 passed ✅ PASS
Java caffeine 1/1 passed ✅ PASS
Node.js clsx passed ✅ PASS
Node.js execa passed ✅ PASS
Node.js p-limit passed ✅ PASS
Rust fd 1/1 passed ✅ PASS
Rust zoxide 1/1 passed ✅ PASS

Overall: 8/8 ecosystems passed — ✅ PASS

Warning

Firewall blocked 1 domain

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

  • awmgmcpg

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

network:
  allowed:
    - defaults
    - "awmgmcpg"

See Network Configuration for more information.

Generated by Build Test Suite for #6299 · 35.8 AIC · ⊞ 6.9K ·
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.13 Python 3.12.3
Node.js v24.18.0 v22.23.1
Go go1.22.12 go1.22.12

⚠️ Python and Node.js versions differ between host and chroot environments.

Warning

Firewall blocked 1 domain

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

  • awmgmcpg

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

network:
  allowed:
    - defaults
    - "awmgmcpg"

See Network Configuration for more information.

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

@lpcox
lpcox merged commit 60186f9 into main Jul 16, 2026
131 of 135 checks passed
@lpcox
lpcox deleted the copilot/fix-api-proxy-models-issue branch July 16, 2026 15:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

3 participants