News

Laravel's AI SDK adds sub-agents

Published
Laravel's AI SDK adds sub-agents image

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 RefundsAgent gets LookupOrder; 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.

Eric L. Barnes photo

Eric is the creator of Laravel News and has been covering Laravel since 2012.

Filed in

Sponsored

acquaintsoft logo
Acquaint Softtech

Hire Laravel developers with AI expertise at $20/hr. Get started in 48 hours.

Visit Acquaint Softtech

The latest

View all →
CPX: The Composer Package Executor for PHP image

CPX: The Composer Package Executor for PHP

Read article
Laravel AI SDK Adds Human-in-the-Loop Tool Approval image

Laravel AI SDK Adds Human-in-the-Loop Tool Approval

Read article
Pest 5 Released With Test Impact Analysis, Agent Verification, and Evals image

Pest 5 Released With Test Impact Analysis, Agent Verification, and Evals

Read article
Queue-SQL: Run Mass Deletes and Updates Across Parallel Queue Jobs image

Queue-SQL: Run Mass Deletes and Updates Across Parallel Queue Jobs

Read article
Blade Formatting in Laravel Pint image

Blade Formatting in Laravel Pint

Read article
Inertia DevTools Is Now on the Chrome Web Store image

Inertia DevTools Is Now on the Chrome Web Store

Read article