Skip to content

fix(roadmap): name a spent provider key, not a refused key - #6827

Merged
dan-petty merged 8 commits into
mainfrom
fix/6821-provider-key-spend-limit
Nov 23, 2026
Merged

dan-petty merged 8 commits into
mainfrom
fix/6821-provider-key-spend-limit

Conversation

@dan-petty

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

Copy link
Copy Markdown
Owner

A 401 or 403 model reply whose provider says that the key reached its spend limit (OpenRouter Key limit exceeded, through the gateway) gives AIKeySpendLimitError, not The model refused the key. One rule, spend_limit_error, reads the error text of the body for model_call_error, LLMClient and fetch_model_info. It names the spend limit and the person step, with no key, URL or amount. As a subclass of AICredentialsError, it stops each stop site.

The new failure class spend_limit (action wait, 1 hour) comes from the error type or from its Job log line. A failed stage Job counts as spend_limit, not ci_infra. The class is in INFRA_CLASSES, so its result line has infra=true and the job grade leaves it out of p. The new critical alert RoadmapProviderKeySpendLimit reads that class on the stage, implement and suspended series. Its runbook says that an implement item that a spent key stopped stays Blocked until a person comments implement: retry.

Closes #6821

Change: openspec/changes/archive/2026-11-23-6821-provider-key-spend-limit/

@dan-petty dan-petty added type/bug Type bug: the code does not do what it must scope/roadmap The roadmap jobs: intake, refine, stage, implement and the Service that runs them labels Nov 23, 2026
@dan-petty

Copy link
Copy Markdown
Owner Author

Review points and the person step for this pull request:

Person step (not for the merge). When RoadmapProviderKeySpendLimit fires, raise the spend limit of the provider key (OpenRouter) or put a key with a higher limit in the gateway. The rows run again at their next probe, at most 1 hour later.

Decisions to review.

  1. The alert is critical with for: 0m, as RoadmapServiceIdentityRefused is: the provider names the cause, and each model call fails until a person acts.
  2. The class spend_limit has the action wait and a retry wait of 1 hour. raise_limit was the other choice; wait says that only a person can act.
  3. Scope: only a 401 or 403 whose error text holds Key limit exceeded gives the new error. A 402 or an OpenAI quota code (pydantic-ai ModelQuotaExceededError) keeps its current class. pydantic-ai 2.71.0 gives ModelAuthenticationError for the OpenRouter 403, so it cannot class it.
  4. A row of the Service has no class on devops_cli_service_jobs_total, so the alert reads devops_cli_service_job_suspended{class="spend_limit"} for a row. That gauge is 1 only after service.max_failed_rounds (default 6) failed rounds. A failed stage Job fires the alert at once.
  5. The fault suite cannot drive spend_limit, because the implement job stops for a credentials error with no stop comment. test_roadmap_implement_submit.py tests the class from the log of the Job.

Evidence.

  • devops ci fail-to-pass --base origin/main: the changed tests fail or error on the base and pass on the branch.
  • Live, 2026-11-23: in the last 24 hours, 49 stage Jobs counted as failed with class="ci_infra", and the refine rows held class="provider". The gateway log holds OpenrouterException - {"error":{"message":"Key limit exceeded (total limit)....
  • The live alert can fire only after the merge and a deploy of the rules. The promtool unit tests prove the rule now.

Found, not in this pull request. #6828: LLMClient.chat_stream does not read the status of a gateway error frame after a keepalive, so a key-limit frame there does not give the new error yet.

@dan-petty
dan-petty force-pushed the fix/6821-provider-key-spend-limit branch from 4389054 to ebee528 Compare November 23, 2026 02:02
@dan-petty
dan-petty marked this pull request as ready for review November 23, 2026 02:10
@dan-petty
dan-petty merged commit 3aedb2f into main Nov 23, 2026
36 checks passed
@dan-petty
dan-petty deleted the fix/6821-provider-key-spend-limit branch November 23, 2026 02:12
dan-petty pushed a commit that referenced this pull request Nov 23, 2026
🤖 I have created a release *beep* *boop*
---


##
[0.198.0](v0.197.0...v0.198.0)
(2026-11-23)


### Features

* **ci:** refuse changes to environment paths after the switch
([#6823](#6823))
([ad366bb](ad366bb))
* **roadmap:** Add requirement text to the stage context
([#6826](#6826))
([615bbc4](615bbc4))
* **roadmap:** Require a rejected alternative with a fact
([#6836](#6836))
([5467e22](5467e22))
* **roadmap:** The stage plan states constant claims
([#6837](#6837))
([5ea6d02](5ea6d02))


### Bug Fixes

* **deps:** update ghcr.io/dan-petty/devtools Docker tag to v1.1.1
([#6834](#6834))
([ea1b00f](ea1b00f))
* **docs:** the error catalog lists the onboard errors
([#6829](#6829))
([1846b2d](1846b2d))
* **roadmap:** name a spent provider key, not a refused key
([#6827](#6827))
([3aedb2f](3aedb2f))
* **roadmap:** read a record below a block a person opens
([#6812](#6812))
([54a36e9](54a36e9))

---
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/roadmap The roadmap jobs: intake, refine, stage, implement and the Service that runs them 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(roadmap): name a spent provider key, not a refused key

1 participant