claude-code - 💡(How to fix) Fix [BUG] Opus 4.8 repeatedly emits malformed tool_use blocks, entire response discarded (4.7 works fine)

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…

Error Message

Error Messages/Logs

Root Cause

Because text blocks and tool_use blocks are emitted in a single response, the malformed tool_use causes the accompanying text block to be discarded as well. From the user's side, the assistant appears to "go silent" — no text reaches the user even when the user explicitly says "don't use tools, just talk to me," because the model still tries to call a tool out of habit and the whole response gets thrown away again.

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?

On Opus 4.8 (claude-opus-4-8[1m]), when the assistant attempts to call an MCP tool, the generated tool_use JSON is frequently malformed (unterminated strings / missing braces / truncated arguments). The harness rejects the whole turn with "Your tool call was malformed and could not be parsed. Please retry."

Because text blocks and tool_use blocks are emitted in a single response, the malformed tool_use causes the accompanying text block to be discarded as well. From the user's side, the assistant appears to "go silent" — no text reaches the user even when the user explicitly says "don't use tools, just talk to me," because the model still tries to call a tool out of habit and the whole response gets thrown away again.

This blocked an active conversation for ~30 minutes across many retries. Switching the model to Opus 4.7 (claude-opus-4-7[1m]) immediately restored normal behavior with the exact same system prompt, MCP set, and conversation history.

What Should Happen?

Tool calls should either be well-formed, or — if generation fails — the accompanying text block should still be delivered to the user so the model can at least communicate.

Error Messages/Logs

Steps to Reproduce

  1. Use Opus 4.8 with a long-ish system prompt and multiple MCP servers attached (in my case: plugin:telegram, several claude.ai connectors).
  2. Hold an active conversation where most turns require calling an MCP tool (e.g. replying through a Telegram bridge).
  3. Within ~5–10 turns the model starts emitting malformed tool_use blocks repeatedly; "retry" does not converge.
  4. Switching to Opus 4.7 in the same session resolves immediately.

Claude Model

Opus

Is this a regression?

Yes, this worked in a previous version

Last Working Version

No response

Claude Code Version

2.1.156

Platform

Anthropic API

Operating System

Windows 11

Terminal/Shell

Windows Terminal

Additional Information

  • Multiple MCP servers connected, including plugin:telegram and a handful of claude.ai-hosted connectors
  • Long system prompt (~several KB of project-level CLAUDE.md)
  • Issue is intermittent on the first few turns and then becomes near-deterministic
  • Not a network/SSE hang — tokens are flowing, the response is generated and then rejected by the parser

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] Opus 4.8 repeatedly emits malformed tool_use blocks, entire response discarded (4.7 works fine)