36>36>
37> 一個快速、唯讀的代理,針對搜尋和分析程式碼庫進行最佳化。37> 一個快速、唯讀的代理,針對搜尋和分析程式碼庫進行最佳化。
38>38>
39> * **Model**:主要對話的模型。當主要對話在 Fable 上執行時,Explore 的模型取決於您的連線方式:39> * **Model**:[主要對話](#which-model-a-nested-subagent-runs-on)的模型。當主要對話在 Fable 上執行時,Explore 會在 Opus 上執行或維持使用 Fable,取決於您的連線方式。
40> * 使用 Claude 訂閱、Anthropic Console 帳戶,或透過 `ANTHROPIC_BASE_URL` 連線的 [LLM 閘道](https://code.claude.com/docs/zh-TW/llm-gateway)時,Explore 會在 [`opus` 別名](https://code.claude.com/docs/zh-TW/model-config#model-aliases)所解析的 Opus 模型上執行。40> * 使用 Claude 訂閱、Anthropic Console 帳戶,或透過 `ANTHROPIC_BASE_URL` 連線的 [LLM 閘道](https://code.claude.com/docs/zh-TW/llm-gateway)時,Explore 會在 [`opus` 別名](https://code.claude.com/docs/zh-TW/model-config#model-aliases)所解析的 Opus 模型上執行。
41> * 在 Amazon Bedrock、Google Cloud 的 Agent Platform、Microsoft Foundry、[AWS 上的 Claude Platform](https://code.claude.com/docs/zh-TW/claude-platform-on-aws.md) 或 [Claude apps 閘道](https://code.claude.com/docs/zh-TW/claude-apps-gateway)上,Explore 會維持使用主要對話的模型。41> * 在 Amazon Bedrock、Google Cloud 的 Agent Platform、Microsoft Foundry、[AWS 上的 Claude Platform](https://code.claude.com/docs/zh-TW/claude-platform-on-aws.md) 或 [Claude apps 閘道](https://code.claude.com/docs/zh-TW/claude-apps-gateway)上,Explore 會維持使用 Fable。
42> * **Tools**:唯讀工具;Write 和 Edit 被拒絕42> * **Tools**:唯讀工具;Write 和 Edit 被拒絕
43> * **Purpose**:檔案發現、程式碼搜尋、程式碼庫探索43> * **Purpose**:檔案發現、程式碼搜尋、程式碼庫探索
44>44>
52>52>
53> 一個研究代理,在 [plan mode](https://code.claude.com/docs/zh-TW/permission-modes.md#analyze-before-you-edit-with-plan-mode) 期間使用,以在呈現計畫之前收集上下文。53> 一個研究代理,在 [plan mode](https://code.claude.com/docs/zh-TW/permission-modes.md#analyze-before-you-edit-with-plan-mode) 期間使用,以在呈現計畫之前收集上下文。
54>54>
55> * **Model**:繼承自主要對話,除非您設定 `CLAUDE_CODE_SUBAGENT_MODEL` 並[強制將其套用至每個 subagent](#run-every-subagent-on-one-model)55> * **Model**:繼承自[主要對話](#which-model-a-nested-subagent-runs-on),除非您設定 `CLAUDE_CODE_SUBAGENT_MODEL` 並[強制將其套用至每個 subagent](#run-every-subagent-on-one-model)
56> * **Tools**:唯讀工具;Write 和 Edit 被拒絕56> * **Tools**:唯讀工具;Write 和 Edit 被拒絕
57> * **Purpose**:用於規劃的程式碼庫研究57> * **Purpose**:用於規劃的程式碼庫研究
58>58>
62>62>
63> 一個能力強大的代理,用於需要探索和行動的複雜多步驟任務。63> 一個能力強大的代理,用於需要探索和行動的複雜多步驟任務。
64>64>
65> * **Model**:如果您設定了 [`CLAUDE_CODE_SUBAGENT_MODEL`](#choose-a-model) 模型且沒有其他方式指派模型,則為該模型,否則為主要對話的模型;[選擇模型](#choose-a-model)說明完整順序,[在一個模型上執行每個 subagent](#run-every-subagent-on-one-model) 展示如何讓變數覆蓋這些來源65> * **Model**:預設為主要對話的模型,遵循[模型順序](#choose-a-model)
66> * **Tools**:[可供 subagents 使用](#available-tools)的每個工具66> * **Tools**:[可供 subagents 使用](#available-tools)的每個工具
67> * **Purpose**:複雜研究、多步驟操作、程式碼修改67> * **Purpose**:複雜研究、多步驟操作、程式碼修改
68>68>
346 346
347### 選擇模型347### 選擇模型
348 348
349`model` 欄位控制子代理使用的模型:349預設情況下,您定義的 subagent 會在與啟動它的對話相同的模型上執行。若要自行選擇其模型,請在其定義中將 [`model`](#supported-frontmatter-fields) 欄位設定為下列其中一個值:
350 350
351* **模型別名**:使用可用別名之一:`sonnet`、`opus`、`haiku` 或 `fable`351* **模型別名**:`sonnet`、`opus`、`haiku` 或 `fable`
352* **完整模型 ID**:使用完整模型 ID,例如 `claude-opus-5-5` 或 `claude-sonnet-5`。接受與 `--model` 旗標相同的值352* **完整模型 ID**:[`--model`](https://code.claude.com/docs/zh-TW/cli-reference#cli-flags) 旗標接受的值,例如 `claude-opus-5-5` 或 `claude-sonnet-5`
353* **inherit**:使用與主對話相同的模型353* **`inherit`**:主對話的模型,或對[巢狀 subagent](#which-model-a-nested-subagent-runs-on) 而言,為產生它的 subagent 的模型
354 354
355當 Claude 叫用 subagent 時,它也可以為該次叫用傳遞 `model` 參數。在 Agent 工具呼叫中,該參數接受模型別名:`sonnet`、`opus`、`haiku` 或 `fable`。Claude 無法在該呼叫中傳遞完整模型 ID 或 `inherit`。Claude Code 會依此順序解析 subagent 的模型:355當有多個來源設定模型時,Claude Code 會依此順序使用第一個:
356 356
3571. 每次叫用 `model` 參數3571. 每次叫用的 `model` 參數,Claude 可在啟動 subagent 時傳遞它。在 Agent 工具呼叫中,該參數接受模型別名,而不接受完整模型 ID 或 `inherit`。
3582. 子代理定義的 `model` frontmatter,其中 `inherit` 選擇主對話的模型3582. subagent 定義中的 `model` 欄位,包括 `inherit`
3593. [`CLAUDE_CODE_SUBAGENT_MODEL`](https://code.claude.com/docs/zh-TW/model-config#environment-variables) 環境變數,當您將其設定為模型別名或模型 ID 時3593. [`CLAUDE_CODE_SUBAGENT_MODEL`](https://code.claude.com/docs/zh-TW/model-config#environment-variables) 環境變數
3604. 主對話的模型3604. 主對話的模型,或對巢狀 subagent 而言,為產生它的 subagent 的模型
361 361
362如果已安裝的 [mod](https://code.claude.com/docs/zh-TW/plugins/mods/overview.md) 在其 [`agent.spawn`](https://code.claude.com/docs/zh-TW/plugins/mods/reference#subagents) hook 中設定了模型,Claude Code 會以該模型取代每次叫用的參數。362如果 Claude 傳遞了別名,subagent 在[被繼續或收到後續訊息](#resume-subagents)時會保留該別名。如果已安裝的 [mod](https://code.claude.com/docs/zh-TW/plugins/mods/overview.md) 在其 [`agent.spawn`](https://code.claude.com/docs/zh-TW/plugins/mods/reference#subagents) hook 中設定了模型,Claude Code 會以該模型取代每次叫用的參數。
363
364在兩種情況下,每次叫用參數或 frontmatter 中的家族別名(例如 `opus`)解析為主對話的模型,而不是[別名指向的版本](https://code.claude.com/docs/zh-TW/model-config.md#model-aliases):
365
366* **主對話的模型屬於該家族**:子代理在主對話的確切模型上執行,包括任何 `[1m]` 尾碼,因此它獲得與主對話相同的[擴展上下文](https://code.claude.com/docs/zh-TW/model-config.md#extended-context)視窗。
367* **Claude Code 無法判斷主對話的模型家族,在[Anthropic API 以外的提供者](https://code.claude.com/docs/zh-TW/third-party-integrations.md)上**:這可能發生在 Amazon Bedrock 上的[應用程式推論設定檔 ARN](https://code.claude.com/docs/zh-TW/amazon-bedrock.md#iam-configuration),Claude Code 尚未解析為支援模型。此情況僅涵蓋 `opus` 別名,當您設定 [`ANTHROPIC_DEFAULT_OPUS_MODEL`](https://code.claude.com/docs/zh-TW/model-config#environment-variables) 時不適用,因為 `opus` 然後解析為您設定的模型。
368
369`CLAUDE_CODE_SUBAGENT_MODEL` 中的別名一律解析為別名指向的版本,即使它指定的是主對話的家族。將此變數設定為 `inherit` 等同於不設定它。
370 363
371單獨設定 `CLAUDE_CODE_SUBAGENT_MODEL` 不會改變內建 Explore 和 Plan 子代理執行的模型。若要改變它,請參閱[在一個模型上執行每個子代理](#run-every-subagent-on-one-model)。364單獨設定 `CLAUDE_CODE_SUBAGENT_MODEL` 不會改變內建 Explore 和 Plan 子代理執行的模型。若要改變它,請參閱[在一個模型上執行每個子代理](#run-every-subagent-on-one-model)。
372 365
373在 v2.1.251 之前,`CLAUDE_CODE_SUBAGENT_MODEL` 在此順序中排在第一位,並覆蓋每次叫用參數和 frontmatter,包括 `model: inherit`。366#### 巢狀 subagent 在哪個模型上執行
374 367
375Claude Code 根據您組織的 [`availableModels`](https://code.claude.com/docs/zh-TW/model-config#restrict-model-selection) 允許清單檢查每次叫用參數、frontmatter 和環境變數值。對於被阻止的值,它替換另一個模型:368預設情況下,您定義的[巢狀 subagent](#let-subagents-spawn-their-own-subagents) 會在其父項(即產生它的 subagent)的模型上執行。若要讓巢狀 subagent 在其他模型上執行,請將其 `model` 欄位設定為該模型。
376 369
377* 當被阻止的值是家族別名(例如 `opus`)時,Claude Code 在允許清單允許的該家族的最新版本上執行子代理,遵循與 `/model` 相同的[替換規則和提供者範圍](https://code.claude.com/docs/zh-TW/model-config.md#restrict-model-selection)。在 v2.1.222 之前,Claude Code 也在被阻止的家族別名的繼承模型上執行子代理。370例如,假設您的主對話在 Opus 上執行,並在 Haiku 上啟動一個 reviewer subagent。預設情況下,當 reviewer 產生下列 subagent 時,它們會在 Haiku 而非 Opus 上執行:
378* 對於任何其他被阻止的值,在該替換不操作的提供者上,或當允許清單允許該家族的沒有版本時,Claude Code 改為在繼承模型上執行子代理。如果您設定 `CLAUDE_CODE_SUBAGENT_MODEL`,Claude Code 首先嘗試該模型,在這些相同的規則下。
379 371
380在互動工作階段中,Claude Code 顯示警告,命名請求的模型和子代理執行的模型,用於任一替換。372* 具有 `model: inherit` 或沒有 `model` 欄位的 subagent
373* 內建的 Explore、Plan 和 general-purpose subagent
374* [分叉](#fork-the-current-conversation)
381 375
382若要檢查 subagent 正在執行的模型,請執行 [`/tasks`](https://code.claude.com/docs/zh-TW/commands)。Claude Code 會在 subagent 的列上列出模型,並在有為該 subagent 設定 [effort 等級](https://code.claude.com/docs/zh-TW/model-config.md#adjust-effort-level)時一併顯示。需要 Claude Code v2.1.242 或更新版本。376在 plan mode 中,如果您將工作階段的模型設定為 [`opusplan`](https://code.claude.com/docs/zh-TW/model-config#opusplan-model-setting),這些 subagent 會在 Opus 上執行;如果您將其設定為 `haiku`,則會在 Sonnet 上執行。
383 377
384每次叫用的 `model` 參數也適用於 subagent [被繼續或收到後續訊息](#resume-subagents)時,因此 subagent 會保持在該模型上。378#### 檢查 subagent 的模型
385 379
386從 v2.1.198 開始,子代理也繼承主對話的[擴展思考](https://code.claude.com/docs/zh-TW/model-config.md#extended-thinking)設定:如果思考在您的工作階段中開啟,它對子代理開啟,如果關閉,它保持關閉。沒有每個子代理思考設定。在 v2.1.198 之前,子代理執行時禁用擴展思考,無論主對話的設定如何。380若要檢查 subagent 正在執行的模型,請執行 [`/tasks`](https://code.claude.com/docs/zh-TW/commands)。Claude Code 會在 subagent 的列上列出模型,並在有為該 subagent 設定 [effort 等級](https://code.claude.com/docs/zh-TW/model-config.md#adjust-effort-level)時一併顯示。需要 Claude Code v2.1.242 或更新版本。
387 381
388#### 在一個模型上執行每個子代理382#### 在一個模型上執行每個子代理
389 383
390`CLAUDE_CODE_SUBAGENT_MODEL` 是預設值,因此子代理的定義或 Claude 傳遞的模型仍然優先於它。若要將一個模型應用於每個子代理、[隊友](https://code.claude.com/docs/zh-TW/agent-teams.md#specify-teammates-and-models) 和[工作流代理](https://code.claude.com/docs/zh-TW/workflows.md),也設定 `CLAUDE_CODE_SUBAGENT_MODEL_FORCE` 為 `1`。需要 Claude Code v2.1.257 或更新版本。384若要將同一個模型套用於每個 subagent、[隊員](https://code.claude.com/docs/zh-TW/agent-teams.md#specify-teammates-and-models)和[工作流程 agent](https://code.claude.com/docs/zh-TW/workflows.md),請將 `CLAUDE_CODE_SUBAGENT_MODEL` 設定為該模型,並將 `CLAUDE_CODE_SUBAGENT_MODEL_FORCE` 設定為 `1`。需要 Claude Code v2.1.257 或更新版本。
391
392* 如果您設定兩個變數,子代理在 `CLAUDE_CODE_SUBAGENT_MODEL` 中的模型上執行。
393* 如果您只設定 `CLAUDE_CODE_SUBAGENT_MODEL_FORCE`,subagent 會在主對話的模型上執行,但內建的 Explore subagent 例外,它會在[內建 subagent 中為其列出的模型](#built-in-subagents)上執行。
394 385
395例如,若要在 Haiku 上執行每個子代理,在[設定檔](https://code.claude.com/docs/zh-TW/settings.md)的 `env` 區塊中設定兩個變數:386例如,若要在 Haiku 上執行每個子代理,在[設定檔](https://code.claude.com/docs/zh-TW/settings.md)的 `env` 區塊中設定兩個變數:
396 387
405 396
406若要檢查設定是否生效,在子代理執行時執行 [`/tasks`](https://code.claude.com/docs/zh-TW/commands)。子代理的列顯示它執行的模型。397若要檢查設定是否生效,在子代理執行時執行 [`/tasks`](https://code.claude.com/docs/zh-TW/commands)。子代理的列顯示它執行的模型。
407 398
408當 `CLAUDE_CODE_SUBAGENT_MODEL_FORCE` [開啟](https://code.claude.com/docs/zh-TW/env-vars.md)時,Claude Code 會忽略 subagent 定義中的 `model` 欄位,且 Claude 在啟動 subagent 時無法傳遞模型。以下 subagent 仍會在主對話的模型上執行:399當 `CLAUDE_CODE_SUBAGENT_MODEL_FORCE` [開啟](https://code.claude.com/docs/zh-TW/env-vars.md)時,Claude Code 會忽略 subagent 定義中的 `model` 欄位,且 Claude 在啟動 subagent 時無法傳遞模型。以下 subagent 仍會在其父對話的模型上執行:
409 400
410* [分叉](#fork-the-current-conversation)401* [分叉](#fork-the-current-conversation)
411* [在子代理中執行的技能](https://code.claude.com/docs/zh-TW/skills.md#run-skills-in-a-subagent),具有 `model: inherit`402* [在子代理中執行的技能](https://code.claude.com/docs/zh-TW/skills.md#run-skills-in-a-subagent),具有 `model: inherit`
412 403
404如果您只設定 `CLAUDE_CODE_SUBAGENT_MODEL_FORCE`,subagent 會在主對話的模型上執行,但內建的 Explore subagent 例外,它會在[內建 subagent 中為其列出的模型](#built-in-subagents)上執行。
405
406#### 模型別名選擇哪個版本
407
408預設情況下,具有模型別名的 subagent 會在[該別名指向的版本](https://code.claude.com/docs/zh-TW/model-config.md#model-aliases)上執行。當 `model` 欄位或每次叫用參數中使用家族別名(例如 `opus`)時,subagent 在兩種情況下會在其父對話的模型上執行:
409
410* **相同家族**:例如,如果您的主對話在 `claude-opus-4-7` 上執行,具有 `model: opus` 的 subagent 也會在該版本上執行。若要執行其他版本,請在 `model` 欄位中設定完整模型 ID。
411* **未知家族**:Claude Code 無法判斷父模型的家族,例如使用它[無法查詢](https://code.claude.com/docs/zh-TW/amazon-bedrock.md#iam-configuration)的 Amazon Bedrock ARN 時。此情況僅適用於[Anthropic API 以外之提供者](https://code.claude.com/docs/zh-TW/third-party-integrations.md)上的 `opus` 別名。若要選擇 Opus 版本,請設定 [`ANTHROPIC_DEFAULT_OPUS_MODEL`](https://code.claude.com/docs/zh-TW/model-config#environment-variables)。
412
413#### 當允許清單封鎖 subagent 模型時
414
415如果您組織的 [`availableModels`](https://code.claude.com/docs/zh-TW/model-config#restrict-model-selection) 允許清單封鎖了為 subagent 設定的模型,subagent 會在下列第一個適用的模型上執行:
416
4171. 對於被封鎖的家族別名,在[支援此替換的提供者](https://code.claude.com/docs/zh-TW/model-config.md#restrict-model-selection)上,該家族中允許的最新版本
4182. `CLAUDE_CODE_SUBAGENT_MODEL` 中的模型(如果您有設定),並適用相同的規則
4193. 主對話的模型,或對巢狀 subagent 而言,為產生它的 subagent 的模型
420
421對於互動工作階段中的頂層 subagent,會有警告列出請求的模型及其替代模型。若要執行特定模型,請將被封鎖的值改為允許清單允許的值。
422
423### subagent 中的延伸思考
424
425subagent 會繼承主對話的[延伸思考](https://code.claude.com/docs/zh-TW/model-config.md#extended-thinking)設定。沒有每個 subagent 個別的思考設定。
426
413### 選擇 effort 等級427### 選擇 effort 等級
414 428
415若要讓 subagent 以其自己的 [effort 等級](https://code.claude.com/docs/zh-TW/model-config.md#adjust-effort-level)執行,請在其定義中設定 [`effort`](#supported-frontmatter-fields) 欄位。429若要讓 subagent 以其自己的 [effort 等級](https://code.claude.com/docs/zh-TW/model-config.md#adjust-effort-level)執行,請在其定義中設定 [`effort`](#supported-frontmatter-fields) 欄位。
426 440
427#### 可用工具441#### 可用工具
428 442
429子代理繼承[內建工具](https://code.claude.com/docs/zh-TW/tools-reference.md)和主對話中可用的 MCP 工具,由兩個篩選器縮小:第一個從每個子代理移除工具的簡短列表,第二個減少在[背景中](#run-subagents-in-foreground-or-background)執行的子代理的內建工具集,這是預設值。在 macOS、Linux 和 WSL 上,當主對話沒有時,子代理也可以接收 Glob 和 Grep 工具,如[Glob 工具行為](https://code.claude.com/docs/zh-TW/tools-reference.md#glob-tool-behavior)下所述。[分叉](#fork-the-current-conversation)跳過兩個篩選器並接收主對話的確切工具池。第一個篩選器移除這些工具,即使在 `tools` 欄位中列出:443subagent 會繼承主對話中可用的[內建工具](https://code.claude.com/docs/zh-TW/tools-reference.md)和 MCP 工具,並經過兩個篩選器縮小範圍。第一個篩選器會從每個 subagent 移除一小份工具清單。第二個篩選器會縮減在[背景中](#run-subagents-in-foreground-or-background)執行之 subagent 的內建工具集,這是預設情況。
444
445在 macOS、Linux 和 WSL 上,當主對話沒有 Glob 和 Grep 工具時,subagent 也可以取得它們,如 [Glob 工具行為](https://code.claude.com/docs/zh-TW/tools-reference.md#glob-tool-behavior)中所述。[分叉](#fork-the-current-conversation)會跳過兩個篩選器,並取得其父對話完全相同的工具池。第一個篩選器會移除這些工具,即使它們列在 `tools` 欄位中:
430 446
431* `Agent`,當子代理在[深度限制](#let-subagents-spawn-their-own-subagents)時;在[分叉](#fork-the-current-conversation)中工具保持列出但返回錯誤而不是生成447* `Agent`,當子代理在[深度限制](#let-subagents-spawn-their-own-subagents)時;在[分叉](#fork-the-current-conversation)中工具保持列出但返回錯誤而不是生成
432* `AskUserQuestion`448* `AskUserQuestion`
1077 1093
1078使用此值,您的 subagents 可以委派給自己的第二層,該第二層無法進一步委派。設定 `1` 以關閉巢狀。1094使用此值,您的 subagents 可以委派給自己的第二層,該第二層無法進一步委派。設定 `1` 以關閉巢狀。
1079 1095
1080巢狀 subagent 的設定方式與頂層 subagent 相同,並從相同的 [範圍](#choose-the-subagent-scope) 解析。若要在巢狀開啟時防止某個 subagent 產生 subagents,例如應保持唯讀的審查者,請從其 [`tools`](#available-tools) 列表中省略 `Agent` 或將其新增到 `disallowedTools`。1096在與頂層 subagent 相同的 [範圍](#choose-the-subagent-scope) 中定義巢狀 subagent。預設情況下,您定義的巢狀 subagent 會在 [進行產生的 subagent 的模型](#which-model-a-nested-subagent-runs-on) 上執行。若要在巢狀開啟時防止某個 subagent 產生 subagents,例如應保持唯讀的審查者,請從其 [`tools`](#available-tools) 列表中省略 `Agent` 或將其新增到 `disallowedTools`。
1081 1097
1082在終端機中,Claude Code 會在提示輸入下方的 subagent 面板中將巢狀 subagents 顯示為樹狀結構,並用 `(+N)` 計數標記面板中仍有後代的每一列。開啟一列以查看該 subagent 的同級和直接子代,以及返回到 `main` 的路徑。1098在終端機中,Claude Code 會在提示輸入下方的 subagent 面板中將巢狀 subagents 顯示為樹狀結構,並用 `(+N)` 計數標記面板中仍有後代的每一列。開啟一列以查看該 subagent 的同級和直接子代,以及返回到 `main` 的路徑。
1083 1099
1221>1237>
1222> 當[agent 檢視已關閉](https://code.claude.com/docs/zh-TW/agent-view.md#turn-off-agent-view)時,`/subtask` 無法使用,`/fork` 會改為啟動 forked subagent;否則 `/fork` 會將整個工作階段複製到新的[背景工作階段](https://code.claude.com/docs/zh-TW/agent-view.md#from-inside-a-session)。1238> 當[agent 檢視已關閉](https://code.claude.com/docs/zh-TW/agent-view.md#turn-off-agent-view)時,`/subtask` 無法使用,`/fork` 會改為啟動 forked subagent;否則 `/fork` 會將整個工作階段複製到新的[背景工作階段](https://code.claude.com/docs/zh-TW/agent-view.md#from-inside-a-session)。
1223 1239
1224Fork 是一個 subagent,它繼承到目前為止的整個對話,而不是從頭開始。這會放棄 subagents 否則提供的輸入隔離:fork 看到與主工作階段相同的系統提示、工具、模型和訊息歷史記錄,因此您可以將側面任務交給它,而無需重新解釋情況。Fork 自己的工具呼叫仍然保持在您的對話之外,只有其最終結果返回,因此您的主要上下文視窗保持乾淨。當任何其他 subagent 需要太多背景才能有用時,或當您想從相同的起點並行嘗試多種方法時,使用 fork。1240Fork 是一個 subagent,它繼承到目前為止的整個對話,而不是從頭開始。當任何其他 subagent 需要太多背景資訊才能發揮作用時,或當您想從相同的起點並行嘗試多種方法時,請使用 fork。
1241
1242* **輸入**:fork 看到的系統提示詞、工具、[模型](#which-model-a-nested-subagent-runs-on)和訊息歷史記錄與其父對話相同
1243* **輸出**:fork 自己的工具呼叫會保持在其父對話之外,只有其最終結果會傳回
1225 1244
1226在 fork 模式開啟期間(預設即為開啟),Claude 可以自行啟動 fork。若要停止 fork,請參閱[關閉 fork 模式](#turn-fork-mode-on-or-off)。1245在 fork 模式開啟期間(預設即為開啟),Claude 可以自行啟動 fork。若要停止 fork,請參閱[關閉 fork 模式](#turn-fork-mode-on-or-off)。
1227 1246
1257 1276
1258### Forks 與其他 subagents 的區別1277### Forks 與其他 subagents 的區別
1259 1278
1260Fork 繼承主工作階段在產生時擁有的所有內容。任何其他 subagent 從其定義開始新鮮。
1261
1262| | Fork | 非 fork subagent |1279| | Fork | 非 fork subagent |
1263| :- | :- | :- |1280| :- | :- | :- |
1264| Context | 完整對話歷史記錄 | 新鮮上下文,帶有您傳遞的提示 |1281| Context | 完整對話歷史記錄 | 新鮮上下文,帶有您傳遞的提示 |
1265| 系統提示和工具 | 與主工作階段相同 | 來自 subagent 的[定義檔](#write-subagent-files),[針對背景執行進行篩選](#available-tools) |1282| 系統提示詞和工具 | 與父對話相同 | 來自 subagent 的[定義檔](#write-subagent-files),[針對背景執行進行篩選](#available-tools) |
1266| Model | 與主工作階段相同 | 來自 subagent 的 `model` 欄位 |1283| 模型 | 與[父對話](#which-model-a-nested-subagent-runs-on)相同 | 遵循 [subagent 模型順序](#choose-a-model) |
1267| Prompt cache | 與主工作階段共享 | 單獨的快取 |1284| 提示快取 | 與父對話共享 | 單獨的快取 |
1268 1285
1269因為 fork 的系統提示詞和工具定義與父級相同,其第一個請求重複使用父級的[提示快取](https://code.claude.com/docs/zh-TW/prompt-caching.md#subagents-and-the-cache)。由於這種重複使用,對於需要相同上下文的任務,fork 的成本比新的 subagent 更低。1286因為 fork 的系統提示詞和工具定義與父級相同,其第一個請求重複使用父級的[提示快取](https://code.claude.com/docs/zh-TW/prompt-caching.md#subagents-and-the-cache)。由於這種重複使用,對於需要相同上下文的任務,fork 的成本比新的 subagent 更低。
1270 1287