fix: tolerate non-message events in Claude tool traces - #122
Open
vlad902-bot wants to merge 3 commits into
Open
Conversation
(WARNING: This PR and this commit text is entirely AI-generated and
largely human-unreviewed.)
A claude reviewer runs with --allowedTools Read Grep Glob, so it can request a
tool the CLI refuses. When the refusal is settled before the ask, the stream
carries `{"type":"system","subtype":"permission_denied",...,"message":"<text>"}`
— a bare string where assistant/user events carry an object. `_tool_trace` read
`message` for every event before checking its type, so the string reached
`.get("content")` and the round died on an AttributeError.
It died three rubrics into TauCeti#3934, discarding correctness and reuse after
$4.22 of reviewing, and charged the PR one of its three review-error attempts.
Two changes. The parse now skips any event that is not an assistant or user
message, which is also the only kind it ever wanted. And the trace parse moves
inside `run_claude`'s handler: that handler exists so an unforeseen stream shape
degrades to a parse_error, and the one parse that could meet an unforeseen shape
sat above it.
Co-Authored-By: Claude Opus 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.
This PR prevents Claude's
stream-jsontool-trace parser from crashing on stream events it does not consume. Claude Code 2.1.233 emitted a historicalsystem/permission_deniedevent with a stringmessage;_tool_traceassumed every event'smessagewas an object, so anAttributeErrorescapedrun_claudeand ended a paid review round midway.The current reviewer no longer exposes Bash after #123, so the observed trigger is not a live Bash path. The parser still accepts external CLI output, and only
assistantandusermessages belong in the tool trace. It now ignores other event kinds and keeps the trace parse inside the existing parse-error boundary, so an unexpected stream shape becomes a diagnosable failed attempt instead of unwinding the review engine.The regression test replays the captured event, verifies that the terminal verdict and denied tool result still parse correctly, and checks that an unexpected parser exception is contained.
python3 -m py_compile runner/*.pyand every script in thetestsworkflow pass on the branch merged with currentmain.🤖 Prepared with OpenAI Codex