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.
工作原理
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.
民众
功能
工具
()
:
可迭代{
返回
[
新的
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:
实施
CanActAsTool
on the sub-agent to define the
name()
和
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 不是 receive the parent's conversation history. The parent has to pass a clear, self-contained task description.
阅读 sub-agents docs for the full API.







