fix(#2786): surface agent API errors when Claude Code exits 0 - #2860
Conversation
Claude Code exits with code 0 on API/infrastructure failures (e.g., invalid_grant, quota exhaustion) while setting is_error:true in the transcript result event. This made infrastructure errors invisible — green workflows with no PR, no comment, and no GHA error annotation. Two changes in run.go: 1. After exit code 0, parse the tee'd output.jsonl for is_error:true result events. If found, override lastExitCode to 1 and emit StepWarn so downstream gating treats the run as failed. 2. Remove the lastExitCode != 0 gate around ParseTranscriptErrors so ::error:: annotations are always emitted, regardless of exit code. Added ParseTranscriptFile to the TranscriptHandler interface to support checking a single JSONL file (output.jsonl) without scanning an entire directory. Note: make lint could not run (shellcheck-py fails to download in sandbox). go vet and go test both pass. Closes #2786
Site previewPreview: https://5728bdf3-site.fullsend-ai.workers.dev Commit: |
This comment was marked as off-topic.
This comment was marked as off-topic.
|
/review |
This comment was marked as resolved.
This comment was marked as resolved.
- Add transcriptErrorOverride flag to skip the post-script when Claude Code exits 0 with is_error:true in the transcript. The flag is scoped to transcript-error overrides only (not all non-zero exits) and reset each iteration. - Simplify the three-way StepWarn branch to two-way, printing lastExitCode (the effective value) instead of exitCode. Assisted-by: Claude (fix), Gemini (review), Codex (review) Signed-off-by: Wayne Sun <gsun@redhat.com>
This comment was marked as resolved.
This comment was marked as resolved.
E2E tests did not runE2E tests run automatically for org/repo members and collaborators on pull requests. For other contributors, a maintainer must add the See E2E testing guide for details. |
|
/review |
|
Persistent review updated to latest commit 5f1462d |
waynesun09
left a comment
There was a problem hiding this comment.
LGTM. Reviewed with a 5-agent review squad (Claude, Gemini, Codex), 3 fix-verify iterations.
Core logic is correct: is_error:true in the final transcript result event is a definitive session failure signal (API errors, quota exhaustion, stale OIDC tokens). No false positive risk — only fires on exit code 0 with a terminal error in the transcript.
Fixes applied on top of the original commit:
transcriptErrorOverrideflag scoped to transcript-error overrides only (not all non-zero exits), reset each iteration- StepWarn prints
lastExitCode(effective value) instead ofexitCode - Post-script correctly skipped on transcript errors
codecov/patch failure is expected — runAgent is an orchestrator function that can't be unit-tested. The underlying parseTranscriptFile has thorough test coverage.
|
🤖 Finished Retro · ✅ Success · Started 9:51 PM UTC · Completed 10:00 PM UTC |
Retro: PR #2860 — Surface agent API errors when Claude Code exits 0Timeline
What went well
What needed reworkThe human pushed a follow-up commit fixing two gaps in the code agent's implementation:
Skipped proposals (covered by existing issues)
Proposals filed
|
Claude Code exits with code 0 on API/infrastructure failures (e.g., invalid_grant, quota exhaustion) while setting is_error:true in the transcript result event. This made infrastructure errors invisible — green workflows with no PR, no comment, and no GHA error annotation.
Two changes in run.go:
After exit code 0, parse the tee'd output.jsonl for
is_error:true result events. If found, override
lastExitCode to 1 and emit StepWarn so downstream gating
treats the run as failed.
Remove the lastExitCode != 0 gate around
ParseTranscriptErrors so ::error:: annotations are always
emitted, regardless of exit code.
Added ParseTranscriptFile to the TranscriptHandler interface to support checking a single JSONL file (output.jsonl) without scanning an entire directory.
Note: make lint could not run (shellcheck-py fails to download in sandbox). go vet and go test both pass.
Closes #2786
Post-script verification
agent/2786-surface-api-errors)43388d57a168ed0b5caf97463414003677404fa2..HEAD)