huggingface / huggingface/agents-course

[HANDS-ON BUG] Unit 2.1 Bedrock converse invocation issue

Open
#593 0 comments 0 reactions 0 assignees View on GitHub
hands-on-bug
Dominant language
MDX
Stars
32.6k
Forks
2.3k
PR merge metrics
No merged PRs in 30d

Description

**Describe the bug**
Hi!
I'm trying to reproduce the steps in the course using the AmazonBedrockServerModel.
While the CodeAgent works well the ToolCallingAgent gives me following error:

`AgentGenerationError: Error while generating output:
Parameter validation failed:
Unknown parameter in input: "tools", must be one of: modelId, messages, system, inferenceConfig, toolConfig, guardrailConfig, additionalModelRequestFields, promptVariables, additionalModelResponseFieldPaths, requestMetadata, performanceConfig
Unknown parameter in input: "tool_choice", must be one of: modelId, messages, system, inferenceConfig, toolConfig, guardrailConfig, additionalModelRequestFields, promptVariables, additionalModelResponseFieldPaths, requestMetadata, performanceConfig
`
I made some research and I found out that the issue is in the way the converse arguments are built.
Specifically in the line 1855 of the models.py file.
The json built to invoke the bedrock converse API is attached to this issue and has, among the other parameters, the "tool" parameter on the same level of "modelId".
The boto3 library expects the tools dict to be injected into the argument "toolConfig" and to have a different structure. I leave here the [link to the doc](https://boto3.amazonaws.com/v1/documentation/api/latest/reference/services/bedrock-runtime/client/converse.html#:~:text=%2C%0A%20%20%20%20%20%20%20%20%5D%0A%20%20%20%20%7D%2C-,toolConfig%3D%7B,-%27tools%27%3A)

[converse_args.json](https://github.com/user-attachments/files/21889502/converse_args.json)

**To Reproduce**
I just leave here the snippet that gives me the error

`
from smolagents import ToolCallingAgent, DuckDuckGoSearchTool, AmazonBedrockModel, InferenceClientModel
import boto3
MODEL_ID = 'eu.amazon.nova-lite-v1:0'
session = boto3.Session(profile_name='profile-name')
bedrock_client = session.client(service_name='bedrock-runtime', region_name='eu-west-1')
model = AmazonBedrockModel(
   model_id = MODEL_ID ,
   client=bedrock_client
)
web_agent = ToolCallingAgent(tools=[DuckDuckGoSearchTool()], model=model)
web_agent.run("Search for the best music recommendations for a party at the Wayne's mansion.")
`

**Additional context**
Library versions:
boto3: 1.40.13
smolagents: 1.21.2
python: 3.13.1

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.