Overview
Thetask tool delegates work to specialized agents using category-based or direct agent selection. Categories automatically select optimal models, while direct agent selection uses agent-specific fallback chains.
Source: src/tools/delegate-task/
Tool Definition
Skill names to inject into delegated agentREQUIRED: Pass
[] if no skills needed.Examples:[]: No skills["mintlify"]: Mintlify documentation skill["git-master", "deploy"]: Multiple skills
Short task description (3-5 words)Example:
"Fix type errors", "Add user auth"Full detailed prompt for the agentMust be in English.Be explicit and detailed — agent has no context from parent session.
Execution mode
false: Synchronous (waits for completion, returns full result)true: Asynchronous (returns task_id immediately, poll withbackground_output)
true ONLY for parallel exploration with 5+ independent queries.Task category for model selectionRequired if
subagent_type not provided.Options:visual-engineering: Frontend, UI/UX, design, stylingultrabrain: Deep logical reasoning, hard problemsdeep: Autonomous problem-solving, thorough researchartistry: Creative, unconventional approachesquick: Trivial tasks, simple fixesunspecified-low: Moderate effort, unclassifiableunspecified-high: High effort, unclassifiablewriting: Documentation, prose, technical writing
Direct agent selection (bypasses category system)Required if
category not provided.Options: explore, librarian, oracle, metis, momus, or any registered agent.Do NOT provide both category and subagent_type.Existing task session to continueUse when:
- Previous task failed/incomplete →
session_idwith “fix: [issue]” - Need follow-up on result →
session_idwith additional question - Multi-turn conversation → always use
session_idinstead of new task
The command that triggered this task (optional)For slash command tracking.
Task result or background task infoSync mode (Background mode (
run_in_background=false):run_in_background=true):Categories
Categories determine model selection and system prompts.visual-engineering
Model:google/gemini-3.1-pro (variant: high)
Best for: Frontend, UI/UX, design, styling, animation
System prompt: Design-first mindset, bold aesthetic choices, distinctive typography, high-impact animations.
Example:
ultrabrain
Model:openai/gpt-5.3-codex (variant: xhigh)
Best for: Deep logical reasoning, complex architecture, hard problems
System prompt: Strategic advisor, bias toward simplicity, leverage existing patterns, readable code.
CRITICAL: Give clear goals, NOT step-by-step instructions.
Example:
deep
Model:openai/gpt-5.3-codex (variant: medium)
Best for: Goal-oriented autonomous problem-solving, thorough research
System prompt: Autonomous executor, extensive exploration before action, fix hairy problems.
CRITICAL: Agent explores 5-15 minutes before acting. Give goal, NOT instructions.
Example:
artistry
Model:google/gemini-3.1-pro (variant: high)
Best for: Complex problem-solving with creative, unconventional approaches
System prompt: Artistic genius, push beyond boundaries, surprise and delight.
Example:
quick
Model:anthropic/claude-haiku-4-5
Best for: Trivial tasks, single file changes, typo fixes
System prompt: Fast, focused, minimal overhead.
WARNING: Less capable model. Prompts MUST be exhaustively explicit:
unspecified-low
Model:anthropic/claude-sonnet-4-6
Best for: Tasks that don’t fit other categories, moderate effort
Selection gate: Use ONLY if task doesn’t fit any other category AND requires moderate effort.
unspecified-high
Model:anthropic/claude-opus-4-6 (variant: max)
Best for: Tasks that don’t fit other categories, substantial effort
Selection gate: Use ONLY if task doesn’t fit any other category AND requires high effort across multiple systems.
writing
Model:kimi-for-coding/k2p5
Best for: Documentation, prose, technical writing, READMEs
System prompt: Clear prose, engaging, anti-AI-slop rules (no em dashes, no corporate phrases).
Example:
Usage Examples
Category-Based Delegation
Direct Agent Selection
Session Continuation
Parallel Background Tasks
With Skills
Model Selection
Model resolution follows this priority:- Category model override (if category provided)
- Category default (from config or built-in)
- Provider fallback (if model unavailable)
- System default (from OpenCode config)
Execution Modes
Synchronous (run_in_background=false)
- Create new session
- Send prompt to agent
- Poll session until idle
- Return full result
Asynchronous (run_in_background=true)
- Launch background task
- Return task_id immediately
- System notifies on completion
- Poll with
background_outputif needed
Error Handling
Missing Required Parameter
run_in_background.
Missing Category and Subagent
Model Unavailable
Session Start Timeout
Configuration
Customize categories in.opencode/oh-my-opencode.jsonc:
Best Practices
✅ Do
- Use sync mode for sequential work (default workflow)
- Use background mode ONLY for parallel exploration (5+ queries)
- Provide explicit prompts for
quickcategory (less capable model) - Give goals, not steps for
ultrabrainanddeepcategories - Use session continuation for follow-up work (preserves context)
- Load relevant skills to inject domain knowledge
❌ Don’t
- Don’t use background mode for sequential tasks
- Don’t provide both
categoryandsubagent_type - Don’t omit
run_in_background— it’s required - Don’t assume agent has parent context — prompts must be self-contained
- Don’t use
quickfor complex tasks — model has limited reasoning
Related Tools
- background_output: Poll background task results
- call_omo_agent: Direct agent invocation (similar interface)
- task_create: Create TODO task (different from delegation)
Source Files
| File | Purpose |
|---|---|
tools.ts:28 | Tool factory and main entry point |
executor.ts | Route to sync/background execution |
constants.ts:210 | Category definitions and models |
category-resolver.ts | Resolve category → model config |
subagent-resolver.ts | Resolve subagent_type → agent |
model-selection.ts | Model availability checking |
skill-resolver.ts | Resolve load_skills → content |
prompt-builder.ts | Build system/user prompts |
sync-task.ts | Synchronous execution flow |
background-task.ts | Background execution flow |