claude-code - 💡(How to fix) Fix [BUG] tool_use input intermittently malformed — emits literal "court"/"<invoke>" text instead of a valid tool call [1 comments, 2 participants]

Official PRs (…)
ON THIS PAGE

Recommended Tools

×6

Utilities matched from this issue’s tags and category — try them while you read without losing context.

GitHub issue graph ai analysis

Paste a GitHub issue URL. We fetch that issue, discover linked issues from bodies/comments/timeline, collect linked pull requests, and produce a structured English report.

The report is written in English Markdown for sharing and archival.

Helpful · Quick feedback

Loading…
GitHub stats
anthropics/claude-code#60584Fetched 2026-05-20 03:54:46
View on GitHub
Comments
1
Participants
2
Timeline
6
Reactions
0
Author
Timeline (top)
labeled ×4commented ×1cross-referenced ×1

Error Message

No stack trace — the failure is silent. The symptom is literal text in the assistant's reply, e.g.:

court <invoke name="Edit"> <parameter name="replace_all">false</parameter> <parameter name="file_path">/path/to/file.php</parameter> <parameter name="old_string">...</parameter> <parameter name="new_string">...</parameter> </invoke>

This text appears as part of the rendered markdown message; no Edit is performed and no error is returned.

Fix Action

Fix / Workaround

  • Environment: Claude Code running inside the VS Code native extension.
  • The session involved hundreds of file edits across a PHP/Laravel + React repo; the malformed-call rate rose as the session grew longer.
  • Workaround that reliably avoids it: emit the tool call as the first element of the reply, one tool call per message, with explanation moved AFTER the tool result rather than before the call.
  • Impact: significant — repeated silent edit failures + retries consumed a large portion of a long working session and surfaced raw <invoke> markup to the user.

Code Example

No stack trace — the failure is silent. The symptom is literal text in the
assistant's reply, e.g.:

court
<invoke name="Edit">
<parameter name="replace_all">false</parameter>
<parameter name="file_path">/path/to/file.php</parameter>
<parameter name="old_string">...</parameter>
<parameter name="new_string">...</parameter>
</invoke>

This text appears as part of the rendered markdown message; no Edit is
performed and no error is returned.
RAW_BUFFERClick to expand / collapse

Preflight Checklist

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

What's Wrong?

During a long coding session, the assistant intermittently emits a malformed tool call. Instead of a valid tool-use block, the literal text court followed by an XML-style <invoke name="Edit">...</invoke> block appears in the assistant's visible message as plain text. The tool never executes.

It happens most often when the assistant writes explanatory prose immediately before a tool call (e.g. "Now I'll edit X:" followed by an Edit call). Tool calls placed as the first element of a reply, with little or no preceding prose, succeed reliably. The same Edit, retried with minimal preceding text, then goes through.

Net effect: the edit silently does not apply, the user sees raw <invoke> markup in chat, and the assistant must detect the failure and retry — often several times — which wasted a large part of a long session.

What Should Happen?

Every tool call the assistant intends to make should be emitted as a valid, executable tool-use block, regardless of how much prose precedes it in the same message. A tool call must never leak into the visible message as literal court / <invoke> text.

Error Messages/Logs

No stack trace — the failure is silent. The symptom is literal text in the
assistant's reply, e.g.:

court
<invoke name="Edit">
<parameter name="replace_all">false</parameter>
<parameter name="file_path">/path/to/file.php</parameter>
<parameter name="old_string">...</parameter>
<parameter name="new_string">...</parameter>
</invoke>

This text appears as part of the rendered markdown message; no Edit is
performed and no error is returned.

Steps to Reproduce

Hard to reproduce deterministically (intermittent), but the pattern:

  1. Start a long coding session with many sequential Edit/Read tool calls (observed in a session with 50+ tool calls editing a Laravel codebase).
  2. Have the assistant make Edit calls that are preceded in the same message by a sentence or two of explanation ("Now I'll change X:", "Pozriem ...").
  3. After many turns, some Edit calls are emitted as literal court / <invoke> text instead of executing.
  4. Retrying the SAME edit with no/minimal preceding prose succeeds.

Correlation observed: malformed calls had explanatory prose before them; successful calls were the first element of the reply.

Claude Model

Opus

Is this a regression?

I don't know

Last Working Version

No response

Claude Code Version

2.1.143 (Claude Code)

Platform

Anthropic API

Operating System

macOS

Terminal/Shell

Other

Additional Information

  • Environment: Claude Code running inside the VS Code native extension.
  • The session involved hundreds of file edits across a PHP/Laravel + React repo; the malformed-call rate rose as the session grew longer.
  • Workaround that reliably avoids it: emit the tool call as the first element of the reply, one tool call per message, with explanation moved AFTER the tool result rather than before the call.
  • Impact: significant — repeated silent edit failures + retries consumed a large portion of a long working session and surfaced raw <invoke> markup to the user.

Vote matrix · Quick signals

Works
Did the solution work? Tap to confirm.
Easy Fix
Was it a quick fix?
Time Saver
Did it save you time?
Blocking
Was it severely blocking?
Common Issue
Are others likely hitting this too?
Flaky / Intermittent
Is it intermittent?
Verified / Reproducible
Can you reproduce it reliably?
Loading…

Still need to ship something?

×6

Another batch ranked right after the header list — different links, same matching logic.

Back to top recommendations

TRENDING

claude-code - 💡(How to fix) Fix [BUG] tool_use input intermittently malformed — emits literal "court"/"<invoke>" text instead of a valid tool call [1 comments, 2 participants]