You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
fix(api-proxy): 403 for terminal caps; fix Anthropic/Copilot input credits (#5271)
* fix(api-proxy): 403 for terminal caps; fix Anthropic input credits
Two related token-budget fixes:
1. Terminal hard caps (effective_tokens, max_runs, max_cache_misses,
ai_credits) now reject with HTTP 403 instead of 429. LLM SDK clients
treat 429 as a transient rate-limit and retry-storm against a cap that
never recovers, exhausting the run budget until the step times out.
403 is non-retryable, so the agent stops cleanly. The per-IP rate
limiter keeps returning 429 (with Retry-After) since it is recoverable.
2. AI-credit calculation is now provider-aware. Anthropic reports
input_tokens as the NON-cached input only (cache_read/cache_creation
are additive), whereas OpenAI reports it as the TOTAL with cache as a
subset. The old code always subtracted cache from input, over-counting
cache and under-counting fresh input for Anthropic. provider is now
threaded through applyAiCreditsUsage -> calculateAiCredits.
Provider string literals in the new code use centralized constants from
the new provider-names module (named to avoid colliding with the
providers/ adapter directory).
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
* fix(api-proxy): handle copilot fresh input in ai credits
* test(smoke-claude): raise max-turns/maxRuns from 2 to 5
The maxRuns:2 cap was too tight for the smoke prompt: the agent
routinely burns its 2 invocations on a planning turn plus a parallel
capability-probe before emitting its safe output, then hits the cap and
fails. Bump max-turns (which drives apiProxy.maxRuns) to 5 so the smoke
test has headroom to complete. Recompiled the lock file and updated the
workflow test assertions accordingly.
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
---------
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
0 commit comments