@deepseek-ai/dsh-tool-subagent 0.2.2-rc.5 → 0.2.3-alpha.2

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
@@ -15,8 +15,8 @@
15
15
  en: d152484eb41ac6b4
16
16
  zh: 09388d293f9be9cb
17
17
  /deepseek-ai-dsh-tool-subagent/use-this-package:
18
- en: 93f1701f5209ecb5
19
- zh: 6310fd012400aead
18
+ en: 76236371849f929c
19
+ zh: 341fb5d40fdb6d36
20
20
  /deepseek-ai-dsh-tool-subagent/use-this-package/minimal-configuration:
21
21
  en: 1a23808ca32b8f2d
22
22
  zh: e637a35220da0564
@@ -27,17 +27,17 @@
27
27
  en: e28a206c65151ec0
28
28
  zh: 1372242076549ca4
29
29
  /deepseek-ai-dsh-tool-subagent/use-this-package/selecting-a-child-llm:
30
- en: fb47e667c543dfc6
31
- zh: fa450e808dd5dc7f
30
+ en: c8b91471fb12f907
31
+ zh: 5086e6c62df65b3b
32
32
  /deepseek-ai-dsh-tool-subagent/understand-the-implementation:
33
33
  en: 6ce5f749256a7e6c
34
34
  zh: a4f2adb04a70d9cf
35
35
  /deepseek-ai-dsh-tool-subagent/understand-the-implementation/design-concept:
36
- en: 373abf7c7aa3e4f1
37
- zh: be0b4d4a7371d360
36
+ en: 6b531756ba1c2c7c
37
+ zh: 4e3f7500c83cf02d
38
38
  /deepseek-ai-dsh-tool-subagent/understand-the-implementation/activation-ownership:
39
- en: ef692c4d17290920
40
- zh: b1d0d3dab011e2cd
39
+ en: 4a65fd2ecf132237
40
+ zh: eb009d94a0b2501a
41
41
  /deepseek-ai-dsh-tool-subagent/understand-the-implementation/result-acknowledgement:
42
42
  en: 3c2d70d479be8e38
43
43
  zh: 9aebdb72223a086e
@@ -45,8 +45,8 @@
45
45
  en: 1733728ac5aa6bb0
46
46
  zh: 341ffc6e21a289af
47
47
  /deepseek-ai-dsh-tool-subagent/understand-the-implementation/source-map:
48
- en: 181b32db8839119a
49
- zh: a9e8625b236d6fc4
48
+ en: 6b29ed876aaf4b6e
49
+ zh: 381d01a65e54c583
50
50
  /deepseek-ai-dsh-tool-subagent/further-exploration:
51
51
  en: fa3c9a967b636afb
52
52
  zh: a9ce930a9766d5cb
@@ -57,8 +57,8 @@
57
57
  en: e4c7376d4f29dbd5
58
58
  zh: 6b7a9eaf69c9ea53
59
59
  /deepseek-ai-dsh-tool-subagent/model-experience/tool-schema/what-the-model-sees:
60
- en: 2e7844a04f0456ea
61
- zh: 7aaaa033b700aa3d
60
+ en: 68befd517e6874fb
61
+ zh: 823c6fc65eadd9a2
62
62
  /deepseek-ai-dsh-tool-subagent/model-experience/tool-schema/token-effect:
63
63
  en: b36081ab5c06241f
64
64
  zh: 1e784317ee1fb381
@@ -69,11 +69,11 @@
69
69
  en: a4ca31b9cbacda6b
70
70
  zh: 91ac3e0784a14697
71
71
  /deepseek-ai-dsh-tool-subagent/model-experience/model-selection-and-discovery/what-the-model-sees:
72
- en: 44bd1c2d49d0bbc1
73
- zh: 7ae63df1cc3f56f2
72
+ en: 3884165fa3c6118d
73
+ zh: dca7f94713e64b22
74
74
  /deepseek-ai-dsh-tool-subagent/model-experience/model-selection-and-discovery/token-effect:
75
- en: 3a55d6616c00746b
76
- zh: 4b0ef3dbff2c67ce
75
+ en: f0b6cc7441998c26
76
+ zh: 376cfb972c1bfe0a
77
77
  /deepseek-ai-dsh-tool-subagent/model-experience/model-selection-and-discovery/kv-cache-effect:
78
78
  en: 7dc47a34d5574fbd
79
79
  zh: bd7bd2a4da2f8ae2
@@ -81,8 +81,8 @@
81
81
  en: cf78b9dd5596495f
82
82
  zh: bd44560f8c2435e8
83
83
  /deepseek-ai-dsh-tool-subagent/model-experience/system-prompt/what-the-model-sees:
84
- en: c02f6b82a7756d03
85
- zh: 60ed316d16e34ddf
84
+ en: c2f02a2a3b4232a3
85
+ zh: 7f7ca71413ef1abb
86
86
  /deepseek-ai-dsh-tool-subagent/model-experience/system-prompt/what-the-model-sees/tool-guidance-section:
