@deepseek-ai/dsh-tool-subagent 0.2.1-alpha.1 → 0.2.1-alpha.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.i18n.yaml CHANGED
@@ -9,20 +9,23 @@
9
9
  en: 686fb5136bef0a3b
10
10
  zh: d25d6569174a01b5
11
11
  /deepseek-ai-dsh-tool-subagent/summary:
12
- en: 04da983479776bfa
13
- zh: 17b955b0390dc448
12
+ en: c09d40329253a9d8
13
+ zh: 91c1bbe5557bdda9
14
14
  /deepseek-ai-dsh-tool-subagent/table-of-contents:
15
15
  en: d152484eb41ac6b4
16
16
  zh: 09388d293f9be9cb
17
17
  /deepseek-ai-dsh-tool-subagent/use-this-package:
18
- en: 3248a28bba2ef809
19
- zh: 807cc32c49fcb0cb
18
+ en: 93f1701f5209ecb5
19
+ zh: 6310fd012400aead
20
20
  /deepseek-ai-dsh-tool-subagent/use-this-package/minimal-configuration:
21
- en: a8809e00166c7f2f
22
- zh: 261432232638c445
23
- /deepseek-ai-dsh-tool-subagent/use-this-package/foreground-and-background-modes:
24
- en: 8e7319bc2887ae5c
25
- zh: 87d5abdfbe7562df
21
+ en: 6a82283a51912841
22
+ zh: 35728acc16931bb4
23
+ /deepseek-ai-dsh-tool-subagent/use-this-package/managed-delegation:
24
+ en: bb715d037cde14bd
25
+ zh: a88e98c07115fbd1
26
+ /deepseek-ai-dsh-tool-subagent/use-this-package/selecting-a-child-preset:
27
+ en: 1950ef92bab0f46e
28
+ zh: 593f5f64ed9b5631
26
29
  /deepseek-ai-dsh-tool-subagent/use-this-package/selecting-a-child-llm:
27
30
  en: 0d37e3b3957515e4
28
31
  zh: ea1a94b2f29e7d9a
@@ -30,23 +33,23 @@
30
33
  en: 6ce5f749256a7e6c
31
34
  zh: a4f2adb04a70d9cf
32
35
  /deepseek-ai-dsh-tool-subagent/understand-the-implementation/design-concept:
33
- en: 5ceacfed4ea0c648
34
- zh: 005284534923d854
35
- /deepseek-ai-dsh-tool-subagent/understand-the-implementation/foreground-settlement:
36
- en: ccb36af6884ec89f
37
- zh: 41e9aa6d3cd75a41
38
- /deepseek-ai-dsh-tool-subagent/understand-the-implementation/background-routes:
39
- en: dfd6306019a63bea
40
- zh: 5055b66e19885e8d
36
+ en: e9df1e3d504a3625
37
+ zh: 4eca7bb1bc6def62
38
+ /deepseek-ai-dsh-tool-subagent/understand-the-implementation/activation-ownership:
39
+ en: ef692c4d17290920
40
+ zh: b1d0d3dab011e2cd
41
+ /deepseek-ai-dsh-tool-subagent/understand-the-implementation/result-acknowledgement:
42
+ en: 3cdb913209febc42
43
+ zh: ea6ebfbe9d21fb3e
41
44
  /deepseek-ai-dsh-tool-subagent/understand-the-implementation/context-sensitive-wording:
42
45
  en: 1733728ac5aa6bb0
43
46
  zh: 341ffc6e21a289af
44
47
  /deepseek-ai-dsh-tool-subagent/understand-the-implementation/source-map:
45
- en: 1f52c5f5c7caf04a
46
- zh: dba288fd0cf51e5d
48
+ en: ce5147d9e1b2849c
49
+ zh: 67a707f05b2b7dc5
47
50
  /deepseek-ai-dsh-tool-subagent/further-exploration:
