Skip to content

Is it possible to get reasoning with an inline agent using Claude Sonnet 3.7 or 4 ?

0

I'm trying to get my inline agent to include reasoning in the trace. According to the documentation here, it's possible to enable reasoning by passing the reasoning_config.

Here's how I'm attempting to include this configuration in my invoke_inline_agent call:

response = bedrock_agent_runtime.invoke_inline_agent(
    sessionId=session_id,
    inputText=input_text,
    enableTrace=enable_trace,
    endSession=end_session,
    streamingConfigurations=streaming_configurations,
    bedrockModelConfigurations=bedrock_model_configurations,
    promptOverrideConfiguration={
        'promptConfigurations': [{
            "additionalModelRequestFields": {
                "reasoning_config": {
                    "type": "enabled",
                    "budget_tokens": 2000
                }
            },
            "inferenceConfiguration": {
                "stopSequences": ["</answer>"],
                "maximumLength": 8000,
                "temperature": 1,
                # "topK": 500,
                # "topP": 1
            },
            "parserMode": "DEFAULT",
            "promptCreationMode": "DEFAULT",
            "promptState": "ENABLED",
            "promptType": "ORCHESTRATION",
        }]
    },
)

I constructed these parameters based on the examples provided in the following documentation:

API Reference: InvokeInlineAgent

User Guide: Inline Agent Reasoning

However, even after enabling trace and logging the full response, I’m not seeing any reasoning included in the output.

Can you help me understand what might be missing or incorrect in my setup?

1 Answer
0

Yes, it is possible to enable reasoning with an inline agent using Claude 3.7 Sonnet and Claude 4 models (both Opus 4 and Sonnet 4), but there are some issues with your current implementation.

The main problem in your code is the structure of the reasoning configuration. For Claude models, the reasoning configuration should be specified under a "thinking" key rather than "reasoning_config". Also, the configuration should be placed in the additionalModelRequestFields parameter.

Here's how you should modify your code:

response = bedrock_agent_runtime.invoke_inline_agent(
sessionId=session_id,
inputText=input_text,
enableTrace=enable_trace,
endSession=end_session,
streamingConfigurations=streaming_configurations,
bedrockModelConfigurations=bedrock_model_configurations,
prompt_override_configuration={
'promptConfigurations': [{
"additionalModelRequestFields": {
"thinking": {
"type": "enabled",
"budget_tokens": 2000
}
},
"inferenceConfiguration": {
"stopSequences": ["</answer>"],
"maximumLength": 8000,
"temperature": 1,
# "topK": 500,
# "topP": 1
},
"parserMode": "DEFAULT",
"promptCreationMode": "DEFAULT",
"promptState": "ENABLED",
"promptType": "ORCHESTRATION",
}]
},
)

A few important considerations:

  1. When using reasoning with Claude models, you need to set a budget for the maximum number of tokens that Claude can use for its internal reasoning process.

  2. For Claude 3.7 Sonnet, you must set the temperature to 1 when reasoning is enabled, which you've already done correctly.

  3. Extended thinking is supported specifically for Claude Opus 4, Claude Sonnet 4, and Claude 3.7 Sonnet models.

  4. When reasoning is enabled, the API response will include thinking content blocks followed by text content blocks.

  5. Note that enabling reasoning may increase latency due to the additional processing required for the reasoning process.

Make sure you're using one of the supported model IDs:

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.