Skip to content

Commit 74c9d1c

Browse files
authored
Fix tool calling issue when using AWS Bedrock Nova models (#134)
1 parent cc54cbe commit 74c9d1c

File tree

5 files changed

+10
-7
lines changed

5 files changed

+10
-7
lines changed

examples/mcp_basic_bedrock_agent/README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ Configuration Options
1919
2. Via your AWS config file (`~/.aws/config` and/or `~/.aws/credentials`)
2020

2121
Optional:
22-
- `default_model`: Defaults to `amazon.nova-lite-v1:0` but can be customized in your config.
22+
- `default_model`: Defaults to `us.amazon.nova-lite-v1:0` but can be customized in your config. For more info see: https://docs.aws.amazon.com/bedrock/latest/userguide/inference-profiles-support.html
2323
- `profile`: Select which AWS profile should be used.
2424

2525
## Running the Agent

examples/mcp_basic_bedrock_agent/mcp_agent.config.yaml

+1-2
Original file line numberDiff line numberDiff line change
@@ -18,5 +18,4 @@ mcp:
1818

1919
bedrock:
2020
# Secrets (API keys, etc.) are stored in an mcp_agent.secrets.yaml file which can be gitignored
21-
# default_model: "amazon.nova-lite-v1:0"
22-
default_model: "anthropic.claude-3-haiku-20240307-v1:0"
21+
default_model: "us.amazon.nova-lite-v1:0"

src/mcp_agent/agents/agent.py

+5-1
Original file line numberDiff line numberDiff line change
@@ -173,7 +173,11 @@ async def list_tools(self) -> ListToolsResult:
173173
Tool(
174174
name=HUMAN_INPUT_TOOL_NAME,
175175
description=human_input_tool.description,
176-
inputSchema=human_input_tool.parameters,
176+
inputSchema={
177+
"type": "object",
178+
"properties": {"request": HumanInputRequest.model_json_schema()},
179+
"required": ["request"],
180+
},
177181
)
178182
)
179183

src/mcp_agent/mcp/mcp_aggregator.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@
3131
__name__
3232
) # This will be replaced per-instance when agent_name is available
3333

34-
SEP = "-"
34+
SEP = "_"
3535

3636
# Define type variables for the generalized method
3737
T = TypeVar("T")

src/mcp_agent/workflows/llm/augmented_llm_bedrock.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ def __init__(self, *args, **kwargs):
5555
intelligencePriority=0.3,
5656
)
5757
# Get default model from config if available
58-
default_model = "amazon.nova-lite-v1:0" # Fallback default
58+
default_model = "us.amazon.nova-lite-v1:0" # Fallback default
5959

6060
if self.context.config.bedrock:
6161
if hasattr(self.context.config.bedrock, "default_model"):
@@ -296,7 +296,7 @@ async def generate_structured(
296296
client = instructor.from_bedrock(self.bedrock_client)
297297

298298
params = self.get_request_params(request_params)
299-
model = await self.select_model(params)
299+
model = await self.select_model(params) or "us.amazon.nova-lite-v1:0"
300300

301301
# Extract structured data from natural language
302302
structured_response = client.chat.completions.create(

0 commit comments

Comments
 (0)