Sub-Agents

Use of sub-agents must be allowed by enabling the session configuration allow_sub_agents. This in turn ensures the system prompt includes guidance on how and when to use sub-agents automatically when responding to user requests.

spawn_agent

Run a prompt in a completely fresh, isolated context window and receive the result as [query, response]. Ideal for consuming large amounts of tokens, handling self‑contained tasks, or avoiding context pollution.

Parameters

Parameter Type Required Description
prompt String Yes The full instruction for the sub‑agent; be explicit, especially when not including history.
include_session_context Boolean No Set to true only when the task requires awareness of the current session (e.g., summarizing, continuing a thread). Defaults to false.

Notes

  • The tool spawns a temporary session, executes the prompt, and returns the query‑response pair. It is useful for multi‑step research or large codebase analysis.
  • Interrupting a spawned agent New in 0.9.17
    • Interrupting a spawned agent (e.g., pressing Ctrl‑C in the CLI while it is working) stops only that sub‑agent and returns control to the session that invoked it.
    • Interrupt again to stop the calling session itself.

Tool Settings

Settings for spawn_agent can be specified in the config file under the tool_settings: section:

tool_settings:
  spawn_agent:
    SETTING: VALUE

The following settings are available:

  • max_agent_depth New in 0.9.17
    • An integer in the inclusive range 0 to 5 that caps how deep a sub-agent can spawn further sub-agents.
    • Defaults to 2.
    • 0 means a sub-agent cannot spawn any further sub-agents.