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
| Property | Type | Required | Description |
|---|---|---|---|
name | string | ✅ | Agent identifier |
displayName | string | Display name | |
description | string | Description used for delegation selection | |
tools | ?array | Allowed tools. null or omitted means all tools | |
prompt | string | ✅ | Agent-specific system prompt |
mcpServers | array | MCP server config for this agent | |
infer | bool | Whether the runtime can auto-select it (default true) | |
skills | array | Skill names to preload on startup |
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.