Skip to content

Conversation

@thromel
Copy link

@thromel thromel commented Dec 4, 2025

Summary

  • Add reasoning_effort parameter to ChatBedrockConverse for simplified extended thinking configuration
  • Support for "low", "medium", "high" effort levels
  • Automatic translation to provider-specific formats (Amazon Nova, OpenAI on Bedrock)

Why

This addresses langchain-ai/langchain-aws#788 where users requested a simpler interface for configuring reasoning effort instead of manually setting additional_model_request_fields.

Changes

  1. Added reasoning_effort parameter with type Literal["low", "medium", "high"] | None
  2. Added _configure_reasoning_effort validator that translates the parameter to:
    • Amazon Nova: {"reasoningConfig": {"type": "enabled", "maxReasoningEffort": value}}
    • OpenAI on Bedrock: {"reasoning_effort": value}
    • Other providers: Passes through with a warning
  3. Added comprehensive unit tests for all scenarios

Example Usage

from langchain_aws import ChatBedrockConverse

# Amazon Nova with reasoning
llm = ChatBedrockConverse(
    model="us.amazon.nova-lite-v1:0",
    region_name="us-west-2",
    reasoning_effort="medium",
)

# OpenAI on Bedrock with reasoning
llm = ChatBedrockConverse(
    model="openai.gpt-4o-mini-2024-07-18-v1:0",
    region_name="us-west-2",
    reasoning_effort="high",
)

Test Plan

  • Unit tests for Amazon Nova reasoning configuration
  • Unit tests for OpenAI on Bedrock reasoning configuration
  • Unit tests for merging with existing additional_model_request_fields
  • Unit tests for precedence when fields conflict
  • Unit tests for warning on unsupported providers
  • All existing tests continue to pass (122 passed)

Areas for Careful Review

  • The validator merges reasoning_effort config with existing additional_model_request_fields, giving precedence to user-provided fields
  • Warning is emitted for providers that may not support this parameter (e.g., Anthropic Claude which uses thinking.budget_tokens instead)

Add a `reasoning_effort` parameter that provides a convenient way to
configure extended thinking for models that support it. The parameter
accepts "low", "medium", or "high" values and automatically configures
the appropriate provider-specific reasoning parameters:

- Amazon Nova models: Configures `reasoningConfig` with `maxReasoningEffort`
- OpenAI models on Bedrock: Sets `reasoning_effort` directly
- Other providers: Passes through with a warning

This addresses GitHub issue langchain-ai/langchain#34202 by providing a
simpler interface than manually configuring `additional_model_request_fields`.

Example usage:
```python
llm = ChatBedrockConverse(
    model="us.amazon.nova-lite-v1:0",
    reasoning_effort="medium",
)
```
@thromel thromel mentioned this pull request Dec 4, 2025
28 tasks
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.

1 participant