Skip to main content
The Subagent Tool lets a parent agent spawn specialised subagents for specific tasks — synchronously, or in the background so the parent keeps working and collects the result later.
The user asks the coordinator; the parent spawns a subagent with the requested permissions.

Quick Start

1

Create Subagent Tool

2

Spawn a Subagent

3

With Model and Permission Mode


Configuration Options


Delegating to Named Agents

Pass agent_resolver to let the parent delegate to your own named agents instead of spawning a generic worker. When a passed agent_name resolves, that named agent runs the sub-task under its own model, tools, and permissions.
resolvable_agents enriches the tool description so the model knows which named agents it may delegate to. The CLI wires both parameters for you from .praisonai/agents/*.md — see Named Agent Delegation as the primary entry point.

Spawn Parameters

When calling the subagent function:

Deliver Background Job Results Back to Chat

When a background job finishes, its result can be pushed back to the user’s chat automatically — no polling required.

Delivery targets

deliver="origin" requires the parent to have an origin context — inside a BotOS chat it does. From a plain script with no active chat context, the pull-only default (deliver="") applies. Failures are also delivered as a failure notice, so the user is never left waiting silently.
The deliver vocabulary mirrors the scheduling tool’s deliver= parameter. See JOB_COMPLETED Hook for the hook that fires on completion. Backward compatibility: with no deliver target set, behaviour is byte-for-byte identical to before — pull-only via subagent_result.

Background Mode

Run a long subtask without blocking the parent agent. Use it for full test runs, broad codebase scans, or large refactors — anything where the parent agent should keep working instead of waiting.
1

Kick off in the background

2

Keep working, then collect the result

3

Handle failures cleanly

When to use background mode

Background return shapes

spawn_subagent(..., background=True) returns a handle (not a final result):
subagent_result(job_id) polls without blocking:
subagent_result(job_id, wait=True) blocks until done:
Depth (max_depth), allowed_agents, and per-call tools / llm / permission_mode apply to background subagents identically to synchronous ones. Background jobs run on a worker thread but inherit the same scoping the parent set up.

Model Selection

Model selection priority:
  1. Per-call llm parameter - Highest priority
  2. default_llm from tool creation - Fallback
  3. Agent’s default model - Final fallback

Permission Modes


Custom Agent Factory

Create agents with custom configurations:

Delegate to named agents

Turn discovered .praisonai/agents/*.md agents into delegation targets with a resolver. When the caller passes an agent_name that resolves, that named agent runs the sub-task under its own model / tools / permission.
See Named Agent Delegation for the full CLI-first story.

Depth Limiting

Prevent infinite subagent recursion:
The default max_depth=3 prevents runaway subagent spawning. Increase with caution.

Agent Restrictions

Limit which agent types can be spawned:

Result Structure

Synchronous calls (background=False, the default) return the final result directly:
Background calls return a handle — see Background Mode for subagent_result shapes.
When a call is served by an agent_resolver (named agent delegation), agent_name in the result is the resolved named agent (e.g. "researcher"), not "subagent". See Named Agent Delegation.

Best Practices

Use smaller models like gpt-4o-mini for simple tasks and larger models for complex analysis.
Always set permission_mode="plan" for exploration tasks to prevent accidental modifications.
Restrict allowed_agents to only the agent types needed for your use case.
Always check result["success"] before accessing the output.
For test suites, broad scans, or refactors, use background=True so the parent agent can keep working and collect results with subagent_result.

Named Agent Delegation

Delegate to your .praisonai/agents by name — no Python

Subagent Delegation

Advanced subagent management

Permission Modes

Permission mode details

JOB_COMPLETED Hook

Hook that fires when a background job finishes — success or failure