fix: allow ThinkingBlock/RedactedThinkingBlock in RequestContentBlock#72
Open
Ch33zig wants to merge 1 commit into
Open
fix: allow ThinkingBlock/RedactedThinkingBlock in RequestContentBlock#72Ch33zig wants to merge 1 commit into
Ch33zig wants to merge 1 commit into
Conversation
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
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #71.
RequestContentBlock(used to validatemessages[].contentfor bothuserandassistantroles) only allowedTextBlock | ImageBlock | ToolUseBlock | ToolResultBlock.ResponseContentBlockalready includesThinkingBlockandRedactedThinkingBlockfor 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/claudein a multi-turn tool-use loop. The model returns athinkingblock on turn 1; once that block is echoed back inmessages[]on turn 2 (required for tool-use continuation per the Messages API), the proxy rejects the request with a 422: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 | RedactedThinkingBlocktoRequestContentBlock, mirroringResponseContentBlock.