[BUG] Tool call leaks into chat as plain text ("count" + raw invoke tags) and is not executed
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 makes a tool call (e.g., Write/Edit to create or modify a file), the tool-call markup sometimes breaks and leaks into the chat as visible plain text instead of executing. It shows the literal word "count" followed by raw lowercase invoke/parameter tags. The system then reports "malformed and could not be parsed", so the action does not run. It is intermittent and happens most often on large file writes/edits. No data is corrupted (the bad call is rejected), but it repeatedly interrupts the work and clutters the screen. It happened many times in one session.
What Should Happen?
The tool call should execute normally and never leak into the chat. No internal markup (no "count" token, no invoke/parameter tags) should ever be shown to the user.
Error Messages/Logs
System message: malformed and could not be parsed
Example of the leaked text (tags uppercased here so they are not re-parsed):
count
<INVOKE name="Write">
<PARAMETER name="file_path">...</PARAMETER>
<PARAMETER name="content">...</PARAMETER>
</INVOKE>
Steps to Reproduce
- In one session, have the assistant run many file operations (Write/Edit) and shell (Bash) commands.
- Ask it to write or edit a large file (e.g., a 200+ line script).
- Intermittently, instead of executing, the tool call leaks into the chat as text: the word "count" followed by raw invoke/parameter tags.
- The system shows "malformed and could not be parsed" and the file is not written. Retrying usually succeeds.
Note: intermittent (not every call); more frequent on long Write/Edit payloads.
Claude Model
Opus
Is this a regression?
No, this never worked
Last Working Version
_No response_
Claude Code Version
2.1.177 (Claude Code)
Platform
Anthropic API
Operating System
Windows
Terminal/Shell
PowerShell
Additional Information
- Intermittent; retrying the same action usually succeeds.
- No data corruption (the malformed call is rejected).
- Occurs more often on long Write/Edit operations.
- OS: Windows 11 Home (build 10.0.26200).
This issue has 2 comments on GitHub. Read the full discussion on GitHub ↗