Laravel's AI SDK now lets you hand off agents as tools to other agents, turning the SDK into a proper orchestration layer.
Real apps rarely live in one prompt. A general support agent needs different instructions, tools, and often a different model when answering a refund question vs. a billing one. Sub-agents make that delegation a first-class concept instead of a router you hand-roll.
How it works
Return an agent from another agent's tools() method. The parent delegates a specific task and uses the sub-agent's response while answering the original prompt.
public function tools(): iterable{ return [ new RefundsAgent, ];}
Each sub-agent carries its own:
- Instructions and system prompt
- Tools (a
RefundsAgentgetsLookupOrder; the parent doesn't need it) - Provider and model — pin a sub-agent to Anthropic with
#[Provider(Lab::Anthropic)]while the parent runs on OpenAI - Configuration like temperature, max steps, or timeout
Finer control: Implement CanActAsTool on the sub-agent to define the name() and description() the parent sees. Skip it and Laravel falls back to the class basename and a generic description.
One catch: Each sub-agent invocation runs in isolation — it does not receive the parent's conversation history. The parent has to pass a clear, self-contained task description.
Read the sub-agents docs for the full API.