Task Tool (task)
The task tool enables delegation of complex, multi-step tasks to specialized subagents that work autonomously with their own tool access.
Overview
Tool Name:task
Display Name: Task
Kind: Other
Description: Launches specialized subagents to handle complex tasks autonomously. Supports parallel execution and real-time progress updates.
Parameters
Usage
Basic Task Delegation
Detailed Instructions
Multiple Parallel Tasks
Available Subagents
Subagents are configured in your project or user settings. Common types:Built-in Subagents
General Purpose
- Complex refactoring
- Feature implementation
- Multi-file changes
- General development tasks
Code Search
- Finding function definitions
- Locating usage patterns
- Searching across multiple files
- Code exploration
Custom Subagents
Create your own subagents for specific needs. See Subagents System for details.Viewing Available Subagents
In Qwen Code CLI:Task Execution Flow
1. Initialization
2. Execution
3. Termination
Real-time Progress Updates
The task tool provides live updates:Event Types
UI Display
Progress is shown in the CLI:When to Use Task Tool
Good Use Cases
✅ Complex multi-step tasksWhen NOT to Use
❌ Simple file reads- Tasks requiring back-and-forth communication
- Tasks needing user input during execution
- Exploratory tasks with unclear requirements
Subagent Configuration
Subagents need proper configuration to work effectively.Configuration Structure
Creating Subagents
See Subagents System for detailed instructions on:- Creating custom subagents
- Configuring tool access
- Setting model parameters
- Defining system prompts
- Managing subagent lifecycle
Tool Access Control
Subagents only have access to tools specified in their configuration:- Read-only agents: Only read/search tools
- Editor agents: Read + write/edit tools
- Full-access agents: All tools (use carefully)
Execution Limits
Subagents have configurable limits:Reaching Limits
Max Turns:Graceful vs Immediate Termination
- Graceful: Allows subagent to summarize results
- Immediate: Stops immediately and returns current state
Result Handling
Subagents return a single final message:- Use it directly in response
- Process it further
- Delegate to another subagent
- Present it to the user
Statistics and Monitoring
Task execution is tracked:Error Handling
Task Errors
Execution Errors
If a subagent encounters an error:Best Practices
1. Clear, Detailed Prompts
✅ Good:2. Choose Right Subagent
Match task to subagent capabilities:3. Provide Context
Include relevant context in the prompt:4. Set Appropriate Limits
Configure limits based on task complexity:5. Monitor Progress
Watch the progress updates to ensure the subagent is on track:- Check tool calls are relevant
- Verify approach makes sense
- Abort if going in wrong direction
Implementation
Location:packages/core/src/tools/task.ts
Tool Class
Next Steps
- Subagents System - Deep dive into subagents
- File System Tools - Tools available to subagents
- Shell Tool - Command execution
- Memory Tool - Persistent storage
