Skip to content

fix: allow ThinkingBlock/RedactedThinkingBlock in RequestContentBlock#72

Open
Ch33zig wants to merge 1 commit into
CaddyGlow:mainfrom
Ch33zig:fix/thinking-block-request-schema
Open

fix: allow ThinkingBlock/RedactedThinkingBlock in RequestContentBlock#72
Ch33zig wants to merge 1 commit into
CaddyGlow:mainfrom
Ch33zig:fix/thinking-block-request-schema

Conversation

@Ch33zig

@Ch33zig Ch33zig commented Jul 3, 2026

Copy link
Copy Markdown

Fixes #71.

RequestContentBlock (used to validate messages[].content for both user and assistant roles) only allowed TextBlock | ImageBlock | ToolUseBlock | ToolResultBlock. ResponseContentBlock already includes ThinkingBlock and RedactedThinkingBlock for outgoing responses, but the request-side union never got the same treatment.

Repro: proxying client.messages.create(model="claude-sonnet-5", thinking={"type": "adaptive"}, ...) through /claude in a multi-turn tool-use loop. The model returns a thinking block on turn 1; once that block is echoed back in messages[] on turn 2 (required for tool-use continuation per the Messages API), the proxy rejects the request with a 422:

{"type": "error", "error": {"message": "body -> messages -> 1 -> content -> str: Input should be a valid string; body -> messages -> 1 -> content -> list[tagged-union[TextBlock,ImageBlock,ToolUseBlock,ToolResultBlock]] -> 0: Input tag 'thinking' found using 'type' does not match any of the expected tags: 'text', 'image', 'tool_use', 'tool_result'"}}

This isn't model-specific — any config that returns thinking blocks (adaptive or budget_tokens-style extended thinking) and gets used in a tool-calling loop hits this, since the Messages API requires thinking blocks to be replayed unchanged in conversation history.

Fix: add ThinkingBlock | RedactedThinkingBlock to RequestContentBlock, mirroring ResponseContentBlock.

RequestContentBlock (used to validate incoming messages[] content for
both user and assistant roles) only included TextBlock, ImageBlock,
ToolUseBlock, and ToolResultBlock. ResponseContentBlock already
supports ThinkingBlock and RedactedThinkingBlock for outgoing
responses, but the request-side union never got the same treatment.

Any multi-turn tool-use loop against a model that returns thinking
blocks (adaptive thinking, or extended thinking generally) fails once
the assistant turn containing a thinking block is echoed back into
messages[] on the next request, since the discriminated union rejects
the 'thinking' / 'redacted_thinking' type tags with a 422.

Fixes CaddyGlow#71
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Regression] RequestContentBlock union missing ThinkingBlock since v0.2.0 — every Anthropic /claude/v1/messages with thinking blocks returns 422

1 participant