Delegating search and calculation with smolagents managed agents
Draft name/description, managed_agents wiring and a responsibility split for a search-plus-calculation task.
Prerequisites and input · Engineering checks · 1. Split the task and assign ownership
At a glance
When one question needs both web lookups and arithmetic on the numbers found, putting everything into a single agent muddles its prompt and tool list. The official smolagents multi-agent example shows a hierarchy instead: a manager that plans and computes, and a managed agent that only does web search. This entry turns that example into a worksheet you can fill in. The input is a query-plus-calculation request that can be divided; the deliverable is a set of name/description values, the managed_agents wiring, and a statement of who is responsible for what.
Runtime and applicability
- Article type
- Engineering practice
- Verified
- Applies to
- smolagents Delegating search and calculation with smolagents managed agents
Execution locations and responsibilities
- smolagents Python runtime Use the workflow below to distinguish responsibilities of the caller, runtime, and external actions.
Arrows show the order of checks in the guide. Follow each step’s prerequisites, branches and stop conditions; unexecuted steps are not completed work.
When to use
- First check that every managed agent has
nameanddescription. The example states that these two attributes are mandatory for the manager to be able to call the agent, so they act as the interface text the manager sees when delegating. The description should say what the agent does, not how it is built.
When not to use
- The example runs its model through
InferenceClientModelafter a Hugging Face login and Inference Providers; the model name and its availability depend on your account and the service at the time, and nothing here guarantees them. - The example's
visit_webpagefetches the page directly and returns failures as error strings; the printed code shows no timeout and no check of page trustworthiness, so you must evaluate those yourself. - The figures in the report shown in the documentation are that document's own output; they were not reproduced or checked here and should not be cited as facts.
- The material only says the setup can be extended with more agents; it says nothing about parallel delegation, retries on failure or deeper nesting, so those are outside this plan.
Prerequisites and input
- A concrete question that has both a lookup part and a calculation part, with a written requirement for how sources must be cited.
- Ability to create agent, tool and model objects in your own smolagents Python runtime; the model and login used in the example must be confirmed as available to you.
- A decision on which Python packages generated calculation code may import, with a stated reason for each.
Engineering checks
Role contract — First check that every managed agent has name and description. The example states that these two attributes are mandatory for the manager to be able to call the agent, so they act as the interface text the manager sees when delegating. The description should say what the agent does, not how it is built.
Configuration and wiring — Next check that the agent type and tools match the kind of work. In the example the search agent is a ToolCallingAgent with WebSearchTool and a self-built visit_webpage, chosen because web browsing is a single-timeline task with no need for parallel tool calls, and max_steps is raised to 10 because several pages may need exploring. The manager is a CodeAgent with an empty tools list, receives the search agent through managed_agents, and uses additional_authorized_imports to permit the packages its calculations need.
Result and stopping — Finally check the shape of the answer. The example question asks for a source for every number used, and the returned report lists the figures, the comparisons and the sources separately. Your plan should state which numbers come from the search agent, which are computed by the manager, what happens when a source is missing, and who decides to stop when the step limit is reached.
1. Split the task and assign ownership
Where: the caller's task description, before any agent is invoked. Input: the divisible query-and-calculation request. Action: separate the facts that must be looked up on the web from the calculations and summaries built on them, and mark which numbers require a source. Completion check: every sub-question belongs to exactly one role. Stop: if the request contains only one kind of work or cannot be split into lookup and calculation, do not introduce a managed agent; go back to designing a single agent.
2. Write name and description for the search role
Where: the code that creates the search agent, in the smolagents Python runtime. Input: the lookup responsibility from the previous step. Action: give it a stable name and a short description that says what it handles, such as running web searches. Completion check: someone reading only those two fields can tell when a task should be handed to it. Stop: if either attribute is missing, stop before wiring, since the material says both are required for the manager to call it.
3. Choose the search agent's type, tools and step budget
Where: the same creation code. Input: the lookup responsibility and the tools available. Action: follow the example's reasoning and pick ToolCallingAgent with WebSearchTool and visit_webpage, and set max_steps high enough for multi-page exploration; the example uses 10. Completion check: the tool list, the step value and the reason for each are written down. Stop: if your lookup work needs parallel calls or another mode, the material gives no basis, so record it as unsupported instead of copying the example.
4. Configure the manager and restrict imports
Where: the code that creates the manager. Input: the managed agent and the calculation needs. Action: use CodeAgent with an empty tools list, put the search agent in managed_agents, and list in additional_authorized_imports only the packages the calculation really needs; the example lists time, numpy and pandas. Completion check: each permitted package maps to a specific calculation. Stop: do not permit a package whose purpose you cannot state; if you need more than the material covers, handle that in a separate code-execution isolation review rather than loosening it here.
5. Put the result contract in the task text
Where: the question passed to the manager. Input: the source requirement and the calculation requirement. Action: as the example does, state explicitly in the question that a source is needed for every number used, and say what the output should contain. Completion check: the task text contains an explicit demand for sources and for the computed result. Stop: if the search side returns no source, the manager should not treat the related number as verified; record the gap and stop.
6. Run and compare against the record, then record why it stopped
Where: the output and terminal record after calling the manager's run. Input: the full question and the configuration above. Action: note who was delegated to, whether the search steps reached max_steps, whether the answer carries sources, and whether the calculation used only permitted packages. Completion check: every number traces to a source or to a calculation. Stop: if the step limit is reached without an answer, or sources are missing, return to steps 2 and 3 to revise descriptions or tools rather than adding more agents to hide the problem; add a new managed agent only for clearly different work, such as file loading.
Task example
This is a synthetic manual walkthrough and was not executed. Suppose the request is: look up the public annual electricity consumption of two cities, compute the ratio, and cite sources. After the split, lookup belongs to the search agent and the ratio to the manager. The search agent is named city_data_search with the description "searches web pages and returns numbers with sources"; it is a ToolCallingAgent with WebSearchTool and visit_webpage, and max_steps is 10. The manager is a CodeAgent that permits only numpy. Hypothetical expected observations: the manager delegates the lookup first, receives two figures with their pages, then computes the ratio itself. If the search side returned figures without page sources, step 5's stop condition applies and those figures are marked unverified. Actual results must be recorded by the reader in their own environment.
Completion checks
- Each managed agent has
nameanddescription, and the description is enough to support a delegation decision. - The search agent's type, tools and
max_stepseach have a written reason, with no unexplained parameters copied from the example. - Every package in
additional_authorized_importsmaps to a concrete calculation. - Every number in the final answer traces to a search source or to the manager's calculation, and numbers without a source are explicitly flagged.
Verification scope
This entry is based only on the supplied smolagents multi-agent example documentation. The documentation was read, but installation, login, API execution and output were not tested; the walkthrough above is a hypothetical manual exercise.
Sources
All links are official pages; verification dates are listed per source, and links point to the version checked.