48
- en: f9302b0380df26ac
49
- zh: 95f1a0f43fa8ba80
51
+ en: fa3c9a967b636afb
52
+ zh: a9ce930a9766d5cb
50
53
  /deepseek-ai-dsh-tool-subagent/model-experience:
51
54
  en: 215e7ba838619b7b
52
55
  zh: a311da3843709f90
@@ -54,11 +57,11 @@
54
57
  en: e4c7376d4f29dbd5
55
58
  zh: 6b7a9eaf69c9ea53
56
59
  /deepseek-ai-dsh-tool-subagent/model-experience/tool-schema/what-the-model-sees:
57
- en: 5d88050d9496b928
58
- zh: 1278b3b7da4335db
60
+ en: cdaa88b47ba03e23
61
+ zh: 2b7429db53e0aea7
59
62
  /deepseek-ai-dsh-tool-subagent/model-experience/tool-schema/token-effect:
60
- en: 1aa53b7a4c24cc25
61
- zh: bebd5c5ce6443259
63
+ en: 0c6cf11d65ba83dc
64
+ zh: 6e2b2e64bf1f18f2
62
65
  /deepseek-ai-dsh-tool-subagent/model-experience/tool-schema/kv-cache-effect:
63
66
  en: 46f736c6c389052a
64
67
  zh: a7765541030e9104
@@ -78,44 +81,59 @@
78
81
  en: cf78b9dd5596495f
79
82
  zh: bd44560f8c2435e8
80
83
  /deepseek-ai-dsh-tool-subagent/model-experience/system-prompt/what-the-model-sees:
81
- en: 875f8a89292dde21
82
- zh: 670f911b0a149690
84
+ en: 64a1c2edb455950c
85
+ zh: 15d280ff2c918672
83
86
  /deepseek-ai-dsh-tool-subagent/model-experience/system-prompt/what-the-model-sees/tool-guidance-section:
84
87
  en: 82b3cd08b3961c98
85
88
  zh: bdc2a34bcea16cac
86
89
  /deepseek-ai-dsh-tool-subagent/model-experience/system-prompt/token-effect:
87
- en: ed03868e8f551001
88
- zh: 53c10b979a48cf9b
90
+ en: 58ee76659f75c73e
91
+ zh: 726c5b789e96677c
89
92
  /deepseek-ai-dsh-tool-subagent/model-experience/system-prompt/kv-cache-effect:
90
- en: 5f2491d0ee8f440c
91
- zh: 14c06b9fe7096e09
92
- /deepseek-ai-dsh-tool-subagent/model-experience/foreground-result:
93
- en: d83f1f25a3719c54
94
- zh: 445ca808e28dc936
95
- /deepseek-ai-dsh-tool-subagent/model-experience/foreground-result/what-the-model-sees:
96
- en: 7e5d19839fa69495
97
- zh: 0e7ff0d92571ec60
98
- /deepseek-ai-dsh-tool-subagent/model-experience/foreground-result/token-effect:
99
- en: 995810727b29f85f
100
- zh: 4ede7b437091d6ee
101
- /deepseek-ai-dsh-tool-subagent/model-experience/foreground-result/kv-cache-effect:
93
+ en: eaee0378bf87c980
94
+ zh: 2783a481ee349f1e
95
+ /deepseek-ai-dsh-tool-subagent/model-experience/runtime-depth-context:
96
+ en: 1e58e87365d88e45
97
+ zh: 7648aa3b3865057f
98
+ /deepseek-ai-dsh-tool-subagent/model-experience/runtime-depth-context/what-the-model-sees:
99
+ en: fde048c427103086
100
+ zh: 6614730cc00f02e4
101
+ /deepseek-ai-dsh-tool-subagent/model-experience/runtime-depth-context/what-the-model-sees/depth-limit-notice:
102
+ en: 0ae8dbcee66d0cd6
103
+ zh: 5a69283739ae59e0
104
+ /deepseek-ai-dsh-tool-subagent/model-experience/runtime-depth-context/token-effect:
105
+ en: dae9cd59b9649b5a
106
+ zh: 8bb35289ebaeaf7b
107
+ /deepseek-ai-dsh-tool-subagent/model-experience/runtime-depth-context/kv-cache-effect:
108
+ en: 9e6e8bc993992908
109
+ zh: 4de1e9d85ab3bfca
110
+ /deepseek-ai-dsh-tool-subagent/model-experience/start-result:
111
+ en: 45854c8f4da73af7
112
+ zh: 7a9803ca8c03c40f
113
+ /deepseek-ai-dsh-tool-subagent/model-experience/start-result/what-the-model-sees:
114
+ en: 15772cb4c28bf562
115
+ zh: 7452e7a7114d587c
116
+ /deepseek-ai-dsh-tool-subagent/model-experience/start-result/token-effect:
117
+ en: 807d71626c81c858
118
+ zh: ba4b85709fa46c84
119
+ /deepseek-ai-dsh-tool-subagent/model-experience/start-result/kv-cache-effect:
102
120
  en: f5d5f97a153f7c70
