### 文档变更分析
#### 1. 总体摘要
此次文档更新阐明了新模型版本(如 Sonnet 5、Opus 4.8)默认移除了显式的 Task 工具,这一改变直接影响 `TaskCreated` 钩子的触发机制、UI 任务列表的显示逻辑,以及子代理对工具的继承行为。
#### 2. 关键主题
* **默认行为变更**:新模型系列(Opus 4.8, Sonnet 5 等)采用内部状态管理多步骤工作,默认不提供 `TaskCreate` 等 Task 工具。
* **功能依赖性**:多个核心功能依赖 Task 工具的存在。
* **Hooks**:`TaskCreated` 钩子在无 Task 工具的会话中不会触发。
* **UI**:交互模式下的任务列表将默认显示为空。
* **Sub-agents**:子代理在主会话没有 Task 工具时,也无法获取这些工具(即使子代理本身运行的是旧模型)。
* **显式控制机制**:提供了通过 `CLAUDE_CODE_ENABLE_TODO_TOOLS=1` 环境变量来恢复旧版显式工具行为的方法。
#### 3. 影响等级:中等
**理由**:虽然这通常不会导致代码编译错误或 API 直接报错,但它改变了开发者预期的运行时行为。依赖 `TaskCreated` 钩子进行自动化处理,或习惯使用可视化任务列表追踪进度的开发者,会发现这些功能在升级模型后“静默失效”。
#### 4. 开发者行动项
* **评估依赖**:检查是否依赖 `TaskCreated` 钩子来强制执行命名约定或阻止特定任务;如果是,需考虑是否需要通过环境变量重新启用工具。
* **环境变量配置**:如果需要在新模型上保持任务列表可视化功能,请设置 `CLAUDE_CODE_ENABLE_TODO_TOOLS=1`。
* **调试子代理**:若子代理行为异常(无法创建任务),请检查主会话是否禁用了 Task 工具,而非仅检查子代理的模型版本。
💭 Model Reasoning
1. **Analyze the Request:**
* **Role:** World-class programmer analyzing documentation changes.
* **Input:** Three documentation diffs (`hooks.md`, `interactive-mode.md`, `sub-agents.md`).
* **Output Requirement:** Concise, insightful analysis in Markdown format.
* **Language:** Chinese.
* **Structure:**
1. Overall Summary (1-2 sentences).
2. Key Themes.
3. Impact Level with reasoning.
4. Action Items.
2. **Analyze the Diffs:**
* **Diff 1: `hooks.md`**
* *Change:* Added a sentence to the `TaskCreated` hook description: "In a [session without the Task tools](/docs/en/tools-reference#task-tool-availability), this event doesn't fire."
* *Context:* The `TaskCreated` hook relies on `TaskCreate` tool usage.
* **Diff 2: `interactive-mode.md`**
* *Change:* Added a paragraph about the Task List view behavior on newer models (Opus 4.8, Sonnet 5, Fable 5, Mythos 5).
* *Context:* Newer models manage multi-step work internally without explicit "Todo" tools, so the task list stays empty by default unless opted in via `CLAUDE_CODE_ENABLE_TODO_TOOLS=1`.
* *Reference:* Links to "Task tool availability".
* **Diff 3: `sub-agents.md`**
* *Change:* Added a sentence regarding subagents and task tools.
* *Context:* In a session without Task tools, subagents *also* don't get task tools, even if they run a different model. It distinguishes between in-process teammates and split-pane teammates.
3. **Synthesize the Findings:**
* **Overall Summary:** These changes clarify the behavior of the "Task" tools (TaskCreate, TaskList, etc.) and related features across different models and contexts. Specifically, they document that newer models (like Sonnet 5) operate *without* these tools by default, affecting hooks, the UI task list, and subagent capabilities.
* **Key Themes:**
* **Model-specific Tool Availability:** The introduction of new model families (Opus 4.8, Sonnet 5, etc.) that handle tasks internally without exposing explicit Task tools by default.
* **Feature Dependency:** Several features (Hooks, Task List UI, Subagent capabilities) depend on the presence of Task tools and are disabled or modified if those tools aren't available.
* **Opt-in Mechanism:** A clear path to restore the old behavior using `CLAUDE_CODE_ENABLE_TODO_TOOLS=1`.
4. **Determine Impact Level:**
* *Impact:* **Medium**.
* *Reasoning:* This isn't a "breaking change" in the traditional API sense (code won't crash), but it changes the *behavior* developers might expect. If a developer upgrades Claude Code to use Sonnet 5, their hooks relying on `TaskCreated` might stop firing silently, and their custom UI might look empty. Developers building complex agent workflows need to know this nuance.
5. **Formulate Action Items:**
* Check if your workflows rely on `TaskCreated` hooks.
* If you prefer the explicit task list UI on newer models, set the environment variable.
* Understand that subagents inherit the current session's tool constraints regarding Task tools.
* Review the "Task tool availability" documentation for the full list of affected models.
6. **Draft the Response (in Chinese):**
* *Summary:* 此次文档更新阐明了新模型(如 Sonnet 5)默认移除了 Task 工具,进而影响了相关钩子、UI 任务列表以及子代理的行为。
* *Themes:* 模型差异、功能依赖、显式启用。
* *Impact:* Medium (中等)。因为行为发生了重大变化,虽然是“默认”改变,但如果不注意,依赖这些功能的高级用户会感到困惑。
* *Actions:* 设置环境变量、检查钩子、了解子代理限制。
7. **Refine the Language (Professional & Concise):**
* *Overall Summary:* 文档更新阐明了新模型版本(如 Sonnet 5、Opus 4.8)默认不再启用 Task 工具,这一改变影响了 `TaskCreated` 钩子的触发、UI 任务列表的显示以及子代理的工具继承行为。
* *Key Themes:*
* **模型行为变更**:新模型通过内部逻辑而非显式工具管理多步骤工作,导致相关工具默认不可用。
* **功能连锁反应**:Task 工具的缺失导致 `TaskCreated` 钩子不触发、任务列表为空、子代理无法获取 Task 工具。
* **可回退机制**:提供了环境变量(如 `CLAUDE_CODE_ENABLE_TODO_TOOLS=1`)用于恢复旧版显式工具行为。
* *Impact:* **中等**。虽然这主要是行为上的变化而非语法破坏,但若开发者依赖 `TaskCreated` 钩子或可视化的任务列表来追踪工作流,升级模型后将面临功能“静默失效”的风险。
* *Action Items:*
* 如果依赖可视化的任务列表,请设置 `CLAUDE_CODE_ENABLE_TODO_TOOLS=1` 环境变量。
* 检查现有的 `TaskCreated` 钩子逻辑,确认其是否需要适配新模型的默认行为。
* 注意子代理在无 Task 工具的会话中也无法继承这些工具,即使它们运行的是旧模型。
8. **Final Review:** Does this match the prompt's constraints? Yes. World-class programmer tone, markdown, Chinese, specific sections.
* *Self-Correction during drafting:* Ensure I mention that subagents running in split panes might behave differently (as per the diff "runs as a separate Claude Code process, so its own model decides"), but the main point is about the *current session's* context affecting in-process agents or inherited tools. The diff says "In a session without the Task tools... Claude Code doesn't provide the task tools to subagents either". I should keep it simple: subagents follow the session's rules.
9. **Final Output Generation.** (Proceeds to generate output based on step 7).