Task 7 · 8 tasks
Agents as tools
Split the work: an orchestrator routes to a data specialist and a weather specialist.
The “Overloaded Agent” problem
Alice now wants headcounts and the weather for her next business trip. One agent with every tool and every instruction gets confused. Build a small team instead.
Build it
Build the team
Challenge
Create two specialists,
data_agent(database tools plus the approval hook) andweather_agent(HTTP requests to the US National Weather Service), and an orchestrator that routes to them.Work in
phase1/starter/t7_agents_as_tools.py(look forTODO; an unfinished one prints[starter] TODO …) and run it withuv run bootcamp.py phase1 t7 --starter. The reference solution isphase1/t7_agents_as_tools.py;uv run bootcamp.py phase1 t7runs it.Hint 1
Any function decorated with
@toolis a tool, so a function that runs another agent is one too. This is the “agents as tools” pattern. See Strands: agents as tools.Hint 2
Each specialist gets its own prompt and tools; its docstring tells the orchestrator when to use it. The weather agent uses
http_requestfromstrands.vended_toolsandhttps://api.weather.gov/points/{lat},{lon}.sketchread only@tool def data_agent(query: str) -> str: """<when to use me>""" return str(Agent(model=..., system_prompt=..., tools=db_tools, hooks=[...])(query))Solution
phase1/t7_agents_as_tools.py@tool def data_agent(query: str) -> str: """Query and analyze the DataStream Corp database: employee counts, department statistics, any SQL question. Args: query: A database or data analysis question. """ specialist = Agent( model=make_model(), system_prompt="You are a data specialist. Query the database to answer questions.", tools=db_tools, hooks=[ApprovalHook()], callback_handler=None, ) return str(specialist(query)) # weather_agent: same pattern with tools=[http_request] and WEATHER_PROMPT orchestrator = Agent( name="Executive Assistant", model=make_model(), system_prompt=ORCHESTRATOR_PROMPT, tools=[data_agent, weather_agent], )Run it
terminal · your starter fileuv run bootcamp.py phase1 t7 --starter "How many employees are in Engineering?" uv run bootcamp.py phase1 t7 --starter "What is the weather in Seattle?" uv run bootcamp.py phase1 t7 --starter "How many employees do we have and what is the weather in New York?"terminal · reference solutionuv run bootcamp.py phase1 t7 "How many employees are in Engineering?" uv run bootcamp.py phase1 t7 "What is the weather in Seattle?" uv run bootcamp.py phase1 t7 "How many employees do we have and what is the weather in New York?"Experiments
- Watch the
[data_agent]/[weather_agent]lines: what question does the orchestrator actually pass down? - Try
MODEL_ID=claude-sonnet-5-5for the combined question, then checkuv run bootcamp.py llm. Was the better routing worth the spend? - Add a third specialist, for example one that returns a
DepartmentReport.
- Watch the
Check your work
Phase 1 has no automated test: you check it by running the task and looking for the result below.
Database questions go to data_agent, weather questions to weather_agent, and the combined question calls both and merges the answers.
Under the hood
A @tool is a function with a schema derived from its signature and docstring, so a function that runs another agent is a tool too. Each specialist has its own prompt, tools and context, which keeps prompts short and failures contained. This orchestrator is what you deploy to AgentCore Runtime in Phase 2, Task 4.