103
121
  zh: 3d6bc05b9eadfbc2
104
- /deepseek-ai-dsh-tool-subagent/model-experience/background-result:
105
- en: 3f23f9211197b0b9
106
- zh: 8cff3c78249b66ff
107
- /deepseek-ai-dsh-tool-subagent/model-experience/background-result/what-the-model-sees:
108
- en: d2ba2d8a3e88478d
109
- zh: dee910d1d271f75c
110
- /deepseek-ai-dsh-tool-subagent/model-experience/background-result/token-effect:
111
- en: 3c67cdb1cbf53647
112
- zh: bfed5f2945a79c9d
113
- /deepseek-ai-dsh-tool-subagent/model-experience/background-result/kv-cache-effect:
122
+ /deepseek-ai-dsh-tool-subagent/model-experience/completion-delivery:
123
+ en: b6ed0eef154aa546
124
+ zh: 34160884aa30ffec
125
+ /deepseek-ai-dsh-tool-subagent/model-experience/completion-delivery/what-the-model-sees:
126
+ en: 8f5e3a083eb7f807
127
+ zh: 6bfc2b38f49a6f79
128
+ /deepseek-ai-dsh-tool-subagent/model-experience/completion-delivery/token-effect:
129
+ en: 615348e27c0c9bc0
130
+ zh: 1655fdbc42932909
131
+ /deepseek-ai-dsh-tool-subagent/model-experience/completion-delivery/kv-cache-effect:
114
132
  en: f5d5f97a153f7c70
115
133
  zh: 3d6bc05b9eadfbc2
116
134
  /deepseek-ai-dsh-tool-subagent/known-limitations-and-deferred-work:
117
- en: 30b202766dae2b9d
118
- zh: e2654c858b5a2378
135
+ en: c17c91a188bb0d8c
136
+ zh: d77c1ffcf1eca737
119
137
  /deepseek-ai-dsh-tool-subagent/known-limitations-and-deferred-work/dev-note:
120
138
  en: e67f633dc6fe7773
121
139
  zh: 3bb0c20c93f16f98
package/README.md CHANGED
@@ -9,7 +9,7 @@ English | [中文](README.zh.md)
9
9
 
10
10
  ## Summary
11
11
 
12
- Use this package to give an agent a named tool that delegates work to a configured child-agent backend. In `one-shot` mode, calls wait for the child by default; in `continuable` mode, they start a persistent child in the background and return an id for later messages. Supported backends can also expose approved child LLM providers, models, and reasoning effort for selection. Each instance can set child persona, tool access, and depth limits, while failed runs return errors instead of partial success.
12
+ Use this package to give an agent a named tool that delegates work to a configured backend. Every call starts a managed activation and returns a child id; the runtime owns completion notices and cleanup. Local children support messages and restoration, while external backends execute one task and return their final answer through the completion notice. Supported backends can expose approved child LLM routes. Each instance can select a child preset and depth limit.
13
13
 
