Repository navigation
fix: check model policy before pricing in the request guards - #11212
Conversation
|
🚀 Security Guard has started processing this pull request |
There was a problem hiding this comment.
🟡 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)
|
✅ Copilot review passed with no inline comments. @rabeckett Add the |
✅ Coverage Check PassedOverall Coverage
📁 Per-file Coverage Changes (1 files)
Coverage comparison generated by |
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]>
8d6d056 to
45e74ac
Compare
|
PR sous-chef: human handoff (not merge-ready certification). Human review or current-head review evidence is still needed. Sous-chef kind: handoff
|
|
I reworked this PR. Earlier versions changed how the api-proxy reads Copilot's |

Refs #11211
buildCommonGuardChecksruns the pricing check before the model-specific guards. A model whose pricing can't be resolved therefore gets a 500pricing_resolution_error, even when model policy rejects it.Copilot's
/modelslists some models, such asgpt-4o,gpt-4o-miniandgpt-4.1, withbilling.token_prices.batch_size0 and every price 0. Pricing has rejected that listing as an invalid tariff since #11157. So a disallowedgpt-4ogets a 500 instead of a 403, which is why the Model Routing End-to-End Smoke workflow has failed onmainsince #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 403model_policy_violation, and an allowed model still getspricing_resolution_error.Not changed
Pricing rules are unchanged. An allowed model whose tariff is invalid, including Copilot's
batch_size: 0listing, still fails with a 500pricing_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
main(it getspricing_resolution_errorfirst) and passes with the change.npx jestincontainers/api-proxy. On Windows, the same 23 tests fail onmain(symlinks and POSIX file permissions); no other test fails.claude-haiku-5.5,gpt-5.6-luna,gpt-4.1andgpt-4oand disallowsgpt-4o:gpt-4oreturns 403model_policy_violationwith reasondisallowed, as the smoke step expects (it was 500).gpt-4o-mini, which isn't on the allowed list, returns 403 with reasonnot_allowed(it was 500).gpt-4.1, which is allowed, still returns 500pricing_resolution_error, which is unchanged.claude-haiku-5.5returns 200.The smoke workflow only runs on pushes to
main, so it will confirm the fix after merge.