Support managed agents in ToolCallingAgent by albertvillanova · Pull Request #1456 · huggingface/smolagents (original) (raw)
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_fromfor 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.generatecalls 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}}