Repository navigation
Return a clear error when the Anthropic usage limit is hit - #64
Merged
Merged
Conversation
Anthropic reports a spent workspace limit as a 400 invalid_request_error, which fell through to a bare 500. Match it and return a structured error with a ClaudeExplainUsageLimit metric, and count any other unhandled API error as ClaudeExplainApiError so both can be alarmed on. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
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.
From 2026-10-29 10:23 UTC until the limit was raised on 2026-10-30, every Claude Explain request returned a bare
500 Internal Server Error. The workspace had hit its monthly API spend limit, and Anthropic reports that as a 400invalid_request_error("You have reached your specified workspace API usage limits...") rather than a 429. Only 408/409/429/5xx were handled, so the 400 was re-raised and became a 500. That's 67 failed requests in CloudWatch, and the first we heard of it was a user on Discord.Change
ClaudeExplainUsageLimitmetric and logs at ERROR.ClaudeExplainApiErrorbefore re-raising, so unknown failures are countable too._failed_call_responsehelper. Behaviour and metrics on the existing paths are unchanged.Testing
uv run pytestpasses (226), anduv run pre-commit run --all-filesis clean.The alarm on both metrics, and the
image_tagbump that deploys this, are in an infra PR to follow.🤖 Generated with Claude Code