14
14
  ## Table of Contents
15
15
 
@@ -25,6 +25,8 @@ Use this package to give an agent a named tool that delegates work to a configur
25
25
  <a id="use-this-package"></a>
26
26
  ## Use this package
27
27
 
28
+ The optional `cwd` argument selects the child's initial working directory. Relative paths resolve against the caller's current directory; omission inherits it. Existing children retain their own directories when the caller changes directory.
29
+
28
30
  Mount one instance per delegation target, each with a distinct `toolName`. The tool exists exactly while its provider does, so sibling load order and provider reloads never strand it.
29
31
 
30
32
  ### Minimal configuration
@@ -45,22 +47,29 @@ Load the subagent service, an in-process or remote backend, and this tool; then
45
47
  | `provider` | required | Provider name on `ctx.subagents` (e.g. `spawn`, `fork`, `acp`) |
46
48
  | `toolName` | `subagent` | Model-facing tool name; distinct for every loaded instance |
47
49
  | `modelSelectionSettings` | `false` | Sample the Host's exact-route authorization preference for each top-level Session; a standing preset observes matching Sessions, while direct Agent setup passes its Session explicitly; requires provider `agentOptions` support |
48
- | `enableRunInBackground` | `true` | Expose `run_in_background`; disabling also rejects forced background calls |
49
- | `backgroundMode` | `one-shot` | Background policy: `one-shot` defaults calls to foreground; `continuable` defaults them to background and requires the provider's `prepareContinuable` capability |
50
50
  | `agentOptions` | — | Configured child `provider`, `model`, adapter-owned `reasoningEffort`, and positive `maxTokens` defaults; requires provider `agentOptions` support and overlays any provider-owned route defaults |
51
- | `persona` | — | Per-child persona; requires the provider's `persona` capability |
52
- | `toolFilter` | — | Per-child global-tool restriction; requires the `toolFilter` capability |
51
+ | `agentPreset` | — | Default independent child preset id; requires in-process spawn |
52
+ | `allowedAgentPresets` | — | Non-empty preset-id allowlist exposed as the model's optional `agent_preset` enum; must include `agentPreset` when both are set |
53
53
  | `maxDepth` | Host setting (`1`) | Absolute delegation-depth cap (`0` forbids delegation); `'provider-managed'` sends no cap to an out-of-process provider |
54
54
 
