When to reach for it
- Specialists must be encapsulated.
- The main agent must retain absolute control.
- Security boundaries must be strictly separated.
Call a specialist like any other tool.
One orchestrating agent calls other agents exactly like tools, hiding their internal logic and coordination behind a standard tool interface.
A caller agent invokes a tool-agent through a standard tool interface. The embedded-agent semantics are hidden behind the call.
| Call | Caller sees | Inside the tool |
|---|---|---|
| 1 | flight_expert(…) returns one line: flight, time, price | Four model calls, three searches, a fare comparison |
| 2 | hotel_expert(…) returns one line: hotel, nights, price | Three model calls, two searches |
| 3 | Writes the itinerary and answers the user | Nothing. No tool is called |
def as_tool(agent, name, description):
def tool(question: str) -> str:
# the inner steps never reach the caller
return agent.run(question).final_answer
tool.__name__, tool.__doc__ = name, description
return tool
orchestrator = Agent(
instructions="Plan the trip. You answer the user yourself.",
tools=[as_tool(flight_agent, "flight_expert", "Finds and compares flights."),
as_tool(hotel_agent, "hotel_expert", "Finds hotels for given dates.")],
)When to reach for it
When it backfires
The caller treats the tool-agent as instant, but it runs a full internal loop. Timeouts fire before the tool-agent finishes.
Countermeasure
Expose expected latency in the tool schema. Use async callbacks or streaming for long-running tool-agents.
The tool-agent throws an internal exception, but the caller only sees 'Tool execution failed.' Debugging requires tool-agent logs.
Countermeasure
Return structured error payloads with a trace_id. Route the caller to a diagnostic node that can fetch and display the full trace.
Threat exposure
Adopting this pattern opens these attack surfaces. Each links to its entry in the threat model.
Full threat model →Search patterns, frameworks, and pages.