87
87
  en: 82b3cd08b3961c98
88
88
  zh: bdc2a34bcea16cac
@@ -90,8 +90,8 @@
90
90
  en: 1dac7ae068a09dab
91
91
  zh: 408c273c0bdf88d3
92
92
  /deepseek-ai-dsh-tool-subagent/model-experience/system-prompt/kv-cache-effect:
93
- en: 6dce9fc6c131fd20
94
- zh: 2783a481ee349f1e
93
+ en: f2224ea48e463d1a
94
+ zh: 1c69cb360d9271e5
95
95
  /deepseek-ai-dsh-tool-subagent/model-experience/runtime-depth-context:
96
96
  en: 1e58e87365d88e45
97
97
  zh: 7648aa3b3865057f
@@ -132,8 +132,8 @@
132
132
  en: f5d5f97a153f7c70
133
133
  zh: 3d6bc05b9eadfbc2
134
134
  /deepseek-ai-dsh-tool-subagent/known-limitations-and-deferred-work:
135
- en: d2daad284c68bc25
136
- zh: 2f10007341188c10
135
+ en: 5e62d35a22719e99
136
+ zh: a2bdcf6ef7e40fa4
137
137
  /deepseek-ai-dsh-tool-subagent/known-limitations-and-deferred-work/dev-note:
138
138
  en: e67f633dc6fe7773
139
139
  zh: 3bb0c20c93f16f98
package/README.md CHANGED
@@ -25,7 +25,7 @@ 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.
28
+ The child starts in the caller's workspace directory; the tool takes no directory argument. Existing children retain their own directories when the caller's directory changes.
29
29
 
30
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.
31
31
 
