Repository navigation
Description
Problem or Motivation
On 2026-11-25 from 13:12Z to 20:43Z the key of the hosted provider had too few credits. The provider answered HTTP 402 ("This request requires more credits, or fewer max_tokens"), and the gateway passed the status on. The roadmap jobs read the reply as a short provider failure, not as a spent key:
spend_limit_errorinsrc/devops_cli/ai/client/models.pyreads only the textKey limit exceeded, and each caller asks it only for HTTP 401 and 403 (fix(roadmap): name a spent provider key, not a refused key #6821).model_call_errorinsrc/devops_cli/roadmap/agent_run.pygives an HTTP 402 the plainAIClientError, so the failure class isprovider.- A job fails one item for an
AIClientErrorand goes on to the next item. It stops its round only forAICredentialsError. So no round failed, and the failure ledger of the Service parked no row.
Result lines of the 8 hours (Loki, roadmap job result:): 439 attempts with class=provider (refine 315 on 119 items, stage 87, alternatives 34, implement 3) and 4 successes. In the 7-day window, 452 of about 860 failed attempts have the class provider. The Service log of the same time shows HTTP 402 Payment Required (203 lines) and HTTP 429 Too Many Requests from the cooldown of the gateway (199 lines). No log line, class or metric told a person that only a higher spend limit could help.
Proposed Solution
Disposition: change the code.
- An HTTP 402 of a model call is a spent key:
spend_limit_errorreturnsAIKeySpendLimitErrorfor it, with no test of the body text. - Each site that maps HTTP 401 and 403 to a credentials error also takes HTTP 402.
model_call_erroralso mapsModelQuotaExceededErrorof pydantic-ai, which that library raises when a provider reports exhausted quota, credits or billing.
Then the class is spend_limit, each job stops its round at the first refused call, no item gets a failure, and the failure ledger suspends the row with a probe each hour (RETRY_AFTER), as for the 403 of #6821.
Proof: unit tests of spend_limit_error and model_call_error for HTTP 402 and for ModelQuotaExceededError, and a test that the failure class of the error is spend_limit.
Existing Tool Considered
pydantic-ai (in use) already classifies the reply: ModelQuotaExceededError covers HTTP 402 and the quota errors of each provider. The change reads that class and adds no new rule for provider text.
Related
- fix(roadmap): name a spent provider key, not a refused key #6821 named the 403
Key limit exceededreply of the same cause. - feat(roadmap): park jobs while the gateway is offline #5967 asks for a park while the gateway is offline. A health probe does not see this case: the gateway stays ready, and a small request still passes.
Activity
dan-petty commentedon Nov 26, 2026
439 misclassified failures in 8 hours and wrong failure class prevent correct parking and alerting.fix(ai): read an HTTP 402 of the provider as a spent key
docs(openspec): archive the change of #7261
test(roadmap): an implement step stops its run for a 402 quota error
devops-cli-service commentedon Nov 26, 2026
Released in v0.221.11: https://github.com/dan-petty/devops-cli/releases/tag/v0.221.11
devops-cli-service commentedon Nov 26, 2026
Live since 2026-11-26 01:10 UTC