Skip to content

fix(ai): read an HTTP 402 of the provider as a spent key - #7265

Merged
dan-petty merged 3 commits into
mainfrom
fix/7261-read-http-402-as-a-spent-key
Nov 26, 2026
Merged

dan-petty merged 3 commits into
mainfrom
fix/7261-read-http-402-as-a-spent-key

Conversation

@dan-petty

@dan-petty dan-petty commented Nov 26, 2026 •

Copy link
Copy Markdown
Owner

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 RoadmapProviderKeySpendLimit did not fire.

  • spend_limit_error gives AIKeySpendLimitError for 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_error and the status branches of LLMClient read it.
  • model_call_error also gives the error for ModelQuotaExceededError of pydantic-ai, with the status of the reply, or 402 when it has none.

The failure class is now spend_limit (provider before, and ci_infra in 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 stays provider.

Closes #7261
Change: openspec/changes/archive/2026-11-26-7261-read-http-402-as-a-spent-key/

@dan-petty dan-petty added type/bug Type bug: the code does not do what it must scope/ai AI review pipeline, personas, prompts, LLM client, or RAG labels Nov 26, 2026
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
dan-petty force-pushed the fix/7261-read-http-402-as-a-spent-key branch from a3977b9 to 82c7921 Compare November 26, 2026 00:37
@dan-petty
dan-petty marked this pull request as ready for review November 26, 2026 00:44
@dan-petty
dan-petty merged commit f9e7823 into main Nov 26, 2026
31 checks passed
@dan-petty
dan-petty deleted the fix/7261-read-http-402-as-a-spent-key branch November 26, 2026 00:52
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>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

scope/ai AI review pipeline, personas, prompts, LLM client, or RAG type/bug Type bug: the code does not do what it must

Projects

None yet

Development

Successfully merging this pull request may close these issues.

fix(ai): read an HTTP 402 of the provider as a spent key

1 participant