[BUG]

Open 💬 1 comment Opened Jul 11, 2026 by zizomi

Preflight Checklist

  • [x] I have searched existing issues and this hasn't been reported yet
  • [x] This is a single bug report (please file separate reports for different bugs)
  • [x] I am using the latest version of Claude Code

What's Wrong?

BUG: Tool call rendered as visible text instead of executing

Summary: The assistant's function_calls block intermittently leaks into the
chat transcript as literal text (e.g. "<invoke name=\"Bash\">…") instead of
being parsed and executed. No tool runs; the user's tokens are wasted and the
turn stalls.

Reproduction pattern (high correlation): multi-line Bash commands containing
heredocs (cat <<'PHP' … PHP), for loops, or several piped stages.
Single-line Bash and dedicated tools (Grep/Read/Write) do NOT trigger it.

Environment: Claude Code, Windows (Git Bash tool), Opus 4.8 / Fable 5.
Frequency: ~6 times in one session.
Impact: wasted tokens, stalled turns, repeated retries.

Suggested fix area: tool-call serialization/streaming when the argument string
contains embedded newlines/heredoc markers.

What Should Happen?

The assistant's tool call should be parsed and executed normally. The
<function_calls>/<invoke> block must never appear as literal text in the
chat transcript — it should run the tool silently and return a result.

<img width="887" height="851" alt="Image" src="https://github.com/user-attachments/assets/4d57dfe6-08de-4ac3-a983-c8b90b2d7f67" />
<img width="925" height="701" alt="Image" src="https://github.com/user-attachments/assets/1cfb2bc8-db96-420b-bb7a-6928a4ca3589" />
<img width="853" height="875" alt="Image" src="https://github.com/user-attachments/assets/73c5fe27-228e-4012-a2ec-53eec42098ee" />

Error Messages/Logs

(No stack trace — the failure is silent. The symptom is the literal tool-call
markup appearing in the assistant message, e.g.:)
call
<invoke name="Bash">
<parameter name="command">cd /d/... && for c in A B C; do ... done</parameter>
</invoke>

Steps to Reproduce

  1. In an interactive Claude Code session, have the assistant run a multi-line

Bash command that contains a heredoc, e.g.:
cat > tests/Probe.php <<'PHP'
<?php ...
PHP
php artisan test tests/Probe.php

  1. Intermittently, instead of executing, the raw tool call is printed to the

chat as text: <invoke name="Bash"><parameter name="command">....

  1. No tool runs; the turn stalls and must be retried.

Reliable-work path: single-line Bash commands and Grep/Read/Write tools never
leak. The correlation is with embedded newlines / heredoc markers / for-loops.

Claude Model

Opus

Is this a regression?

Yes, this worked in a previous version

Last Working Version

_No response_

Claude Code Version

2.1.168

Platform

Anthropic API

Operating System

Windows

Terminal/Shell

PowerShell

Additional Information

Frequency: ~6 occurrences in a single long session (heavy tool use).
Impact: wasted output tokens and stalled turns each time; requires manual retry.
Mitigation found: avoiding heredocs/for-loops in Bash and using dedicated
Grep/Read/Write tools eliminates the leak.

View original on GitHub ↗

This issue has 1 comment on GitHub. Read the full discussion on GitHub ↗