TaskOutputTool: Reads task output
8/2/2026, 4:24:29 PM · Source
AI-translated on 8/2/2026, 4:25:42 PM · by Qwen3.6 35B (fast, default)
Deeply understand how TaskOutputTool unifies task outputs from shells, local agents, and remote agents into a consistent structure, and master its design philosophy and evolution direction.
It Unifies Background Task Output into a Single Readable Format
TaskOutputTool is used to read background task output.
Its most important value is unification:
- Shell task output
- Local agent output
- Remote agent output
So the main thread doesn't need to worry about underlying task type differences, only about the unified return structure.
Key Source Code
Input definition:
const inputSchema = z.strictObject({
task_id: z.string(),
block: z.boolean().default(true),
timeout: z.number().min(0).max(600000).default(30000),
})
Unified output object:
type TaskOutput = {
task_id: string;
task_type: TaskType;
status: string;
description: string;
output: string;
}
An Interesting Current State
The source code prompt explicitly states:
DEPRECATED: Prefer using the Read tool on the task's output file path instead.
In other words, it still exists, but Anthropic is already steering "reading task output" toward the more generic Read tool.
This is valuable for studying the source code, as you can see how Claude Code's runtime capabilities are gradually converging.
Call Chain
Main thread wants to check background result > TaskOutputTool > read task status > wait to complete if necessary > uniformly extract output > return to main thread
Summary
TaskOutputTool acts as the "unified read interface" in the background task chain, even if it may eventually be replaced by the more generic Read tool.
Learning map
📚 TaskOutputTool Learning Roadmap
Phase One: Understanding the Underlying Mechanisms
- Understand the differences between the three task types (shell / local agent / remote agent)
- Grasp the structure of the unified output interface
TaskOutputand the meaning of each field - Master the role of the
inputSchemaparameters: task_id, block, timeout
Phase Two: Mastering the Invocation Chain
- Trace the complete chain from main thread request initiation → TaskOutputTool → task status reading → waiting for completion → output return
- Understand the difference between blocking mode (synchronous wait) and non-blocking mode
- Analyze the failure boundaries and retry policies for the timeout parameter
Phase Three: Architectural Evolution Insights
- Compare the functional differences between TaskOutputTool and the general-purpose Read tool
- Understand why Anthropic converged the functionality to a more general-purpose Read tool
- Grasp the design trend of convergence from specialized tools to unified interfaces
Get hands-on — step by step
- Locate the implementation file of TaskOutputTool in the Claude Code source code and read its inputSchema definition
- For the three task types (backend tasks), separately construct a shell task, local agent task, and remote agent task to observe output differences
- Call the Read interface of TaskOutputTool to verify whether the returned structure is a unified TaskOutput (with fields: task_id, task_type, status, description, output)
- Test synchronous waiting and asynchronous polling behavior by setting block=true/false separately
- Set timeout to less than actual task duration (e.g., 100ms), observe state feedback when timeout triggers
- Read the replacement explanation for Read tools in TaskOutputTool source code, then compare their capability boundaries
Top 3 sources
- 1Claude Code GitHub 仓库
Anthropic Claude Code 的官方开源实现,可从中直接查阅 TaskOutputTool 的源码与设计文档。
https://github.com/anthropics/claude-code
- 2Anthropic 官方博客文章
Anthropic 工程团队发布的官方文章,包含 Claude Code 架构演进与工具设计理念的说明。
https://www.anthropic.com/engineering
- 3Agent 模式化输出设计(Pattern: Unified Output Channel)
关于 Agent 中统一输出通道的通用设计模式的教程与最佳实践。
https://www.aipatterns.io/tool-design/unified-output-channels
Links are AI-suggested — worth a quick sanity check before diving in.