@@ -74,7 +74,7 @@ Compose persona and tools in the [preset plugin list](../../preset/agent-preset-
74
74
 
75
75
  ### Selecting a child LLM
76
76
 
77
- Set `modelSelection: true` to expose optional `provider`, `model`, and `reasoning_effort` fields; instances without it reject selection fields. Set `modelDiscovery: true` on one instance per tool scope to register `list_subagent_models`; it defaults off independently of `modelSelection`. A second discovery owner in the same scope fails to register. Discovery follows its owning plugin instance, remains available when its delegation provider is absent, and is removed when that instance unloads. Web and Desktop presets enable discovery and route fields on spawn and leave both disabled on fork. The Host’s `/model-selection-settings` service samples the user preference during Agent creation, independently of tool installation. Its creation listener subscribes before projection registration completes and awaits the handle; registration failure or owner disposal rejects Agent publication. When enabled, its exact route list is recorded in each fresh top-level Session, inherited by child Sessions, and preserved on restore; later settings edits affect only new Sessions. Without a recorded Session policy, discovery and explicit selection permit only the parent Agent’s current effective provider/model and its supported efforts. Route fields require a backend that advertises `agentOptions`; in-process Spawn and Fork and DSH SDK qualify, while ACP, Codex, and Claude Code fail the mount.
77
+ Set `modelSelection: true` to expose optional `provider`, `model`, and `reasoning_effort` fields; instances without it reject selection fields. Set `modelDiscovery: true` on one instance per tool scope to register `list_subagent_models`; it defaults off independently of `modelSelection`. A second discovery owner in the same scope fails to register. Discovery follows its owning plugin instance, remains available when its delegation provider is absent, and is removed when that instance unloads. Web and Desktop presets enable discovery and route fields on spawn and leave both disabled on fork. Explicit selection by a model-selectable delegation tool and each discovery call read the Host’s `/model-selection-settings` service, so a settings edit applies to the next call in every running, restored, and child Session. When enabled, discovery and explicit selection permit its exact route list. When it is disabled or not mounted, they permit only the parent Agent’s current effective provider/model and its supported efforts. An enabled setting with an empty, malformed, or repeated route list rejects each call that reads it with `SubagentError` code `INVALID_MODEL_SELECTION_SETTINGS`. Ordinary delegation and tools with model selection disabled do not read the route list; a disabled Host setting also leaves the list unread. Sessions record no authorization; earlier `subagent/model-selection-policy` events are ignored. Route fields require a backend that advertises `agentOptions`; in-process Spawn and Fork and DSH SDK qualify, while ACP, Codex, and Claude Code fail the mount.
78
78
 
79
79
  A call supplies `provider` and `model` together; `reasoning_effort` requires both fields in the same call. An effort-only call rejects before route lookup or child creation. Omitting all three fields preserves configured child defaults and their existing fallback behavior. Static `provider.agentRouteDefaults`, when present, form the provider/model baseline; tool configuration and model fields overlay it before route-aware effort merging and exact-route preflight. Providers without these defaults use compatible values from the parent's latest logged request, then the parent's creation options before its first request, while retaining the configured `maxTokens`. An explicit provider/model pair without an effort clears configured and inherited effort, even when the route is unchanged, so the selected model resolves its default. The live LLM adapter validates the effective route before child creation. Catalog membership remains advisory, so a model can use an unlisted id when its adapter accepts it.
80
80
 
@@ -90,11 +90,11 @@ This section explains how the tool mirrors provider lifecycle and settles runs;
90
90
 
91
91
  ### Design concept
92
92
 
93
- One instance is one provider plus one tool name. The plugin registers its definition in the owning composition while the provider is present and disposes it when the provider leaves. Each preset revision owns one shared registration, including tools with preset selection. Agents inherit its definitions; switching presets changes scope ancestry without reinstalling tools. Discovery belongs to the instance configured with `modelDiscovery` and reads the same durable Session policy as the delegation executor. A numeric `maxDepth` or configured LLM selection unsupported by the provider fails the mount. Multiple distinctly named delegation tools may expose model selection in one scope.
93
+ One instance is one provider plus one tool name. The plugin registers its definition in the owning composition while the provider is present and disposes it when the provider leaves. Each preset revision owns one shared registration, including tools with preset selection. Agents inherit its definitions; switching presets changes scope ancestry without reinstalling tools. Discovery belongs to the instance configured with `modelDiscovery` and reads the same current Host setting as the delegation executor. A numeric `maxDepth` or configured LLM selection unsupported by the provider fails the mount. Multiple distinctly named delegation tools may expose model selection in one scope.
94
94
 
95
95
  ### Activation ownership
96
96
 
97
- 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.
97
+ 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. Rejections before startup are coded: a missing calling Agent, `llm` service, or effective parent route throws `ToolContextUnavailableError`; an unpaired route field throws `ToolArgsError`, and an empty route field counts as omitted; and `SubagentError` reports a disabled selection (`MODEL_SELECTION_DISABLED`, `PRESET_SELECTION_DISABLED`), a preset outside the allowlist (`PRESET_NOT_ALLOWED`), a route the current Host setting does not authorize (`MODEL_ROUTE_NOT_ALLOWED`), invalid enabled model-selection settings (`INVALID_MODEL_SELECTION_SETTINGS`), an LLM provider unknown to discovery (`LLM_PROVIDER_NOT_FOUND`), or a provider replaced during route preflight (`PROVIDER_CHANGED`). When the caller can call `list_subagent_models`, unpaired-field and unauthorized-route rejections tell the model to call it. Failures after publication arrive through the completion notice, with diagnostics and partial output preserved by the runtime.
98
98
 
99
99
  ### Result acknowledgement
100
100
 
@@ -111,8 +111,8 @@ The tool's description derives from `provider.inheritsParentContext`: a fresh ch
111
111
  | [`src/index.ts`](src/index.ts) | Tool registration, provider lifecycle mirroring, activation requests |
112
112
  | [`src/preset-selection.ts`](src/preset-selection.ts) | Preset defaults, model allowlist, and selection guidance |
113
113
  | [`src/model-selection.ts`](src/model-selection.ts) | Request/config merge and live LLM route preflight |
114
- | [`src/model-selection-settings.ts`](src/model-selection-settings.ts) | Host-owned opt-in setting sampled for new Sessions |
115
- | [`src/model-selection-state.ts`](src/model-selection-state.ts) | Session event that records and inherits the sampled decision |
114
+ | [`src/model-selection-settings.ts`](src/model-selection-settings.ts) | Host-owned opt-in setting read at each delegation and discovery call |
115
+ | [`src/model-selection-state.ts`](src/model-selection-state.ts) | Declaration of the retired Session policy event, kept so released Session logs stay readable |
116
116
  | [`src/list-models.ts`](src/list-models.ts) | `list_subagent_models` runtime discovery tool |
117
117
 
118
118
  </details>
@@ -139,7 +139,7 @@ Read these pages when the package-level contract is not enough; they move from t
139
139
 
140
140
  #### What the model sees
141
141
 
142
- The generated default [`subagent` schema](../../../docs/tool-catalog.md#deepseek-aidsh-tool-subagent) appears under the configured tool name while its provider exists. An instance with `modelSelection` adds `provider`, `model`, and `reasoning_effort` plus route guidance in every Session. `allowedAgentPresets` adds the `agent_preset` enum and guidance for the default or inherited selection. Context inheritance and continuation support determine task and follow-up descriptions. Agent restrictions apply to inherited preset delegation tools in schemas, execution, and guidance, including when historical `toolFilter` overrides are restored; sibling Agents remain unaffected. Preset-selection guidance depends only on the tool configuration, so it does not depend on other presets’ declaration order.
142
+ The generated default [`subagent` schema](../../../docs/tool-catalog.md#deepseek-aidsh-tool-subagent) appears under the configured tool name while its provider exists. An instance with `modelSelection` adds `provider`, `model`, and `reasoning_effort` in every Session. The `provider` description tells the model to set the fields only when the task needs a different model and names the omitted-field route: the parent's current model and effort, or the default configured for the tool or backend. It names `list_subagent_models` as the source of provider ids when the same instance enables `modelDiscovery`. `allowedAgentPresets` adds the `agent_preset` enum and guidance for the default or inherited selection. Context inheritance and continuation support determine task and follow-up descriptions. Agent restrictions apply to inherited preset delegation tools in schemas, execution, and guidance, including when historical `toolFilter` overrides are restored; sibling Agents remain unaffected. Preset-selection guidance depends only on the tool configuration, so it does not depend on other presets’ declaration order.
143
143
 
144
144
  #### Token effect
145
145
 
@@ -153,11 +153,11 @@ Prefix-stable while provider instances and their configuration are unchanged. Ad
153
153
 
154
154
  #### What the model sees
155
155
 
156
- The optional `list_subagent_models` definition reads the calling Session’s route policy, falling back to the current parent route when no policy is recorded. Calls reject while the optional `ctx.llm` service is unavailable. With a recorded policy, provider model lists intersect the advertised catalog with the Session’s authorized routes. Without one, they resolve only the current parent model, even if the catalog omits it. The discovery tool’s description tells the model when to query child routes or efforts and to omit optional query fields rather than send empty strings. Delegation tools document their own selection fields and defaults. Exact-model queries accept authorized ids absent from the catalog; unauthorized provider/model lookups fail before adapter access. Catalog or exact-model lookup failures and cancellation reject the call. Execution independently enforces the same policy.
156
+ The optional `list_subagent_models` definition reads the current Host route setting, falling back to the current parent route when the setting is disabled or absent. Calls reject while the optional `ctx.llm` service is unavailable. With the setting enabled, provider model lists intersect the advertised catalog with its authorized routes. Otherwise, they resolve only the current parent model, even if the catalog omits it. The discovery tool’s description lists what each argument combination returns; an empty query field counts as omitted. Delegation tools document their own selection fields, defaults, and the discovery source. Exact-model queries accept authorized ids absent from the catalog; unauthorized provider/model lookups fail before adapter access. Catalog or exact-model lookup failures and cancellation reject the call. Execution independently enforces the same setting.
157
157
 
158
158
  #### Token effect
159
159
 
160
- One fixed discovery schema is present wherever `modelDiscovery` is enabled, regardless of the Session’s preference or the owning instance’s `modelSelection` option; the shipped Web and Desktop presets include it, while headless, SDK, and ACP profiles do not. Route metadata enters the transcript only when the model calls the tool.
160
+ One fixed discovery schema is present wherever `modelDiscovery` is enabled, regardless of the Host setting or the owning instance’s `modelSelection` option; the shipped Web and Desktop presets include it, while headless, SDK, and ACP profiles do not. Route metadata enters the transcript only when the model calls the tool.
161
161
 
162
162
  #### KV Cache effect
163
163
 
@@ -167,12 +167,12 @@ The schema is prefix-stable across adapter registration and catalog changes. Eac
167
167
 
168
168
  #### What the model sees
169
169
 
170
- Visible delegation tools share delegation and collaboration guidance, 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. Ending the turn works because a settled child notifies its parent and a notice that reaches an idle parent starts one independent model request; hosts that keep children progressing alternate `agent.whenIdle()` and `waitForChildren(agent)` ([`dsh-subagent`](../subagent/README.md), [`session.ts`](../../acp/acp/src/session.ts)). Hidden or unavailable tools are omitted; no guidance appears when none are visible. With both `subagent` and `subagent_fork` visible, the text is:
170
+ Visible delegation tools share delegation and collaboration guidance, 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. Ending the turn works because a settled child notifies its parent and a notice that reaches an idle parent starts one independent model request; hosts that keep children progressing alternate `agent.whenIdle()` and `waitForChildren(agent)` ([`dsh-subagent`](../subagent/README.md), [`session.ts`](../../acp/acp/src/session.ts)). Hidden or unavailable tools are omitted; no guidance appears when none are visible. With both `subagent` and `subagent_fork` visible and the default concurrency limit of `8`, the text is:
171
171
 
172
172
  ##### Tool-guidance section
173
173
 
174
174
  ```markdown
175
- 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. Collect the subagent results required to complete the task before giving the user a final answer.
175
+ Start independent delegations with `subagent` or `subagent_fork` together in one assistant message and continue useful work while they run. The concurrency limit of all the subagents is 8. When only waiting for their results remains, end your turn instead of sleeping or polling; the next result starts a new turn. Collect the subagent results required to complete the task before giving the user a final answer.
176
176
 
177
177
  Bash, formatters, code generators, and scripts can overwrite concurrent edits without conflict detection; coordinate their changes explicitly. The agent integrating the work must review the final diff and run relevant tests.
178
178
  ```
@@ -183,7 +183,7 @@ Two guidance paragraphs per parent request with visible delegation tools, listin
183
183
 
184
184
  #### KV Cache effect
185
185
 
186
- Prefix-stable while the visible tool names are unchanged; adding or removing a visible tool changes the guidance.
186
+ Prefix-stable while the visible tool names and configured concurrency limit are unchanged; each prompt assembly reads the current limit.
187
187
 
188
188
  ### Runtime depth context
189
189
 
@@ -243,8 +243,8 @@ These limits define what this tool does not return or enforce; they are current
243
243
  - **This tool does not wait for results** — use the completion notice or child messages. Programmatic result waiting belongs to the subagent service.
244
244
  - **Preset choices omit descriptions** — `agent_preset` exposes ids and default or inheritance guidance only. The schema does not read candidate preset documents, so registration is independent of their declaration order. Use ids that convey each candidate's purpose.
245
245
  - **Preset references are checked on delegation** — Host-mounted and preset-mounted tools both resolve the target when starting a child. A target can be declared or replaced after tool registration, so loading the tool cannot establish its availability for a later call. Misspelled or unavailable ids remain undetected until selected; that call returns an error.
246
- - **Shipped fork tools omit model selection** — their configuration leaves `modelSelection` disabled to preserve inherited-prefix reuse. Custom fork tools may enable it under the same Session authorization and adapter validation as other delegation tools.
247
- - **Depth caps are fixed per instance** — another cap requires another distinctly named tool. Child personas and tools belong to the selected Agent Preset. Explicit LLM selection requires `modelSelection` and is restricted to the Session’s authorized routes, or the current parent route without an enabled policy.
246
+ - **Shipped fork tools omit model selection** — their configuration leaves `modelSelection` disabled to preserve inherited-prefix reuse. Custom fork tools may enable it under the same Host authorization and adapter validation as other delegation tools.
247
+ - **Depth caps are fixed per instance** — another cap requires another distinctly named tool. Child personas and tools belong to the selected Agent Preset. Explicit LLM selection requires `modelSelection` and is restricted to the routes the Host setting authorizes at call time, or the current parent route when it is disabled.
248
248
 
249
249
  <a id="dev-note"></a>
250
250
  ### Dev Note
package/README.zh.md CHANGED
@@ -25,7 +25,7 @@ kind: "package-reference"
25
25
  <a id="use-this-package"></a>
26
26
  ## 使用本包
27
27
 
28
- 可选参数 `cwd` 选择子级的初始工作目录。相对路径以调用者当前目录解析;省略时继承该目录。调用者切换目录时,已有子级保留自己的目录。
28
+ 子级从调用者的工作区目录启动;工具不接受目录参数。调用者的目录变化时,已有子级保留自己的目录。
29
29
 
30
30
  每个委派目标挂载一个实例,且每个实例的 `toolName` 必须不同。工具与其提供方同时存在、同时消失,因此同级加载顺序与提供方重新加载都不会让工具悬空。
31
31
 
@@ -74,7 +74,7 @@ kind: "package-reference"
74
74
 
75
75
  ### 选择子级 LLM
76
76
 
77
- 设置 `modelSelection: true` 后,该实例公开可选的 `provider`、`model` 和 `reasoning_effort` 字段;未设置的实例拒绝选择字段。在每个工具作用域的一个实例上设置 `modelDiscovery: true`,以注册 `list_subagent_models`;该选项独立于 `modelSelection`,默认关闭。同一作用域的第二个发现工具所有者会注册失败。发现工具随其所属插件实例存续,在委派提供方缺席时仍然可用,并在该实例卸载时移除。Web 与 Desktop preset 为 spawn 启用发现和路由字段,为 fork 保持两者关闭。Host 的 `/model-selection-settings` 服务在 Agent 创建时读取用户偏好,与工具安装无关。创建监听器在投影注册完成前订阅并等待句柄;注册失败或所属插件卸载会使 Agent 发布失败。启用时,精确路由列表记录在每个新顶层 Session 中,由子 Session 继承,并在恢复时保留;之后的设置编辑只影响新 Session。没有已记录 Session 策略时,发现和显式选择只允许父 Agent 当前生效的 provider/model 及其支持的强度。路由字段要求后端公布 `agentOptions`;进程内 Spawn、Fork 和 DSH SDK 满足条件,ACP、Codex 和 Claude Code 会使挂载失败。
77
+ 设置 `modelSelection: true` 后,该实例公开可选的 `provider`、`model` 和 `reasoning_effort` 字段;未设置的实例拒绝选择字段。在每个工具作用域的一个实例上设置 `modelDiscovery: true`,以注册 `list_subagent_models`;该选项独立于 `modelSelection`,默认关闭。同一作用域的第二个发现工具所有者会注册失败。发现工具随其所属插件实例存续,在委派提供方缺席时仍然可用,并在该实例卸载时移除。Web 与 Desktop preset 为 spawn 启用发现和路由字段,为 fork 保持两者关闭。允许模型选择的委派工具在显式选择路由时、发现工具在每次调用时读取 Host 的 `/model-selection-settings` 服务,因此设置编辑会对所有运行中、已恢复和子 Session 的下一次调用生效。启用时,发现和显式选择允许其精确路由列表。设置关闭或未挂载时,只允许父 Agent 当前生效的 provider/model 及其支持的强度。启用但路由列表为空、格式无效或重复时,读取该设置的每次调用都会抛出错误码为 `INVALID_MODEL_SELECTION_SETTINGS` 的 `SubagentError`。普通委派和关闭模型选择的工具不读取路由列表;Host 设置关闭时也不读取该列表。Session 不记录授权;忽略早期的 `subagent/model-selection-policy` 事件。路由字段要求后端公布 `agentOptions`;进程内 Spawn、Fork 和 DSH SDK 满足条件,ACP、Codex 和 Claude Code 会使挂载失败。
78
78
 
79
79
  一次调用需同时提供 `provider` 与 `model`;`reasoning_effort` 要求同一次调用包含这两个字段。仅指定强度的调用会在查询路由或创建子级之前被拒绝。省略全部三个字段时,保留配置的子级默认值与现有回退行为。静态的 `provider.agentRouteDefaults` 在存在时构成提供方/模型基线;工具配置与模型字段会在路由相关强度合并和确切路由预检前覆盖它。没有这些默认值的提供方会使用父 agent 最新已记录请求中的兼容值,再使用父级首次请求前的创建选项,并保留配置的 `maxTokens`。显式提供提供方/模型组合但省略强度时,会清除配置及继承的强度,即使路由未变,也由所选模型解析自己的默认值。实时 LLM 适配器在创建子 agent 前校验有效路由。目录成员资格只提供建议,因此适配器接受时,模型可以使用未列出的 id。
80
80
 
@@ -90,11 +90,11 @@ kind: "package-reference"
90
90
 
91
91
  ### 设计理念
92
92
 
93
- 一个实例对应一个提供方和一个工具名。插件在提供方存在时向所属组合注册定义,并在提供方离开时释放它。每个 preset 代际拥有一份共享注册,配置了 preset 选择的工具也相同。Agent 继承其定义;切换 preset 只改变作用域的继承关系,不重新安装工具。发现工具属于配置了 `modelDiscovery` 的实例,与委派执行器读取同一份持久 Session 策略。提供方不支持的数字 `maxDepth` 或配置的 LLM 选择会使挂载失败。同一作用域中可以有多个名称不同的委派工具公开模型选择。
93
+ 一个实例对应一个提供方和一个工具名。插件在提供方存在时向所属组合注册定义,并在提供方离开时释放它。每个 preset 代际拥有一份共享注册,配置了 preset 选择的工具也相同。Agent 继承其定义;切换 preset 只改变作用域的继承关系,不重新安装工具。发现工具属于配置了 `modelDiscovery` 的实例,与委派执行器读取同一份当前 Host 设置。提供方不支持的数字 `maxDepth` 或配置的 LLM 选择会使挂载失败。同一作用域中可以有多个名称不同的委派工具公开模型选择。
94
94
 
95
95
  ### Activation 所有权
96
96
 
97
- 工具调用 `ctx.subagents.startActivation()`,并选择向父任务交付。运行时拥有启动取消、执行、结果汇报与清理。启动失败产生出错的工具结果;发布后的失败通过完成通知到达,运行时保留诊断和部分输出。
97
+ 工具调用 `ctx.subagents.startActivation()`,并选择向父任务交付。运行时拥有启动取消、执行、结果汇报与清理。启动失败产生出错的工具结果。启动前的拒绝都带 code:缺少调用方 Agent、`llm` 服务或有效的父级路由时抛出 `ToolContextUnavailableError`;路由字段未成对提供时抛出 `ToolArgsError`,空字符串路由字段视为未提供;`SubagentError` 报告选择被禁用(`MODEL_SELECTION_DISABLED`、`PRESET_SELECTION_DISABLED`)、preset 不在允许列表中(`PRESET_NOT_ALLOWED`)、当前 Host 设置未授权该路由(`MODEL_ROUTE_NOT_ALLOWED`)、已启用的模型选择设置无效(`INVALID_MODEL_SELECTION_SETTINGS`)、发现查询的 LLM 提供方未注册(`LLM_PROVIDER_NOT_FOUND`),或路由预检期间提供方被替换(`PROVIDER_CHANGED`)。调用方可以调用 `list_subagent_models` 时,未成对字段和未授权路由的拒绝会提示模型调用它。发布后的失败通过完成通知到达,运行时保留诊断和部分输出。
98
98
 
99
99
  ### 结果确认
100
100
 
@@ -111,8 +111,8 @@ kind: "package-reference"
111
111
  | [`src/index.ts`](src/index.ts) | 工具注册、提供方生命周期镜像、activation 请求 |
112
112
  | [`src/preset-selection.ts`](src/preset-selection.ts) | preset 默认值、模型白名单与选择引导 |
113
113
  | [`src/model-selection.ts`](src/model-selection.ts) | 请求/配置合并与实时 LLM 路由预检 |
114
- | [`src/model-selection-settings.ts`](src/model-selection-settings.ts) | 为新 Session 读取的宿主所有 opt-in 设置 |
115
- | [`src/model-selection-state.ts`](src/model-selection-state.ts) | 记录并继承已读取决定的 Session 事件 |
114
+ | [`src/model-selection-settings.ts`](src/model-selection-settings.ts) | 每次委派和发现调用时读取的宿主所有 opt-in 设置 |
115
+ | [`src/model-selection-state.ts`](src/model-selection-state.ts) | 已停用 Session 策略事件的声明,保留以便读取已发布的 Session 日志 |
116
116
  | [`src/list-models.ts`](src/list-models.ts) | `list_subagent_models` 运行时发现工具 |
117
117
 
118
118
  </details>
@@ -139,7 +139,7 @@ kind: "package-reference"
139
139
 
140
140
  #### 模型看到什么
141
141
 
142
- 生成的默认 [`subagent` schema](../../../docs/tool-catalog.zh.md#deepseek-aidsh-tool-subagent) 在提供方存在时以配置的工具名公开。设置了 `modelSelection` 的实例在每个 Session 中都会增加 `provider`、`model`、`reasoning_effort` 及路由指导。`allowedAgentPresets` 增加 `agent_preset` 枚举及默认或继承选择的引导。上下文继承和继续执行能力决定任务与后续工作描述。Agent 限制同时作用于继承自 preset 的委派工具的 schema、执行入口和指导文本,恢复历史 `toolFilter` 覆盖时也相同;同级 Agent 不受影响。preset 选择提示仅依赖工具配置,因此不依赖其他 preset 的声明顺序。
142
+ 生成的默认 [`subagent` schema](../../../docs/tool-catalog.zh.md#deepseek-aidsh-tool-subagent) 在提供方存在时以配置的工具名公开。设置了 `modelSelection` 的实例在每个 Session 中都会增加 `provider`、`model`、`reasoning_effort`。`provider` 的描述告诉模型仅在任务需要其他模型时才设置这些字段,并说明省略时使用的路由:父级当前模型和推理强度,或工具或后端配置的默认值。同一实例启用 `modelDiscovery` 时,它还指明 provider id 取自 `list_subagent_models`。`allowedAgentPresets` 增加 `agent_preset` 枚举及默认或继承选择的引导。上下文继承和继续执行能力决定任务与后续工作描述。Agent 限制同时作用于继承自 preset 的委派工具的 schema、执行入口和指导文本,恢复历史 `toolFilter` 覆盖时也相同;同级 Agent 不受影响。preset 选择提示仅依赖工具配置,因此不依赖其他 preset 的声明顺序。
143
143
 
144
144
  #### Token 影响
145
145
 
@@ -153,11 +153,11 @@ kind: "package-reference"
153
153
 
154
154
  #### 模型看到什么
155
155
 
156
- 可选的 `list_subagent_models` 定义读取调用 Session 的路由策略,没有已记录策略时使用当前父级路由。可选的 `ctx.llm` 服务不可用时,调用会被拒绝。有已记录策略时,提供方模型列表取公布目录与 Session 授权路由的交集。没有策略时,只解析当前父级模型,即使目录未列出它。发现工具的描述说明何时查询子级路由或强度,并要求省略可选查询字段而不是传空字符串。委派工具各自说明选择字段及其默认行为。精确模型查询允许已授权但目录未列出的 ID;未授权的提供方/模型查询会在访问适配器前失败。目录或精确模型查询失败以及取消都会使调用被拒绝。执行过程独立强制同一策略。
156
+ 可选的 `list_subagent_models` 定义读取当前 Host 路由设置,设置关闭或缺失时使用当前父级路由。可选的 `ctx.llm` 服务不可用时,调用会被拒绝。设置启用时,提供方模型列表取公布目录与其授权路由的交集。设置关闭时,只解析当前父级模型,即使目录未列出它。发现工具的描述列出各参数组合的返回内容;空字符串查询字段视为未提供。委派工具各自说明选择字段、默认行为和取值来源。精确模型查询允许已授权但目录未列出的 ID;未授权的提供方/模型查询会在访问适配器前失败。目录或精确模型查询失败以及取消都会使调用被拒绝。执行过程独立强制同一设置。
157
157
 
158
158
  #### Token 影响
159
159
 
160
- 启用 `modelDiscovery` 的组合中存在一份固定发现 schema,不受 Session 偏好或所属实例的 `modelSelection` 选项影响;随附 Web 与 Desktop preset 包含它,headless、SDK 和 ACP profile 不包含。只有模型调用工具时,路由元数据才进入 transcript。
160
+ 启用 `modelDiscovery` 的组合中存在一份固定发现 schema,不受 Host 设置或所属实例的 `modelSelection` 选项影响;随附 Web 与 Desktop preset 包含它,headless、SDK 和 ACP profile 不包含。只有模型调用工具时,路由元数据才进入 transcript。
161
161
 
162
162
  #### KV Cache 影响
163
163
 
@@ -167,12 +167,12 @@ kind: "package-reference"
167
167
 
168
168
  #### 模型看到什么
169
169
 
170
- 可见的委派工具共享委派与协作指导,列出按名称排序的工具,指示模型一起启动相互独立的委派,并在它们运行时继续工作;当只剩等待它们的结果时,结束本轮,而不是休眠或轮询。结束本轮之所以可行,是因为子代理结束后会通知父级,而通知到达空闲父级会起一次独立的模型请求;在子代理继续推进期间,宿主交替等待 `agent.whenIdle()` 与 `waitForChildren(agent)`([`dsh-subagent`](../subagent/README.zh.md)、[`session.ts`](../../acp/acp/src/session.ts))。隐藏或不可用的工具不列入其中;没有可见工具时,不输出指导。`subagent` 和 `subagent_fork` 都可见时,文本为:
170
+ 可见的委派工具共享委派与协作指导,列出按名称排序的工具,指示模型一起启动相互独立的委派,并在它们运行时继续工作;当只剩等待它们的结果时,结束本轮,而不是休眠或轮询。结束本轮之所以可行,是因为子代理结束后会通知父级,而通知到达空闲父级会起一次独立的模型请求;在子代理继续推进期间,宿主交替等待 `agent.whenIdle()` 与 `waitForChildren(agent)`([`dsh-subagent`](../subagent/README.zh.md)、[`session.ts`](../../acp/acp/src/session.ts))。隐藏或不可用的工具不列入其中;没有可见工具时,不输出指导。`subagent` 和 `subagent_fork` 都可见且并发上限为默认值 `8` 时,文本为:
171
171
 
172
172
  ##### 工具指导 section
173
173
 
174
174
  ```markdown
175
- 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. Collect the subagent results required to complete the task before giving the user a final answer.
175
+ Start independent delegations with `subagent` or `subagent_fork` together in one assistant message and continue useful work while they run. The concurrency limit of all the subagents is 8. When only waiting for their results remains, end your turn instead of sleeping or polling; the next result starts a new turn. Collect the subagent results required to complete the task before giving the user a final answer.
176
176
 
177
177
  Bash, formatters, code generators, and scripts can overwrite concurrent edits without conflict detection; coordinate their changes explicitly. The agent integrating the work must review the final diff and run relevant tests.
178
178
  ```
@@ -183,7 +183,7 @@ Bash, formatters, code generators, and scripts can overwrite concurrent edits wi
183
183
 
184
184
  #### KV Cache 影响
185
185
 
186
- 可见工具名不变时,前缀保持稳定;增加或移除可见工具会更改这段指导。
186
+ 可见工具名和配置的并发上限不变时,前缀保持稳定;每次组装提示词都会读取当前上限。
187
187
 
188
188
  ### 运行时深度上下文
189
189
 
@@ -243,8 +243,8 @@ Delegation depth for `subagent`: current 1, maximum 1, remaining levels 0. Do no
243
243
  - **本工具不等待结果**——使用完成通知或子任务消息。程序化结果等待由 subagent 服务提供。
244
244
  - **预设选项不含描述**——`agent_preset` 只公开 id 及默认或继承提示。schema 不读取候选预设文档,因此注册不依赖它们的声明顺序。请使用能够表达各候选用途的 id。
245
245
  - **预设引用在委派时检查**——Host 挂载和预设内挂载的工具都在启动子级时解析目标。目标可以在工具注册后声明或替换,因此加载工具无法确定后续调用时目标是否可用。拼错或不可用的 id 在被选中前不会被发现;选中它的调用会返回错误。
246
- - **随附 fork 工具省略模型选择**:其配置保持 `modelSelection` 关闭,以保留对继承前缀的复用。自定义 fork 工具可以启用它,并接受与其他委派工具相同的 Session 授权和适配器校验。
247
- - **深度上限按实例固定** — 更换上限需要另一个不同名称的工具。子级角色和工具由所选 Agent Preset 配置。显式 LLM 选择需要 `modelSelection`,并受 Session 授权路由限制,没有启用策略时只允许当前父级路由。
246
+ - **随附 fork 工具省略模型选择**:其配置保持 `modelSelection` 关闭,以保留对继承前缀的复用。自定义 fork 工具可以启用它,并接受与其他委派工具相同的 Host 授权和适配器校验。
247
+ - **深度上限按实例固定** — 更换上限需要另一个不同名称的工具。子级角色和工具由所选 Agent Preset 配置。显式 LLM 选择需要 `modelSelection`,并受调用时 Host 设置授权的路由限制,设置关闭时只允许当前父级路由。
248
248
 
249
249
  <a id="dev-note"></a>
250
250
  ### 开发备注