Multiple bugs: thinking block ordering, settings schema validation, agent frontmatter

Status Open
Maintainer reply None cached
Activity 12 comments · opened Jan 25, 2026

Bug Report — Multiple Issues

Environment

  • Model: Claude Opus 4.5 (claude-opus-4-5-20251101)
  • Platform: macOS (Darwin 25.3.0)
  • Date: 2025-01-25

---

Bug 1: Thinking Block Ordering Error

Error:

{
  "type": "invalid_request_error",
  "message": "messages.29.content.0: If an assistant message contains any thinking blocks, the first block must be thinking or redacted_thinking. Found text."
}

Request ID: req_011CXTCAWtq7XQ1St7ovhfN8

Description: During a normal CLI session, the API returns this error. An assistant message is being constructed where a text block precedes a thinking block. The user has no control over message payload ordering — this appears to be an internal issue in how Claude Code constructs API requests.

Impact: Session becomes unusable. Only workaround is starting a new conversation.

---

Bug 2: Settings Schema Validation Rejects Valid Files

Error:

Settings Error
.claude/settings.json
  └ $schema: Invalid value. Expected one of: "https://json.schemastore.org/claude-code-settings.json"

Files with errors are skipped entirely, not just the invalid settings.

Description: Claude Code's settings validator only accepts $schema: "https://json.schemastore.org/claude-code-settings.json". However, if settings.json was generated with a different but valid JSON schema URI (e.g., http://json-schema.org/draft-07/schema#), the entire file is skipped instead of just ignoring the $schema field.

Expected behavior:

  • The $schema field should either be optional/ignored, or
  • Claude Code should not skip the entire settings file over a metadata field
  • If Claude Code itself generates settings files, it should use the correct schema value

---

Bug 3: Agent Files Created Without Required Frontmatter

Error:

Agent Parse Errors
└ Failed to parse agent file(s):
  └ example-agent.md: Missing required "name" field in frontmatter

Description: Multiple agent .md files fail to parse because they lack the required YAML frontmatter with a name field. If these files were generated or scaffolded by Claude Code (or by Claude in a session), the tool should include the required frontmatter automatically.

Expected format:

---
name: Agent Name
---

# Agent content here...

Current behavior: Agent files are created without frontmatter, then Claude Code rejects them on startup.

---

Summary

| Bug | Severity | Workaround |
|-----|----------|------------|
| Thinking block ordering | High | Start new conversation |
| Settings schema validation | Medium | Manually fix $schema value |
| Agent frontmatter missing | Low | Manually add name frontmatter |

All three issues point to Claude Code generating content that it later rejects during validation.

View original on GitHub ↗

12 Comments

github-actions[bot] · 7 months ago

Found 3 possible duplicate issues:

  1. https://github.com/anthropics/claude-code/issues/20692
  2. https://github.com/anthropics/claude-code/issues/20691
  3. https://github.com/anthropics/claude-code/issues/20698

This issue will be automatically closed as a duplicate in 3 days.

  • If your issue is a duplicate, please close it and 👍 the existing issue instead
  • To prevent auto-closure, add a comment or 👎 this comment

🤖 Generated with Claude Code

mattolson · 7 months ago

I'm getting the same very consistently now, it just started in the last 10 minutes or so.