55
55
  The generated [configuration catalog](../../../docs/config-catalog.md#deepseek-aidsh-tool-subagent) is the exhaustive source for every accepted field and its JSDoc.
56
56
 
57
- ### Foreground and background modes
57
+ ### Managed delegation
58
+
59
+ Every call returns `started subagent <childId>` after the runtime accepts the child. It does not wait for the child's result. The activation owns the work independently of the completed tool call; the runtime sends a completion notice and releases execution resources.
60
+
61
+ Every backend’s completion notice carries its final answer. Local Spawn and Fork children can also send messages, accept more work through `send_message` while active, or resume after settling. Codex, Claude Code, ACP, and DSH SDK backends do not accept follow-up messages.
62
+
63
+ `maxDepth` caps recursion (`0` forbids delegation); omission reads the current Host `subagent.maxDepth` setting, initially `1`, at each delegation. A numeric depth requires a provider with the `depthLimit` capability; `'provider-managed'` leaves the budget to an out-of-process provider. The tool stays visible at the cap; each attempted start checks the calling agent's current depth and rejects with an errored result.
64
+
65
+ <a id="selecting-a-child-preset"></a>
66
+ ### Selecting a child preset
58
67
 
59
- Under `one-shot` policy, an omitted `run_in_background` waits in the foreground and returns the child's final text; `run_in_background: true` starts a plain parent-owned background job and returns `started background subagent job <id>`, collected with `job_output` and stopped with `job_kill`.
68
+ Set `agentPreset` to give every child an independent preset by default. Set `allowedAgentPresets` to let the model choose an id through `agent_preset`; without this allowlist, the model cannot override the configured choice. Only in-process spawn supports these options; fork and external backends reject them.
60
69
 
61
- Under `continuable` policy, an omitted or `true` `run_in_background` starts a durable child and returns `started subagent <childId>` without waiting for a result; the runtime delivers one settlement notice when the child's Activation ends, and the optional `send_message` tool sends it more work. Set `run_in_background: false` to wait for the result in the foreground.
70
+ The configured default and allowlist must name declared presets. A tool inside a preset checks these ids and reads their descriptions during Agent initialization; a Host-mounted tool performs this check when it loads. This check does not activate candidate presets. Activation failures reject the selected preset when the child is composed. Without either selection field, the tool does not require the preset service. An omitted model choice uses the configured `agentPreset`, or joins the parent's current preset revision when no default is configured. Any explicit id mounts the currently available revision, even when it matches the parent's id.
62
71
 
63
- `maxDepth` caps recursion (`0` forbids delegation); omission reads the current Host `subagent.maxDepth` setting, initially `1`, at each delegation. A numeric depth requires a provider with the `depthLimit` capability; `'provider-managed'` leaves the budget to an out-of-process provider. `persona` and `toolFilter` configure every child when the provider supports them, and the tool stays visible at the cap — each attempted start checks the calling agent's current depth and rejects with an errored result.
72
+ Compose persona and tools in the [preset plugin list](../../preset/agent-preset-registry/README.md). Tool configuration containing `persona` or `toolFilter` fails at load with a migration error. Local children use the shared [preset restoration rules](../subagent/README.md#restoring-child-composition).
64
73
 
65
74
  ### Selecting a child LLM
66
75
 
@@ -80,15 +89,15 @@ This section explains how the tool mirrors provider lifecycle and settles runs;
80
89
 
81
90
  ### Design concept
82
91
 
83
- One instance is one provider plus one tool name. The plugin mirrors provider lifecycle: it registers the tool when the named provider appears and disposes it when the provider leaves, so sibling load order and HMR replacement cannot strand a dangling tool. Direct Agent setup passes its unpublished Session explicitly and awaits installation before publication. A settings-backed standing preset receives each matching Agent through `agent/created`, selects policy from its Session, and awaits installation through its Context; installation failure rejects creation. A numeric `maxDepth` or configured LLM selection the provider cannot enforce fails the mount instead of the first delegation. At most one instance in a tool scope may own model selection because `list_subagent_models` has a global name.
92
+ One instance is one provider plus one tool name. The plugin mirrors provider lifecycle: it registers the tool when the named provider appears and disposes it when the provider leaves, so sibling load order and HMR replacement cannot strand a dangling tool. Direct Agent setup passes its unpublished Session explicitly and awaits installation before publication. A standing preset with model or preset selection receives each matching Agent through `agent/created`, validates preset references, selects any model policy from its Session, and awaits installation through its Context; installation failure rejects creation. A numeric `maxDepth` or configured LLM selection the provider cannot enforce fails the mount instead of the first delegation. At most one instance in a tool scope may own model selection because `list_subagent_models` has a global name.
84
93
 
85
- ### Foreground settlement
94
+ ### Activation ownership
86
95
 
87
- A foreground call awaits `run.result`, maps every non-completed stop reason to an error headline, appends the provider diagnostic and any preserved partial assistant text, and always awaits `run.dispose()` before returning; when result collection and disposal both reject, the errored result preserves both failures.
96
+ The tool calls `ctx.subagents.startActivation()` with parent delivery selected. The runtime owns startup cancellation, execution, outcome reporting, and cleanup. A startup failure is an errored tool result; failures after publication arrive through the completion notice, with diagnostics and partial output preserved by the runtime.
88
97
 
89
- ### Background routes
98
+ ### Result acknowledgement
90
99
 
91
- One-shot background registers a plain parent-owned Task whose done channel settles the start and keeps the stop reason and optional provider diagnostic in its detail. Continuable background calls `ctx.subagents.startContinuable()`, which resolves at inbox acceptance: the child owns its own turns from there, so the call neither waits for nor collects a result.
100
+ The canonical tool result is `{ kind: 'activation', subagentId }`. It contains no execution Promise or final output; programmatic consumers that need to await results use the subagent service directly.
92
101
 
93
102
  ### Context-sensitive wording
94
103
 
@@ -98,7 +107,8 @@ The tool's description derives from `provider.inheritsParentContext`: a fresh ch
98
107
 
99
108
  | File | Role |
100
109
  |---|---|
101
- | [`src/index.ts`](src/index.ts) | Tool registration, lifecycle mirroring, mode resolution, result settlement |
110
+ | [`src/index.ts`](src/index.ts) | Tool registration, provider lifecycle mirroring, activation requests |
111
+ | [`src/preset-selection.ts`](src/preset-selection.ts) | Configured preset validation, model allowlist, and description guidance |
102
112
  | [`src/model-selection.ts`](src/model-selection.ts) | Request/config merge and live LLM route preflight |
103
113
  | [`src/model-selection-settings.ts`](src/model-selection-settings.ts) | Host-owned opt-in setting sampled for new Sessions |
104
114
  | [`src/model-selection-state.ts`](src/model-selection-state.ts) | Session event that records and inherits the sampled decision |
@@ -113,12 +123,11 @@ The tool's description derives from `provider.inheritsParentContext`: a fresh ch
113
123
 
114
124
  Read these pages when the package-level contract is not enough; they move from the tool's runtime behavior to the seam it delegates over and the adjacent child tools.
115
125
 
116
- - [Subagent subsystem](../../../docs/subsystems/subagent.md) — providers, one-shot start requests, continuable children and activations.
126
+ - [Subagent subsystem](../../../docs/subsystems/subagent.md) — providers, activations, results, and continuation.
117
127
  - [dsh-tool-subagent-control](../tool-subagent-control/README.md) — messaging, interrupt, and listing tools for continuable children.
118
- - [Generated tool catalog](../../../docs/tool-catalog.md#deepseek-aidsh-tool-subagent) — the default schema and per-mode wording.
128
+ - [Generated tool catalog](../../../docs/tool-catalog.md#deepseek-aidsh-tool-subagent) — the default schema and backend-specific wording.
119
129
  - [Generated configuration catalog](../../../docs/config-catalog.md#deepseek-aidsh-tool-subagent) — every accepted config field.
120
- - [Background-first continuable delegation](../../../.agents/notes/archived/feature/2026-08-11-background-first-continuable-delegation.md) — why continuable work defaults to background.
121
- - [historical Model-selected subagent routes](../../../.agents/notes/archived/feature/2026-08-18-model-selected-subagent-routes.md) — selection policy, inheritance, discovery, and the fork restriction.
130
+ - [Historical model-selected subagent routes](../../../.agents/notes/archived/feature/2026-08-18-model-selected-subagent-routes.md) — selection policy, inheritance, discovery, and the fork restriction.
122
131
 
123
132
  -----
124
133
 
@@ -129,11 +138,11 @@ Read these pages when the package-level contract is not enough; they move from t
129
138
 
130
139
  #### What the model sees
131
140
 
132
- The delegation description uses `running` and `inactive` for follow-up availability; `inactive` does not imply a task result. The generated default [`subagent` schema](../../../docs/tool-catalog.md#deepseek-aidsh-tool-subagent) under this instance's configured name while its provider exists. An enabled Session policy adds `provider`, `model`, and `reasoning_effort` plus inheritance and selection guidance; the provider must support `agentOptions`. Provider context inheritance changes the tool and prompt descriptions. Enabled background mode adds `run_in_background`: continuable mode documents its `true` default, runtime settlement notice, and explicit foreground override, while one-shot mode documents its `false` default and the job id collected with `job_output` or stopped with `job_kill`. While the tool is visible in an assembly's scope, a `tool:<toolName>` system-prompt section tells the model to start independent continuable delegations together, keep working while they run, and choose foreground only when its next action depends on the result; a tool restriction removes both its schema and this guidance.
141
+ The generated default [`subagent` schema](../../../docs/tool-catalog.md#deepseek-aidsh-tool-subagent) appears under the configured tool name while its provider exists. An enabled Session policy adds `provider`, `model`, and `reasoning_effort` plus route guidance; the backend must support `agentOptions`. `allowedAgentPresets` adds the `agent_preset` enum and guidance from the presets' display descriptions. Context inheritance and continuation support determine the task and follow-up descriptions. A tool restriction removes both the schema and its `tool:<toolName>` guidance section.
133
142
 
134
143
  #### Token effect
135
144
 
136
- Fixed schema cost per parent request; model selection adds three parameters. Each provider instance adds one schema, and each continuable instance adds one short system-prompt section.
145
+ Fixed schema cost per parent request; LLM selection adds three parameters, while preset selection adds one enum parameter and preset descriptions. Each tool instance adds one schema and one short system-prompt section.
137
146
 
138
147
  #### KV Cache effect
139
148
 
@@ -157,45 +166,65 @@ The schema is prefix-stable across adapter registration and catalog changes. Eac
157
166
 
158
167
  #### What the model sees
159
168
 
160
- When `enableRunInBackground` and `backgroundMode: continuable` are both set, the model additionally reads a `tool:<toolName>` system-prompt section telling it to start independent continuable delegations together and keep working while they run. With the default tool name `subagent`, the section text is:
169
+ Visible delegation tools share one guidance paragraph, listing tools in name order and instructing the model to start independent delegations together and keep working while they run, and to end its turn instead of sleeping or polling when only waiting for their results remains. Hidden or unavailable tools are omitted; no guidance appears when none are visible. With both `subagent` and `subagent_fork` visible, the text is:
161
170
 
162
171
  ##### Tool-guidance section
163
172
 
164
173
  ```markdown
165
- Start independent subagent delegations together in one assistant message and continue useful work while they run.
174
+ Start independent delegations with `subagent` or `subagent_fork` together in one assistant message and continue useful work while they run. When only waiting for their results remains, end your turn instead of sleeping or polling; the next result starts a new turn.
175
+ ```
176
+
177
+ #### Token effect
178
+
179
+ At most one short delegation paragraph per parent request, listing the tool names visible to that request.
180
+
181
+ #### KV Cache effect
182
+
183
+ Prefix-stable while the visible tool names are unchanged; adding or removing a visible tool changes the paragraph.
184
+
185
+ ### Runtime depth context
186
+
187
+ #### What the model sees
188
+
189
+ When the calling agent reaches or exceeds a visible tool's effective numeric depth cap, an optional runtime-context snapshot tells it to do the work directly. The cap is resolved again at each request, including after settings changes or session resume. Hidden tools and `provider-managed` limits contribute no depth text. For a child at depth one with a cap of one:
190
+
191
+ ##### Depth-limit notice
192
+
193
+ ```markdown
194
+ Delegation depth for `subagent`: current 1, maximum 1, remaining levels 0. Do not call `subagent` at this depth; carry out the work directly.
166
195
  ```
167
196
 
168
197
  #### Token effect
169
198
 
170
- One short fixed section per continuable instance, paid on every parent request while the tool is in scope.
199
+ One short contribution per capped tool joins the user-role runtime-context snapshot. Unchanged snapshots are not appended again; agents below the cap receive no additional text. `includeRuntimeContext: false` suppresses this notice without changing runtime depth enforcement.
171
200
 
172
201
  #### KV Cache effect
173
202
 
174
- Prefix-stable while the section text and tool presence are unchanged; removing the tool or changing the section establishes a different parent prefix.
203
+ Depth changes do not alter the system prompt or tool schemas. Updated runtime context appends after existing history; the provider still enforces the cap if the model attempts delegation.
175
204
 
176
- ### Foreground result
205
+ ### Start result
177
206
 
178
207
  #### What the model sees
179
208
 
180
- The call retains the description and prompt. Success contains only the child's final text; other outcomes become `Error: <stop reason>`, followed by a safe provider diagnostic when present and then any partial assistant text. Intermediate child steps stay out of the parent.
209
+ The call retains the task description and prompt. Success returns `started subagent <childId>`; startup rejection returns an error. Child execution details are delivered separately from this acknowledgement.
181
210
 
182
211
  #### Token effect
183
212
 
184
- The prompt and result remain in parent history until compaction; child working context remains in the child.
213
+ The prompt and acknowledgement remain in parent history until compaction; child working context remains in the child.
185
214
 
186
215
  #### KV Cache effect
187
216
 
188
217
  Append-only; newly visible content follows the reusable request prefix and does not invalidate existing KV-cache entries.
189
218
 
190
- ### Background result
219
+ ### Completion delivery
191
220
 
192
221
  #### What the model sees
193
222
 
194
- Start returns exactly `started subagent <childId>` in configured continuable mode, or `started background subagent job <id>` in configured one-shot mode. In one-shot mode the generic task surface provides later status, final output, cancellation responses, and notices; failed status detail includes the provider diagnostic when the result supplied one. In continuable mode this tool returns no result of its own: the child's settlement reaches the parent as a service-owned notice, an independently loaded `send_message` tool delivers follow-ups, and the child's transcript by its id is the source of its detailed output.
223
+ Answer delivery follows the managed delegation rules above. The returned child id identifies subsequent control and catalog operations; only backends with continuation support accept follow-up messages.
195
224
 
196
225
  #### Token effect
197
226
 
198
- The acknowledgement is retained; a one-shot final output enters parent history only when collected or injected, while a continuable child's output never returns through this tool — its settlement notice arrives independently of any tool result.
227
+ Messages and completion notices append to parent history independently of the start acknowledgement. The tool result itself contains no final output.
199
228
 
200
229
  #### KV Cache effect
201
230
 
@@ -208,10 +237,9 @@ Append-only; newly visible content follows the reusable request prefix and does
208
237
 
209
238
  These limits define what this tool does not return or enforce; they are current package constraints.
210
239
 
211
- - **Background runs expose no result through this tool** — a one-shot task's final output is collected through the generic task surface, and a continuable child's output stays in its own session, read by its subagent id. The settlement notice states how that child ended and carries nonempty text from its final assistant output, but it is not this call's return value and cannot be awaited here.
212
- - **Duplicate names across waiting one-shot instances are detected late** (`TODO(subagent-dup-toolname)`) — continuable instances reserve their prompt-section name during plugin application, but preventing provider-registration rollback for waiting one-shot instances requires a registry of intended names.
240
+ - **This tool does not wait for results** — use the completion notice or child messages. Programmatic result waiting belongs to the subagent service.
213
241
  - **Shipped fork tools cannot select a child LLM route** — they inherit the parent's provider and model to keep the copied conversation prefix eligible for KV Cache reuse. Re-enable selection only when route changes preserve reuse or expose a bounded recomputation cost.
214
- - **Non-routing child policy is fixed per instance** — another persona, tool filter, or depth cap requires another distinctly named tool. LLM selection requires an enabled per-Session preference and a provider that advertises `agentOptions`; both in-process providers and DSH SDK advertise it, while ACP, Codex, and Claude Code reject it rather than ignore it.
242
+ - **Depth limits are fixed per instance** — independently named tools can set different caps. LLM selection requires an enabled per-Session preference and a provider that advertises `agentOptions`; both in-process providers and DSH SDK advertise it, while ACP, Codex, and Claude Code reject it rather than ignore it.
215
243
 
216
244
  <a id="dev-note"></a>
217
245
  ### Dev Note