docs/developers/tools/task.md
agent)This document describes the agent tool for Qwen Code.
Use agent to launch a specialized subagent to handle complex, multi-step tasks autonomously. The Agent tool delegates work to specialized agents that can work independently with access to their own set of tools, allowing for parallel task execution and specialized expertise.
agent takes the following arguments:
description (string, required): A short (3-5 word) description of the task for user visibility and tracking purposes.prompt (string, required): The detailed task prompt for the subagent to execute. Should contain comprehensive instructions for autonomous execution.subagent_type (string, optional): The type of specialized agent to use for this task. Defaults to general-purpose if omitted.run_in_background (boolean, optional): Set to true to run the agent in the background. You will be notified when it completes.isolation (string, optional): Set to "worktree" to run the agent in an isolated git worktree.agent with Qwen CodeThe Agent tool dynamically loads available subagents from your configuration and delegates tasks to them. Each subagent runs independently and can use its own set of tools, allowing for specialized expertise and parallel execution.
When you use the Agent tool, the subagent will:
Usage:
agent(description="Brief task description", prompt="Detailed task instructions for the subagent", subagent_type="agent_name")
The available subagents depend on your configuration. Common subagent types might include:
You can view available subagents by using the /agents command in Qwen Code.
The Agent tool provides live updates showing:
You can launch multiple subagents concurrently by calling the Agent tool multiple times in a single message, allowing for parallel task execution and improved efficiency.
Each subagent can be configured with:
agent examplesagent(
description="Code refactoring",
prompt="Please refactor the authentication module in src/auth/ to use modern async/await patterns instead of callbacks. Ensure all tests still pass and update any related documentation.",
subagent_type="general-purpose"
)
# Launch code review and test execution in parallel
agent(
description="Code review",
prompt="Review the recent changes in the user management module for code quality, security issues, and best practices compliance.",
subagent_type="general-purpose"
)
agent(
description="Run tests",
prompt="Execute the full test suite and analyze any failures. Provide a summary of test coverage and recommendations for improvement.",
subagent_type="test-engineer"
)
agent(
description="Update docs",
prompt="Generate comprehensive API documentation for the newly implemented REST endpoints in the orders module. Include request/response examples and error codes.",
subagent_type="general-purpose"
)
Use the Agent tool when:
Don't use the Agent tool for:
Subagents are configured through Qwen Code's agent configuration system. Use the /agents command to:
For more information on configuring subagents, refer to the subagents documentation.