Skip to content

I want my Anthropic Claude Sonnet 4 AI to behave as a reasoning model, but I'm not able to apply the required configuration.

1

I want reasoning behavior for my Claude Sonnet 4 model, and I am using invoke_inline_agent to make calls to the AI.

I referred to the following pages to configure my invoke_inline_agent:

  1. https://docs.aws.amazon.com/bedrock/latest/userguide/inline-agent-invoke.html
  2. https://docs.aws.amazon.com/bedrock/latest/userguide/kb-test-configure-reasoning.html?utm_source=chatgpt.com
  3. https://docs.aws.amazon.com/bedrock/latest/APIReference/API_agent-runtime_RetrieveAndGenerateStream.html

Configuration Snapshot:

agent = InlineAgent(
    foundation_model=model_id,
    instruction=agent_instructions,
    agent_name="agent_name",
    action_groups=[
        groups,
        {
            "name": "CodeInterpreter",
            "builtin_tools": {
                "parentActionGroupSignature": "AMAZON.CodeInterpreter"
            },
        },
    ],
    prompt_override_configuration={
        'promptConfigurations': [
            {
                # "foundationModel": model_id,
                "basePromptTemplate": '100000',
                "parserMode": "DEFAULT",
                "promptCreationMode": "DEFAULT",
                "promptState": "ENABLED",
                "promptType": "ORCHESTRATION",

                "additionalModelRequestFields": {
                    "reasoning_config": {
                        "type": "enabled",
                        "budget_tokens": 1024
                    }
                },

                "inferenceConfiguration": {
                    "maximumLength": 8000,
                    "temperature": 1,
                    "topP": 1
                },
            }
        ]
    }
)

I tried using this configuration. Can you please tell me what might be wrong in the above code snippet for enabling reasoning?

We checked the entire orchestration of the agent, but reasoning Content and thoughts are not visible for Claude Sonnet 4. And also tried for Claude Sonnet 3.7 not working for this too.

2 Answers
0

Change the additionalModelRequestFields with using thinking parameter

"additionalModelRequestFields": {
    "thinking": {
        "type": "enabled",
        "budget_tokens": 1024
    }
}

Please refer this blog for additional implementation details

AWS
EXPERT

answered a year ago

  • Hi Ganesh,

    Thank you for your response.

    We reviewed the link you shared, but it appears that the solution is specific to the Converse. However, in our case, we are using the InlineAgent for our workflow, and we're currently unable to enable the Thinking Mode in this setup.

    Could you please assist us with enabling this feature in InlineAgent, if you have any insights or experience with it?

    Your help would be greatly appreciated.

-1

To enable reasoning for Claude Sonnet 4 in your InlineAgent configuration, there are a few issues with your current setup that need to be addressed:

  1. The reasoning configuration should be placed in the additionalModelRequestFields parameter, but it needs to be structured correctly. For Claude Sonnet 4, reasoning can be enabled or disabled using a configurable token budget.

  2. The basePromptTemplate value of '100000' appears incorrect - this should typically contain your prompt template, not a numeric value.

  3. Reasoning is only applied during the generation step, not during the orchestration step. Your current configuration is targeting the "ORCHESTRATION" prompt type.

Here's how you should modify your configuration:

prompt_override_configuration={
'promptConfigurations': [
{
# "foundationModel": model_id,
"parserMode": "DEFAULT",
"promptCreationMode": "DEFAULT",
"promptState": "ENABLED",
"promptType": "GENERATION",  # Change from ORCHESTRATION to GENERATION

"additionalModelRequestFields": {
"anthropic_version": "bedrock-2023-05-31",
"reasoning_config": {
"enable_reasoning": True,
"reasoning_token_budget": 1024
}
},

"inferenceConfiguration": {
"maximumLength": 8000,
"temperature": 1,
"topP": 1
},
}
]
}

Key changes:

  • Changed promptType from "ORCHESTRATION" to "GENERATION" since reasoning is only enabled during the generation step
  • Updated the reasoning configuration format to match what Claude models expect
  • Added the required "anthropic_version" parameter

Note that when using reasoning models, there's a five-minute timeout limit, and the models can use up to 8192 tokens to respond to queries (including both output and thinking tokens). Also, enabling reasoning will increase latency, but it will provide more detailed step-by-step thinking for complex tasks.
Sources
Enhance model responses with model reasoning - Amazon Bedrock
Configure response generation for reasoning models and considerations - Amazon Bedrock
Introducing Claude 4 in Amazon Bedrock, the most powerful models for coding from Anthropic | AWS News Blog

answered a year ago

You are not logged in. Log in to post an answer.

A good answer clearly answers the question and provides constructive feedback and encourages professional growth in the question asker.