-
Notifications
You must be signed in to change notification settings - Fork 1.9k
Support managed agents in ToolCallingAgent #1456
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
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR adds support for managed agents in ToolCallingAgent
, ensuring they are treated like tools when calling the model and surfaced in prompts.
- Register managed agents as callable tools with input/output metadata
- Update prompt templates to display each agent’s inputs and output type
- Include managed agents in
tools_to_call_from
for both streaming and non-streaming calls
Reviewed Changes
Copilot reviewed 5 out of 5 changed files in this pull request and generated 1 comment.
Show a summary per file
File | Description |
---|---|
tests/test_agents.py | Added a test to verify that managed agents are passed to model.generate alongside tools |
src/smolagents/prompts/toolcalling_agent.yaml | Extended system prompt to list agent inputs and output types |
src/smolagents/prompts/structured_code_agent.yaml | Updated example agent signatures to include typed task argument and docstring |
src/smolagents/prompts/code_agent.yaml | Mirrored signature/docs update in code agent prompt |
src/smolagents/agents.py | In _setup_managed_agents , set inputs /output_type ; merged managed agents into tools_to_call_from |
Comments suppressed due to low confidence (2)
tests/test_agents.py:1089
- Consider adding a complementary test for the non-streaming path (when
stream=False
) to verify that managed agents are also included inmodel.generate
calls in that scenario.
def test_toolcalling_agent_passes_both_tools_and_managed_agents(self, test_tool):
src/smolagents/prompts/toolcalling_agent.yaml:106
- [nitpick] The indentation of these lines is deeper than the preceding list item. Align them with the bullet (
-
) for consistent prompt formatting.
Takes inputs: {{agent.inputs}}
@@ -150,8 +150,12 @@ system_prompt: |- | |||
Here is a list of the team members that you can call: | |||
```python | |||
{%- for agent in managed_agents.values() %} | |||
def {{ agent.name }}("Your query goes here.") -> str: | |||
"""{{ agent.description }}""" | |||
def {{ agent.name }}(task: str) -> str: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You can add additional_args
here to hint the manager that it can pass other args:
def {{ agent.name }}(task: str) -> str: | |
def {{ agent.name }}(task: str, additional_args: dict[str, Any]) -> str: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I guess this is a follow-up to:
I also guess this should be added to the ToolCallingAgent prompt as well...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think I will treat that in a subsequent PR.
|
||
Args: | ||
task: Long detailed description of the task. | ||
""" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
""" | |
additional_args: a dictionary of other variables to make available to your managed agent, e.g. images, or dataframes. | |
""" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I just noted that the images
param is treated differently from the additional_args
param in the run
method.
Is this expected? I mean, if we can to pass images to the managed agent, should we use images
or additional_args
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think I will treat that in a subsequent PR.
Support managed agents in
ToolCallingAgent
.Fix #1455.
Fix #1353.
Supersede and close #1418.