[BUG] Malformed/unparseable tool call: the raw tool-call markup (full parameter payload) is rendered to the user as message text

Resolved 💬 2 comments Opened Jun 1, 2026 by suhang56 Closed Jun 5, 2026

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?

When the assistant emits a tool call whose wrapper/markup is malformed (unparseable), Claude Code renders the raw attempted tool-call markup — the full function-call block, including the entire parameter payload — into the visible transcript as assistant message text, and only then surfaces Your tool call was malformed and could not be parsed. Please retry.

For a tool call carrying a large parameter (e.g. a multi-KB document written via the Write tool, or a long Edit), this dumps hundreds of lines of raw XML-ish markup onto the user's screen as if it were chat output. In my session the user saw it directly and asked, in effect, "why did your command just print out to me?" — so the leak is plainly user-visible, not internal-only. It happened twice in one session (an Agent dispatch, then a Write of a large handoff doc), each time flooding the conversation with the raw payload before the retry error appeared.

What Should Happen?

A malformed/unparseable tool-call attempt should be suppressed from the user-visible transcript — or replaced with a compact, content-free placeholder such as ⚠ malformed tool call — retrying — followed by the existing retry error. The attempted tool-call's parameter contents, especially large file payloads, must never be echoed to the user as message text. (Detect the parse failure before flushing the partial block to the transcript.)

Error Messages/Logs

  • System response: Your tool call was malformed and could not be parsed. Please retry.
  • Immediately preceded in the visible transcript by the full raw tool-call markup (opening tag + invoke block + every parameter value — including the complete file body for a Write).

Environment

  • Claude Code CLI, Windows 11 (PowerShell default shell; Git-Bash for POSIX commands).
  • Model: claude-opus-4-8[1m] (Opus 4.8, 1M context).
  • Long multi-agent session (Agent Teams, teammateMode: in-process) running an autoloop. Same program as prior reports #63684 and #64550 (filing this per the same bug-report convention).

View original on GitHub ↗

This issue has 2 comments on GitHub. Read the full discussion on GitHub ↗