Skip to main content

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

Use for:
  • Complex refactoring
  • Feature implementation
  • Multi-file changes
  • General development tasks
Use for:
  • 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:
This shows all available subagents with their descriptions and tool access.

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 tasks
Specialized expertise
Parallel execution
Autonomous workflows

When NOT to Use

Simple file reads
Single-step operations
Interactive tasks
  • 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:
This provides isolation and security:
  • 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:
Timeout:

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:
The parent agent receives this result and can:
  1. Use it directly in response
  2. Process it further
  3. Delegate to another subagent
  4. Present it to the user

Statistics and Monitoring

Task execution is tracked:
Statistics are logged (respecting privacy settings) for analytics and optimization.

Error Handling

Task Errors

Execution Errors

If a subagent encounters an error:

Best Practices

1. Clear, Detailed Prompts

Good:
Bad:

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