API Error: 400 {"type":"error","error":{"type":"invalid_request_error","message":"messages.17.content.0.type: Expected `thinking` or `redacted_thinking`, but found `text`. When
     `thinking` is enabled, a final `assistant` message must start with a thinking block (preceeding the lastmost set of `tool_use` and `tool_result` blocks). We recommend you include
     thinking blocks from previous turns. To avoid this requirement, disable `thinking`. Please consult our documentation at
     https://docs.claude.com/en/docs/build-with-claude/extended-thinking"},"request_id":"req_011CXTCprBFh3zECAtZHyC4f"}

I asked Claude about it, and it said

 Looks like there's a persistent API issue with thinking blocks in the conversation history. That's not something I can fix from my side - it's related to how the client is
  constructing the API messages.
slarkvan · 7 months ago

opps same error

API Error: 400 {"type":"error","error":{"type":"invalid_request_error","me
ssage":"messages.5.content.0: If an assistant message contains any
thinking blocks, the first block must be thinking or
redacted_thinking. Found
text."},"request_id":"req_011CXTDJgmF3vTsxLLEUWeVP"}

doziedotdev · 7 months ago

Same error as well.

I have to manually turn thinking off to do anything.

felixDulys · 7 months ago

same issue.

API Error: 400 {"type":"error","error":{"type":"invalid_request_error","message":"messages.1.content.0: If an assistant message contains any thinking
     blocks, the first block must be `thinking` or `redacted_thinking`. Found `text`."},"request_id":"req_011CXT7C2gffSy6TJrsgWVeV"} 
castrolol · 7 months ago

Same here, I disabled thinking so I could continue

emregurhan · 7 months ago

Additional Finding: EPERM on project-level .claude directories

When working from a different directory than the project root, Claude Code cannot read or write files inside a project's .claude/ directory due to EPERM: operation not permitted errors.

Reproduction:

  • Working directory: ~/
  • Target files: ~/Documents/GitHub/project/.claude/agents/*.md and ~/Documents/GitHub/project/.claude/settings.json
  • All read/write operations return EPERM

This means:

  1. Agent frontmatter errors in project-level .claude/agents/ cannot be fixed from outside the project directory
  2. Settings schema errors in project-level .claude/settings.json cannot be fixed from outside the project directory
  3. Claude Code reports these errors on startup but cannot fix them itself due to permission restrictions

Expected behavior: If Claude Code scans and reports errors from project-level .claude/ directories, it should also have permission to read/fix those files, or at minimum not report errors for files it cannot access.

emregurhan · 7 months ago

Environment Details

| Component | Version |
|-----------|---------|
| Claude Code CLI | 2.1.19 |
| VS Code | 2.3.10 (arm64) |
| Model | Claude Opus 4.5 (claude-opus-4-5-20251101) |
| Node.js | v24.7.0 |
| macOS | 26.3 (Build 25D5101c) |
| Architecture | Apple Silicon (arm64) |

ThatDragonOverThere · 6 months ago

Still happening - February 3, 2026

Platform: Claude Code CLI, Windows

Exact error:

API Error: 400 {"type":"error","error":{"type":"invalid_request_error",
"message":"messages.15.content.78: `thinking` or `redacted_thinking` blocks 
in the latest assistant message cannot be modified. These blocks must remain 
as they were in the original response."},"request_id":"req_011CXmYhWehtfGivYDUKxnwV"}

This occurred mid-session during normal task work. Kills the session — cannot recover without restarting.

ThatDragonOverThere · 6 months ago

Still happening constantly - February 5, 2026

Platform: Claude Code CLI v2.1.32, Windows, Opus 4.6

Getting this error repeatedly mid-conversation during normal work:

API Error: 400 {"type":"error","error":{"type":"invalid_request_error",
"message":"messages.9.content.1: `thinking` or `redacted_thinking` blocks 
in the latest assistant message cannot be modified. These blocks must 
remain as they were in the original response."},
"request_id":"req_011CXr8WvAF65VzG9nEX24Fy"}

Happened twice in a row on consecutive messages in the same conversation. The conversation is mid-flow, working on code analysis. Each error kills the request and requires re-sending.

This is happening constantly now with the new v2.1.32 / Opus 4.6 release. Something in the new version is modifying thinking blocks it shouldn't.

chrisvaillancourt · 6 months ago

+1 on Bug 2 ($schema validation). The $schema field is enforced as a const in the schema itself, which means even a 301 redirect from the canonical URL (e.g., json.schemastore.orgwww.schemastore.org) can't be followed by updating the value — the validator rejects it. A metadata hint for editor autocompletion shouldn't gate whether the entire settings file loads.

cjduncana · 4 months ago

Adding an upstream signal for Bug 2: VS Code is actively migrating away from the json.schemastore.org subdomain — see microsoft/vscode#254689, which tracks the deprecation. Once the subdomain is fully retired, IDE-side $schema resolution for .claude/settings*.json will fail to load, and Claude Code's const-enforced validator blocks the obvious fix (updating the value to a non-deprecated URL).

Confirmed locally on Claude Code 2.1.121 — switching $schema to https://www.schemastore.org/claude-code-settings.json is rejected with Invalid value. Expected one of: "https://json.schemastore.org/claude-code-settings.json". The current workaround is to omit $schema entirely from settings files.