claude-code - 💡(How to fix) Fix [BUG] Mode/permission changes mid-tool-loop (effortLevel: xhigh) poisons entire session

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

API Error: 400 messages.1.content.N: thinking or redacted_thinking blocks in the

Error Messages/Logs

transcript entry immediately preceding the error is a tool_result) and the offending

  • Session A: error at messages.1.content.18. The transcript shows a permission-mode change default → auto on the line immediately before the first error. After it broke,
  • Session B: error at messages.1.content.19, same mid-loop pattern, preceded by a burst

Root Cause

State changes during a tool loop should not mutate the preserved thinking/redacted_thinking blocks of earlier assistant turns. Thinking blocks must round-trip byte-for-byte (incl. signature). Related to thinking blocks bug filed earlier but appears to be my individual root cause.

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?

With extended thinking active (effortLevel: xhigh puts a thinking block on the first assistant turn), changing session state in the middle of an active tool-use loop causes the next request to fail with:

API Error: 400 messages.1.content.N: `thinking` or `redacted_thinking` blocks in the
latest assistant message cannot be modified. These blocks must remain as they were in
the original response.

Once this fires, EVERY subsequent turn in the session replays the same corrupted history and returns the identical 400 — the session is permanently poisoned and unusable.

What Should Happen?

State changes during a tool loop should not mutate the preserved thinking/redacted_thinking blocks of earlier assistant turns. Thinking blocks must round-trip byte-for-byte (incl. signature). Related to thinking blocks bug filed earlier but appears to be my individual root cause.

Error Messages/Logs

Steps to Reproduce

  1. Set "effortLevel": "xhigh" in settings.json.
  2. Start a session and give a task that triggers a multi-step tool-use loop.
  3. While the agent is actively running tools (mid-loop), change session state — e.g. toggle permission mode with Shift+Tab (default → auto-accept), and/or submit a new prompt.
  4. The next assistant generation returns the 400 above, referencing a thinking block in messages.1 (the first assistant turn).

Claude Model

Opus

Is this a regression?

Yes, this worked in a previous version

Last Working Version

No response

Claude Code Version

2.1.154

Platform

Anthropic API

Operating System

macOS

Terminal/Shell

iTerm2

Additional Information

Reproduced in two consecutive sessions. In both, the failure occurs mid-tool-loop (the transcript entry immediately preceding the error is a tool_result) and the offending block is in messages.1:

  • Session A: error at messages.1.content.18. The transcript shows a permission-mode change default → auto on the line immediately before the first error. After it broke, 4 consecutive turns returned the same 400.
  • Session B: error at messages.1.content.19, same mid-loop pattern, preceded by a burst of last-prompt / ai-title / mode metadata entries.

(Branch analysis ruled out message rewinding/editing as the cause — the only "branches" in the transcript were normal tool_use → tool_result linkages.)

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