Quick Start
1
Create Subagent Tool
2
Spawn a Subagent
3
With Model and Permission Mode
Configuration Options
Delegating to Named Agents
Passagent_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.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:- Per-call
llmparameter - Highest priority default_llmfrom tool creation - Fallback- 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.
Depth Limiting
Prevent infinite subagent recursion:Agent Restrictions
Limit which agent types can be spawned:Result Structure
Synchronous calls (background=False, the default) return the final result directly:
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 appropriate models
Use appropriate models
Use smaller models like
gpt-4o-mini for simple tasks and larger models for complex analysis.Set permission modes
Set permission modes
Always set
permission_mode="plan" for exploration tasks to prevent accidental modifications.Limit allowed agents
Limit allowed agents
Restrict
allowed_agents to only the agent types needed for your use case.Handle errors
Handle errors
Always check
result["success"] before accessing the output.Use background mode for long tasks
Use background mode for long tasks
For test suites, broad scans, or refactors, use
background=True so the parent agent can keep working and collect results with subagent_result.Related
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

