Custom agents
Custom agents let you split responsibilities by role and run sub-agents for specific tasks. In Laravel, configure them withSessionConfig customAgents.
For orchestrating multiple sub-agents in parallel, see Fleet Mode.
Basic usage
Configuration fields
Write concrete description values to improve auto-selection accuracy.
Start a session with a specific agent
Setagent to activate one custom agent from the first turn.
Disable auto-selection with infer: false
For high-risk agents, disable automatic selection and require explicit use.
Hide tools from the default agent
UsedefaultAgent.excludedTools to hide specific tools from only the default agent.
This makes delegation to a custom agent easier.
Observe sub-agent events
subagent.* events are emitted while sub-agents run.
You can observe them with onEvent or $session->on().
Best practices
- Separate
researcher(read-heavy) andeditor(change-heavy). - Keep
toolsminimal and least-privileged. - Make
descriptionconcrete to improve delegation. - Handle
subagent.failedwith retry or fallback strategy.