fix(coderd/x/chatd/chaterror): classify aibridge 403 as ChatErrorKindUsageLimit - #27538
Merged
Merged
Conversation
DanielleMaywood
approved these changes
Jul 27, 2026
johnstcn
marked this pull request as ready for review
July 27, 2026 17:29
johnstcn
enabled auto-merge (squash)
July 27, 2026 17:29
Contributor
There was a problem hiding this comment.
Pull request overview
Updates chat error classification in coderd/x/chatd/chaterror so AI budget exhaustion responses from AI Bridge are recognized as ChatErrorKindUsageLimit instead of being treated like auth failures.
Changes:
- Extend usage-limit pattern matching to catch AI budget exceeded messages.
- Add/adjust classifier pattern-coverage test cases for the new signal.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
| coderd/x/chatd/chaterror/signals.go | Adds a new substring signal for usage-limit detection across HTTP status codes. |
| coderd/x/chatd/chaterror/classify_test.go | Adds a pattern-coverage test case to ensure the new usage-limit signal is classified correctly. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Comment on lines
+74
to
+76
| // Hard usage exhaustion codes that fire at any HTTP status, | ||
| // including 429. | ||
| usageLimitAnyStatusPatterns = []string{"insufficient_quota"} | ||
| usageLimitAnyStatusPatterns = []string{"insufficient_quota", "ai budget"} |
johnstcn
disabled auto-merge
July 27, 2026 17:33
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.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 subscribe to this conversation on GitHub.
Already have an account?
Sign in.
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.
Adds the string
ai budget ofto the classifier forChatErrorKindUsageLimit.Testing notes:
insert into group_ai_budgets values ('<everyone group UUID>', 1, NOW(), NOW());