Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BUG] Error when using ToolCallingAgent as manager #606

Closed
faev999 opened this issue Feb 11, 2025 · 2 comments · Fixed by #650
Closed

[BUG] Error when using ToolCallingAgent as manager #606

faev999 opened this issue Feb 11, 2025 · 2 comments · Fixed by #650
Labels
bug Something isn't working

Comments

@faev999
Copy link

faev999 commented Feb 11, 2025

Describe the bug
Error in calling team member

Code to reproduce the error

web_agent = ToolCallingAgent(
    tools=[DuckDuckGoSearchTool(), visit_webpage],
    model=model_agent_coder,
    max_steps=2,
    name="search",
    description="Runs web searches for you. Give it your query as an argument.",
)

agent_manager = ToolCallingAgent(
    tools=[],
    model=model_agent_pepper,
    managed_agents=[web_agent],
)

while True:
    user_query = input("User: ")
    response = agent_manager.run(user_query)

Error logs (if any)

Error in calling team member: MultiStepAgent.__call__() missing 1 required positional    
argument: 'task'
You should only ask this team member with a correct request.
As a reminder, this team member's description is the following:
<smolagents.agents.ToolCallingAgent object at 0x000001C65D9EFE90>

Expected behavior
A clear and concise description of what you expected to happen.

Packages version:
1.8

Additional context
I am trying to create a manger agent of type ToolCallingAgent, by simply modifying the multi-agents example available on the docs, but instead of a CodeAgent I use the ToolCallingAgent as the manager agent.

@faev999 faev999 added the bug Something isn't working label Feb 11, 2025
@faev999 faev999 changed the title [BUG] [BUG] Error when using ToolCallingAgent as manager Feb 11, 2025
@faev999
Copy link
Author

faev999 commented Feb 11, 2025

I managed to track the line triggering the exception to:

https://github.com/huggingface/smolagents/blob/main/src/smolagents/agents.py#L298:
if tool_name in self.managed_agents: observation = available_tools[tool_name].__call__(**arguments)

And the reason is that __call__(self, task: str, **kwargs) function of MultiStepAgent expects an argument called "task" however when inspecting the "arguments" value, the dictionary's key is rather "request". I found that this comes from the model's answer in the ToolCallingAgent step function here:

https://github.com/huggingface/smolagents/blob/main/src/smolagents/agents.py#L700

model_message: ChatMessage = self.model(
                memory_messages,
                tools_to_call_from=list(self.tools.values()),
                stop_sequences=["Observation:"],
            )

So obviously this has to be related to the prompt, and once I checked inside https://github.com/huggingface/smolagents/blob/main/src/smolagents/prompts/toolcalling_agent.yaml
found that the argument where the user's "task" is contained is actually called "request":
"Calling a team member works the same as for calling a tool: simply, the only argument you can give in the call is 'request', a long string explaining your request."

the easiest way to fix this by simple changing the argument's name in the __call__(self, task: str, **kwargs) function of MultiStepAgent from "task" to "request". However, an Important question is whether there's an intended difference between both words "task" and "request"

faev999 pushed a commit to faev999/smolagents that referenced this issue Feb 12, 2025
…ent.yaml states that the argument to be given in the call is called 'request' and not 'task'. Name also changed on agent test
faev999 pushed a commit to faev999/smolagents that referenced this issue Feb 12, 2025
…ent.yaml states that the argument to be given in the call is called 'request' and not 'task'. Name also changed on agent test
@faev999
Copy link
Author

faev999 commented Feb 12, 2025

Hi everyone, I’ve just submitted a PR #618 that addresses this bug. Looking forward to any feedback or suggestions

faev999 pushed a commit to faev999/smolagents that referenced this issue Feb 14, 2025
…ent.yaml states that the argument to be given in the call is called 'request' and not 'task'. Name also changed on agent test
faev999 pushed a commit to faev999/smolagents that referenced this issue Feb 14, 2025
…ent.yaml states that the argument to be given in the call is called 'request' and not 'task'. Name also changed on agent test
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
1 participant