Skip to content

fix: check model policy before pricing in the request guards - #11212

Merged
lpcox merged 1 commit into
mainfrom
fix/copilot-zero-batch-pricing
Nov 6, 2026
Merged

lpcox merged 1 commit into
mainfrom
fix/copilot-zero-batch-pricing

Conversation

@rabeckett

@rabeckett rabeckett commented Nov 6, 2026 •

Copy link
Copy Markdown
Collaborator

Refs #11211

buildCommonGuardChecks runs the pricing check before the model-specific guards. A model whose pricing can't be resolved therefore gets a 500 pricing_resolution_error, even when model policy rejects it.

Copilot's /models lists some models, such as gpt-4o, gpt-4o-mini and gpt-4.1, with billing.token_prices.batch_size 0 and every price 0. Pricing has rejected that listing as an invalid tariff since #11157. So a disallowed gpt-4o gets a 500 instead of a 403, which is why the Model Routing End-to-End Smoke workflow has failed on main since #11157.

Change

  • guards/common-guard-checks.js: the model-specific guards (multiplier cap, retired model and model policy) now run before the pricing check, so a pricing failure never hides a decision about the model. Both the HTTP and WebSocket paths use this list.
  • guards/model-policy-guard.test.js: when pricing fails, a disallowed model gets the 403 model_policy_violation, and an allowed model still gets pricing_resolution_error.

Not changed

Pricing rules are unchanged. An allowed model whose tariff is invalid, including Copilot's batch_size: 0 listing, still fails with a 500 pricing_resolution_error, as #11157 intends. How AWF should treat that listing is still open in #11211: reject it with a clearer error, count the model as free, or count it as an unknown price.

Testing

  • The new test fails on main (it gets pricing_resolution_error first) and passes with the change.
  • npx jest in containers/api-proxy. On Windows, the same 23 tests fail on main (symlinks and POSIX file permissions); no other test fails.
  • Ran the api-proxy locally against Copilot with a model policy that allows claude-haiku-5.5, gpt-5.6-luna, gpt-4.1 and gpt-4o and disallows gpt-4o:
    • gpt-4o returns 403 model_policy_violation with reason disallowed, as the smoke step expects (it was 500).
    • gpt-4o-mini, which isn't on the allowed list, returns 403 with reason not_allowed (it was 500).
    • gpt-4.1, which is allowed, still returns 500 pricing_resolution_error, which is unchanged.
    • claude-haiku-5.5 returns 200.

The smoke workflow only runs on pushes to main, so it will confirm the fix after merge.

@rabeckett rabeckett added the bug Something isn't working label Nov 6, 2026
Copilot AI adaptive review requested due to automatic review settings November 6, 2026 20:26
@rabeckett rabeckett added the bug Something isn't working label Nov 6, 2026
@rabeckett
rabeckett requested a review from lpcox November 6, 2026 20:27
@github-actions

github-actions Bot commented Nov 6, 2026

Copy link
Copy Markdown
Contributor

🚀 Security Guard has started processing this pull request

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

Zero-batch pricing validation can miss nonzero prices, bypassing fail-closed checks and causing runtime models to retain an older, lower tariff.

1 open issue
What changed in this PR

This PR restores pricing fallback for Copilot models listed with a zero batch size and zero or absent prices, addressing the request failures reported in #11211 after exact-decimal accounting was introduced.

Changes:

  • Recognizes all-zero Copilot listings as having no runtime price.
  • Adds regression coverage for pricing fallback while preserving rejection of zero-batch nonzero prices and negative batch sizes.
File Description
containers/​api-proxy/​runtime-model-catalog.js Adds zero-price detection before rejecting non-positive batch sizes.
containers/​api-proxy/​guards/​exact-pricing.test.js Tests the unpriced listing exception and invalid-batch rejection.

Review effort: Balanced (auto)

@rabeckett rabeckett changed the title fix: treat Copilot's zero-batch, zero-price listing as no runtime price fix: price Copilot's zero-batch listing as a zero tariff Nov 6, 2026
@github-actions

github-actions Bot commented Nov 6, 2026

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.

@rabeckett rabeckett changed the title fix: price Copilot's zero-batch listing as a zero tariff fix: treat Copilot's zero-batch listing as no runtime price again Nov 6, 2026
@github-actions

github-actions Bot commented Nov 6, 2026 •

Copy link
Copy Markdown
Contributor

✅ Coverage Check Passed

Overall Coverage

Metric Base PR Delta
Lines 93.74% 93.74% ➡️ +0.00%
Statements 92.27% 92.27% ➡️ +0.00%
Functions 93.02% 93.02% ➡️ +0.00%
Branches 86.55% 86.55% ➡️ +0.00%
📁 Per-file Coverage Changes (1 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%)

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

buildCommonGuardChecks ran the pricing check before the model-specific
guards, so a model whose pricing can't be resolved got a 500
pricing_resolution_error even when model policy rejects it. Copilot lists
some models, such as gpt-4o, with batch_size 0, which pricing rejects
since #11157, so a disallowed gpt-4o got a 500 instead of a 403. This
broke the Model Routing End-to-End Smoke workflow on main.

Run the model-specific guards (multiplier cap, retired model and model
policy) before the pricing check, so a pricing failure never hides a
decision about the model. Pricing rules are unchanged: an allowed model
whose tariff is invalid still fails with pricing_resolution_error.

Refs #11211

Co-authored-by: Copilot <[email protected]>
@rabeckett
rabeckett force-pushed the fix/copilot-zero-batch-pricing branch from 8d6d056 to 45e74ac Compare November 6, 2026 22:17
@rabeckett rabeckett changed the title fix: treat Copilot's zero-batch listing as no runtime price again fix: check model policy before pricing in the request guards Nov 6, 2026
@lpcox

lpcox commented Nov 6, 2026

Copy link
Copy Markdown
Collaborator

PR sous-chef: human handoff (not merge-ready certification).

Human review or current-head review evidence is still needed.
A maintainer should inspect the worker's local-validation evidence, outstanding review decisions, and current HEAD before manually applying ready-for-aw. This label authorizes expensive agentic CI; do not add it until satisfied.
This handoff is not human review acceptance or proof that all required CI passed on this HEAD. Agent pushes can leave CI stale, and an existing label does not prove a new HEAD was tested. Docker/KVM suites not run locally must be disclosed by the worker.

Sous-chef kind: handoff
Sous-chef head: 8d6d056
Sous-chef state: 861dd033bcb918a254ae45d1df4af486244db6faf89e35e313f2d30fbb23a2b2

Generated by PR Sous Chef · copilot · auto · ~12 AIC · ⌖ ~12 AIC · ⊞ 10K · ◷

@rabeckett

Copy link
Copy Markdown
Collaborator Author

I reworked this PR. Earlier versions changed how the api-proxy reads Copilot's batch_size: 0 listing. That would have overridden the current rule that an invalid tariff must fail, so I dropped it. The PR now only runs the model-specific guards before the pricing check, so a pricing failure can't hide a policy rejection, which is what broke the smoke workflow. Pricing rules are unchanged. How to treat the listing is now an open question in #11211, with the options and evidence. The resolved review thread was about the dropped code.

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.

🟢 Approval recommended

No active review issues are recorded for the change prioritizing model-policy rejections over pricing errors.

No open issues 🎉

1 resolved since last review

Review effort: Balanced (auto)

@lpcox
lpcox merged commit 5eb781a into main Nov 6, 2026
39 checks passed
@lpcox
lpcox deleted the fix/copilot-zero-batch-pricing branch November 6, 2026 23:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants