Repository navigation
fix(claude-code): stop treating successful answers as provider failures - #392
Merged
zpzjzj merged 4 commits intoNov 12, 2026
Merged
Conversation
Run and RunTurn scanned stdout and the session's final message for phrases such as "rate limit" and "authentication error" on every result, so an exit-0 answer that mentioned them was reported as a provider failure and never judged. Scan answer text only when the run exits non-zero or the text is an error report.
Match the exact "API Error:" line, parse the JSON result instead of searching it for field names, and accept the gateway notice only in place of an answer. Add a session-file test for a recorded API error.
A JSON answer that only has an is_error field is the agent's output, not the CLI's status.
karanb192
requested review from
JHWang-1997,
hittyt and
zpzjzj
as code owners
November 11, 2026 14:48
Codex Review Summary: ✅ CompletedThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
goconst counts a fourth "result" literal in the package.
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.
Summary
The Claude Code adapter scans stdout and the session's final message for phrases such as "rate limit", "too many requests" and "authentication error" on every result, including exit 0. With
claude -p, stdout is the agent's answer, so a correct answer that mentions those words is reported as a provider failure:Done. I added a rate limit of 100 requests per second to the API gateway and documented the 429 Too Many Requests response.becomesclaude-code provider rate limit: ...Fixed the authentication error handling in login.gobecomesclaude-code authentication failed: ...The exit code is forced to 1, the case becomes ERROR, and the judge never runs. Any Skill about rate limiting, retries or login handling can hit this. The agent judge calls the same
Run, so a judge that grades such a Skill is affected too.Answer text is now scanned only when the run exits non-zero or the text is an error report. The same answers pass through, on
Runand on resumed turns.Related issues
None. Found while reading the adapter; small fix, so I went straight to a PR.
Changes
internal/agent/claude_code.go:API Error:;resultevent, alone or in an event array, withis_error: true;模型提供方限流.isApiErrorMessage, already parsed into an error-role transcript message), that text is scanned as well.providerRateLimitTextandproviderAuthFailureTextkeep their matching rules.Test plan
Checked on
56ded7d, based on7814813, using Go 1.26.10 and the pinned lint tools.RunandRunTurntests fail for both example answers.TestClaudeProviderSignals_AnswerTextcovers each path: prose at exit 0 and at exit 1, stderr, anAPI Error:first or last line, the gateway notice, a JSON result event with and withoutis_error, a session that ends with an API error, and a session that recovered from one. It also pins four answers that must pass: an error code named in prose, prose that starts with "API errors", the gateway notice quoted inside a sentence, and a JSON answer that only has anis_errorfield.TestClaudeProviderSignals_SessionAPIErrorparses a synthetic session file with anisApiErrorMessageentry and checks that the error is found even though stdout has noAPI Error:line.make verifymake testNotes for reviewers
API Errorcheck ine2e/agent_test.go.API Error:line and no API error entry in the session file, is no longer a failure.authentication_failed,"api_error_status":403and the gateway notice no longer match in the middle of an answer. They still match in a JSON result event flaggedis_error, at the start of the text (the notice), on stderr, and at a non-zero exit.resultevent withis_error: true, for example a generated fixture, is still read as the CLI's own status. I kept that shape becauseTestProviderAuthFailureSignalexpects it at exit 0 andbuildClaudePrintJSONSessionResultis kept for the JSON output mode.