Repository navigation
fix(ai): read an HTTP 402 of the provider as a spent key - #7265
Merged
Merged
Conversation
An HTTP 402 of a model call says that the provider key has too few credits. spend_limit_error gives AIKeySpendLimitError for it, and model_call_error also maps ModelQuotaExceededError of pydantic-ai. The failure class is spend_limit, so each job stops its round, the failure ledger suspends the row and RoadmapProviderKeySpendLimit fires. Refs #7261
dan-petty
force-pushed
the
fix/7261-read-http-402-as-a-spent-key
branch
from
November 26, 2026 00:37
a3977b9 to
82c7921
Compare
dan-petty
marked this pull request as ready for review
November 26, 2026 00:44
dan-petty-release Bot
added a commit
that referenced
this pull request
Nov 26, 2026
🤖 I have created a release *beep* *boop* --- ## [0.221.11](v0.221.10...v0.221.11) (2026-11-26) ### Bug Fixes * **ai:** read an HTTP 402 of the provider as a spent key ([#7265](#7265)) ([f9e7823](f9e7823)) ### Code Refactoring * **repos:** remove the npm ci step of worktrees add ([#7267](#7267)) ([3128f86](3128f86)) --- This PR was generated with [Release Please](https://github.com/googleapis/release-please). See [documentation](https://github.com/googleapis/release-please#release-please). Co-authored-by: dan-petty-release[bot] <346998822+dan-petty-release[bot]@users.noreply.github.com>
2 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
An HTTP 402 of a model call says that the provider key has too few credits. The roadmap jobs read it as a short provider failure, so no round stopped, the failure ledger suspended no row, and
RoadmapProviderKeySpendLimitdid not fire.spend_limit_errorgivesAIKeySpendLimitErrorfor each HTTP 402, with no test of the body text. The text rule for a 401 or 403 does not change.KEY_STOP_STATUSES(401, 402, 403) is the one set of statuses that stop a run.model_call_errorand the status branches ofLLMClientread it.model_call_erroralso gives the error forModelQuotaExceededErrorof pydantic-ai, with the status of the reply, or 402 when it has none.The failure class is now
spend_limit(providerbefore, andci_infrain an implement step): each job stops its round at the first such call, no item gets a failure, the ledger suspends the row and probes each hour, and the alert names the person step. An HTTP 429 of the gateway cooldown staysprovider.Closes #7261
Change:
openspec/changes/archive/2026-11-26-7261-read-http-402-as-a-spent-key/