Skip to main content

Custom agents

Custom agents let you split responsibilities by role and run sub-agents for specific tasks. In Laravel, configure them with SessionConfig customAgents. For orchestrating multiple sub-agents in parallel, see Fleet Mode.

Basic usage

You can also pass it as an array config.

Configuration fields

Write concrete description values to improve auto-selection accuracy.

Start a session with a specific agent

Set agent 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

Use defaultAgent.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) and editor (change-heavy).
  • Keep tools minimal and least-privileged.
  • Make description concrete to improve delegation.
  • Handle subagent.failed with retry or fallback strategy.
Last modified on May 31, 2026