fix(card): strip <tool_use_error> envelope from tool_result text#85
Merged
Conversation
When Claude Code's Bash hook (or any other tool hook) rejects a
call — sleep > 20s, dangerous compound command, file outside
permitted scope, etc. — the tool_result content in JSONL arrives
wrapped in a literal ``<tool_use_error>…</tool_use_error>`` envelope.
``transcript_parser`` took the first 100 chars of that text as the
error summary and shoved it into the card head, producing rows like
✗ Bash · Error: <tool_use_error>Blocked: sleep 25 followed by:
cat /tmp/a3_setup.log tail -60. To wait for a conditi… · 00:21
Observed on tests-3 today (sandbox blocked the diagnostic
``sleep 25; cat /tmp/a3_setup.log`` command). The opening/closing
tags are internal framing — leaking them to the chat is just noise.
Fix: ``extract_tool_result_text`` now strips both halves of the
envelope before returning. Two-string ``.replace`` (no regex) keeps
it cheap on the hot path; passthrough early-exit when neither tag
substring is present so normal results pay zero cost.
+3 unit tests cover the string path, the list-of-blocks path, and
the no-envelope passthrough.
Co-Authored-By: Claude Opus 4.7 <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.
Summary
<tool_use_error>…</tool_use_error>envelope.transcript_parserthen took the first 100 chars of that text as the error summary and shoved it into the card head, producing rows like✗ Bash · Error: <tool_use_error>Blocked: sleep 25 followed by: cat …. Observed on tests-3 today (sandbox blocked a diagnosticsleep 25; cat /tmp/x.log).extract_tool_result_textnow strips both halves of the envelope before returning. Two-string.replace(no regex) keeps it cheap; early-exit passthrough means normal results pay zero cost.Test plan
🤖 Generated with Claude Code