feat(bedrock): support Claude extended thinking on Converse

Merged
SA
7h ago
+1282-60

Closes #1654

The Bedrock provider dropped reasoning in both directions: it never sent a thinking configuration and discarded reasoningContent from Converse and ConverseStream.

What changes for users

  • reasoning_effort (Chat Completions), reasoning.effort (Responses) and thinking (/v1/messages) now reach Claude models on Bedrock as additionalModelRequestFields: a thinking budget on older models, adaptive thinking plus output_config.effort on adaptive ones. none turns thinking off where the model allows it.
  • Reasoning comes back as reasoning_content, Responses reasoning items, or thinking blocks, in buffered and streamed responses. Models from other families that report reasoning get reasoning_content too.
  • Signed and redacted thinking blocks round-trip as extra_content.anthropic.thinking_blocks, so thinking tool-use loops continue instead of failing with a 400. The router now keeps this state for bedrock.
  • While thinking, max_tokens is raised above the budget (within the policy's output ceiling) and a temperature other than 1 or a top_p below 0.95 is dropped.

Bedrock-specific behavior

  • Claude is recognized by model ID (foundation model, system inference profile, or their ARNs). An application inference profile ARN does not name its model, so it gets no thinking configuration.
  • A forced tool_choice cannot be combined with thinking; the tool call is kept and thinking is left out.
  • Also fixed: Claude on Bedrock rejects temperature together with top_p, so top_p is dropped when both are sent, and both are dropped on models that removed sampling parameters.

The model rules are shared with the Anthropic provider through a small exported helper rather than duplicated.

Testing

Request and response shapes were checked against real Bedrock with the AWS CLI. The full gateway path was not run against real Bedrock; it is covered by a test that drives the AWS SDK against a fake Converse endpoint, and streaming by unit tests on the event handler. output_config.effort combined with a JSON-schema response_format is untested.