Skip to content

fix(card): strip <tool_use_error> envelope from tool_result text#85

Merged
Time4Mind merged 1 commit into
mainfrom
fix/strip-tool-use-error-envelope
May 16, 2026
Merged

fix(card): strip <tool_use_error> envelope from tool_result text#85
Time4Mind merged 1 commit into
mainfrom
fix/strip-tool-use-error-envelope

Conversation

@Time4Mind
Copy link
Copy Markdown
Owner

Summary

  • When Claude Code's Bash hook (or any tool hook) rejects a call, the JSONL tool_result content arrives wrapped in a literal <tool_use_error>…</tool_use_error> envelope. transcript_parser then 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 diagnostic sleep 25; cat /tmp/x.log).
  • Fix: extract_tool_result_text now 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

  • +3 unit tests cover string content, list-of-text-blocks content, and the no-envelope passthrough case.
  • Full suite 469/469 green; ruff + pyright clean.

🤖 Generated with Claude Code

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>
@Time4Mind Time4Mind merged commit 79c58b7 into main May 16, 2026
4 checks passed
@Time4Mind Time4Mind deleted the fix/strip-tool-use-error-envelope branch May 16, 2026 21:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant