fix(api-proxy): add embedding model pricing to resolve unknown model rejection#4936
Conversation
Embedding models (text-embedding-3-small, text-embedding-ada-002) were missing from the api-proxy AI credits pricing table. With maxAiCredits active and no defaultAiCreditsPricing fallback, these requests were rejected with HTTP 400, triggering the GH_AW_UNKNOWN_MODEL_AI_CREDITS flag that caused the Refactoring Opportunity Scanner to file issue #4935. Add pricing entries: - text-embedding-3-small: $0.02/M input, $0.00 output (no output tokens) - text-embedding-ada-002: $0.10/M input, $0.00 output - text-embedding-3-small-inference resolves via prefix-match Closes #4935
✅ Coverage Check PassedOverall Coverage
📁 Per-file Coverage Changes (2 files)
Coverage comparison generated by |
There was a problem hiding this comment.
Pull request overview
This PR updates the api-proxy’s AI credits pricing so embedding requests made by the Copilot CLI no longer trigger GH_AW_UNKNOWN_MODEL_AI_CREDITS (and HTTP 400s) when maxAiCredits is enabled and no default fallback pricing is configured.
Changes:
- Add curated pricing entries for
text-embedding-3-smallandtext-embedding-ada-002. - Add Jest coverage to confirm AI credits calculation and non-rejection behavior for these embedding models (including prefix match for
text-embedding-3-small-inference).
Show a summary per file
| File | Description |
|---|---|
| containers/api-proxy/ai-credits-pricing.js | Adds explicit pricing entries for embedding models so they resolve as “known” and don’t trigger unknown-model rejection. |
| containers/api-proxy/guards/ai-credits-guard.test.js | Adds tests covering embedding model pricing resolution and behavior under AWF_MAX_AI_CREDITS. |
Copilot's findings
Tip
Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
- Files reviewed: 2/2 changed files
- Comments generated: 2
| // Embedding models (output tokens are not produced; output cost is 0) | ||
| 'text-embedding-3-small': { input: 0.02, cachedInput: null, cacheWrite: null, output: 0.00 }, | ||
| 'text-embedding-ada-002': { input: 0.10, cachedInput: null, cacheWrite: null, output: 0.00 }, |
| it('resolves text-embedding-3-small with input-only pricing', () => { | ||
| const usage = applyAiCreditsUsage({ input_tokens: 1_000_000, output_tokens: 0 }, 'text-embedding-3-small'); | ||
| // input: 1M × $0.02/M / 10_000 denominator = 2.0 AIC | ||
| expect(usage).not.toBeNull(); | ||
| expect(usage.aiCreditsThisResponse).toBeCloseTo(2.0, 5); | ||
| expect(usage.outputCreditsThisResponse).toBe(0); | ||
| }); |
…hen tests - Replace cachedInput: null with cachedInput: 0 for consistency with all other pricing entries (avoids null coercion fragility) - Use non-zero output_tokens in embedding tests to verify that output: 0.00 pricing is actually enforced Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
🏗️ Build Test Suite Results
Overall: 8/8 ecosystems passed — ✅ PASS
|
|
Smoke Test: Copilot BYOK (Direct Mode) ✅ PASS
Mode: Direct BYOK (COPILOT_PROVIDER_API_KEY via api-proxy sidecar, dummy key in agent)
|
🔥 Smoke Test Results — PASS
PR: fix(api-proxy): add embedding model pricing to resolve unknown model rejection Overall: PASS
|
|
PR titles:
Checks:
Overall: PASS Warning Firewall blocked 1 domainThe following domain was blocked by the firewall during workflow execution:
network:
allowed:
- defaults
- "registry.npmjs.org"See Network Configuration for more information.
|
🔍 Smoke Test: API Proxy OpenTelemetry Tracing
All scenarios pass or are expected-pending. No unexpected failures found.
|
|
Smoke test: PAT auth — PASS ✅
Auth mode: PAT (COPILOT_GITHUB_TOKEN) ·
|
Chroot Version Comparison Results
Overall: ❌ Not all versions match — Go matches, but Python and Node.js differ between host and chroot environments.
|
Smoke Test: GitHub Actions Services Connectivity
Overall: FAIL
|
|
Smoke Test Results:
Running in direct BYOK mode (AWF_AUTH_TYPE=github-oidc + AWF_AUTH_AZURE_* + COPILOT_PROVIDER_BASE_URL) via api-proxy → Azure OpenAI (Foundry, o4-mini-aw) authenticated via Microsoft Entra Overall: PASS
|
Smoke Test Results
Overall Status: FAIL PR Titles:
Warning Firewall blocked 1 domainThe following domain was blocked by the firewall during workflow execution:
network:
allowed:
- defaults
- "localhost"See Network Configuration for more information.
|
The Refactoring Opportunity Scanner (and any workflow with
maxAiCreditsactive) was hittingGH_AW_UNKNOWN_MODEL_AI_CREDITSbecause the Copilot CLI makes embedding model requests (text-embedding-3-small,text-embedding-ada-002) that were absent from the api-proxy pricing table. With nodefaultAiCreditsPricingfallback, every such request returned HTTP 400, setting both error flags even though the main agent work completed successfully.Changes
containers/api-proxy/ai-credits-pricing.js— adds two embedding model entries:text-embedding-3-small-inferenceis covered by the existing prefix-match logic.containers/api-proxy/guards/ai-credits-guard.test.js— adds four tests: credit calculation for each embedding model, prefix-match resolution fortext-embedding-3-small-inference, and non-rejection of all three whenmaxAiCreditsis active.