[Bug] Anthropic API Error: Invalid message structure with thinking blocks in /context command

Resolved 💬 3 comments Opened Jan 7, 2026 by mquandalle Closed Jan 11, 2026

Bug Description
throws an exception when running /context

This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). The promise rejected with the reason:
Error: 400 {"type":"error","error":{"type":"invalid_request_error","message":"messages.25.content.0.type: Expected thinking or redacted_thinking, but found tool_use. 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_011CWtA4fhPNmsX8xNWAehSZ"}
at F9.generate (file:///opt/homebrew/lib/node_modules/@anthropic-ai/claude-code/cli.js:510:11051)
at OT.makeStatusError (file:///opt/homebrew/lib/node_modules/@anthropic-ai/claude-code/cli.js:857:2195)
at OT.makeRequest (file:///opt/homebrew/lib/node_modules/@anthropic-ai/claude-code/cli.js:857:5420)
at process.processTicksAndRejections (node:internal/process/task_queues:105:5)
at async dmB (file:///opt/homebrew/lib/node_modules/@anthropic-ai/claude-code/cli.js:1007:4857)

Environment Info

  • Platform: darwin
  • Terminal: ghostty
  • Version: 2.0.76
  • Feedback ID: 9fdba427-50a9-4258-946e-d9ca1f3d3d8e

Errors

[{"error":"Error: Tool mcp__svelte__svelte-autofixer not found\n    at wi2 (file:///opt/homebrew/lib/node_modules/@anthropic-ai/claude-code/cli.js:2591:6696)\n    at h5 (file:///opt/homebrew/lib/node_modules/@anthropic-ai/claude-code/cli.js:252:20693)\n    at IY (file:///opt/homebrew/lib/node_modules/@anthropic-ai/claude-code/cli.js:252:39057)\n    at ss (file:///opt/homebrew/lib/node_modules/@anthropic-ai/claude-code/cli.js:252:49664)\n    at MJ (file:///opt/homebrew/lib/node_modules/@anthropic-ai/claude-code/cli.js:252:85801)\n    at Xf (file:///opt/homebrew/lib/node_modules/@anthropic-ai/claude-code/cli.js:252:84781)\n    at u_ (file:///opt/homebrew/lib/node_modules/@anthropic-ai/claude-code/cli.js:252:84606)\n    at cS (file:///opt/homebrew/lib/node_modules/@anthropic-ai/claude-code/cli.js:252:81054)\n    at m0 (file:///opt/homebrew/lib/node_modules/@anthropic-ai/claude-code/cli.js:252:6240)\n    at Immediate.ip1 [as _onImmediate] (file:///opt/homebrew/lib/node_modules/@anthropic-ai/claude-code/cli.js:245:3491)","timestamp":"2026-01-07T14:14:22.401Z"},{"error":"SyntaxError: Expected double-quoted property name in JSON at position 1001 (line 32 column 7)\n    at JSON.parse (<anonymous>)\n    at file:///opt/homebrew/lib/node_modules/@anthropic-ai/claude-code/cli.js:75:715\n    at B (file:///opt/homebrew/lib/node_modules/@anthropic-ai/claude-code/cli.js:8:6526)\n    at tA7 (file:///opt/homebrew/lib/node_modules/@anthropic-ai/claude-code/cli.js:2613:26759)\n    at async jr2 (file:///opt/homebrew/lib/node_modules/@anthropic-ai/claude-code/cli.js:2613:29538)","timestamp":"2026-01-07T14:14:22.528Z"},{"error":"Error: 400 {\"type\":\"error\",\"error\":{\"type\":\"invalid_request_error\",\"message\":\"messages.25.content.0.type: Expected `thinking` or `redacted_thinking`, but found `tool_use`. 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_011CWtA4eJ3s1qtdu2s3kzQV\"}\n    at F9.generate (file:///opt/homebrew/lib/node_modules/@anthropic-ai/claude-code/cli.js:510:11051)\n    at OT.makeStatusError (file:///opt/homebrew/lib/node_modules/@anthropic-ai/claude-code/cli.js:857:2195)\n    at OT.makeRequest (file:///opt/homebrew/lib/node_modules/@anthropic-ai/claude-code/cli.js:857:5420)\n    at process.processTicksAndRejections (node:internal/process/task_queues:105:5)\n    at async file:///opt/homebrew/lib/node_modules/@anthropic-ai/claude-code/cli.js:1007:4211\n    at async file:///opt/homebrew/lib/node_modules/@anthropic-ai/claude-code/cli.js:1007:2262\n    at async gT3 (file:///opt/homebrew/lib/node_modules/@anthropic-ai/claude-code/cli.js:1006:16947)\n    at async bmB (file:///opt/homebrew/lib/node_modules/@anthropic-ai/claude-code/cli.js:1007:2195)\n    at async RyA (file:///opt/homebrew/lib/node_modules/@anthropic-ai/claude-code/cli.js:2161:52)\n    at async Lg5 (file:///opt/homebrew/lib/node_modules/@anthropic-ai/claude-code/cli.js:2161:3311)","timestamp":"2026-01-07T14:14:25.670Z"}]

View original on GitHub ↗

This issue has 3 comments on GitHub. Read the full discussion on GitHub ↗