@qlzt/dsh-subagent-spawn-in-process 0.0.0-stage → 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/LICENSE +21 -0
- package/README.i18n.yaml +79 -0
- package/README.md +147 -2
- package/README.zh.md +148 -0
- package/lib/index.js +41 -0
- package/lib/types/index.d.ts +19 -0
- package/package.json +53 -4
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 DeepSeek
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.i18n.yaml
ADDED
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
# Bilingual-pair consistency record for README.md (docs/i18n/README.md): per heading
|
|
2
|
+
# section, a hash of its English and Chinese blocks outside code blocks and generated regions.
|
|
3
|
+
# After editing either side, bring the other along and re-record with:
|
|
4
|
+
# pnpm run verify-translation-pairing --write packages/subagent/subagent-spawn-in-process/README.md
|
|
5
|
+
/:
|
|
6
|
+
en: d510765ec1bebc28
|
|
7
|
+
zh: 35efb9f71f05f326
|
|
8
|
+
/deepseek-ai-dsh-subagent-spawn-in-process:
|
|
9
|
+
en: c949befcfe1e376c
|
|
10
|
+
zh: 13c78d0fbbd323ae
|
|
11
|
+
/deepseek-ai-dsh-subagent-spawn-in-process/summary:
|
|
12
|
+
en: 84d0a0acfc4251fe
|
|
13
|
+
zh: 8480ddf68e377522
|
|
14
|
+
/deepseek-ai-dsh-subagent-spawn-in-process/table-of-contents:
|
|
15
|
+
en: d152484eb41ac6b4
|
|
16
|
+
zh: 09388d293f9be9cb
|
|
17
|
+
/deepseek-ai-dsh-subagent-spawn-in-process/use-this-package:
|
|
18
|
+
en: ca895c3af2ec6371
|
|
19
|
+
zh: 51dbe9e2fa79de30
|
|
20
|
+
/deepseek-ai-dsh-subagent-spawn-in-process/use-this-package/when-to-choose-it:
|
|
21
|
+
en: 5f14443940e59bb5
|
|
22
|
+
zh: 3e8610aec21c55e8
|
|
23
|
+
/deepseek-ai-dsh-subagent-spawn-in-process/use-this-package/minimal-configuration:
|
|
24
|
+
en: 3f53b0d5f4037171
|
|
25
|
+
zh: e0f2ac931cfbef95
|
|
26
|
+
/deepseek-ai-dsh-subagent-spawn-in-process/use-this-package/what-a-delegation-does:
|
|
27
|
+
en: eabf1d0e66fde8fa
|
|
28
|
+
zh: d6de66797060bac5
|
|
29
|
+
/deepseek-ai-dsh-subagent-spawn-in-process/understand-the-implementation:
|
|
30
|
+
en: 7f34637751939818
|
|
31
|
+
zh: 2937553168e1aee5
|
|
32
|
+
/deepseek-ai-dsh-subagent-spawn-in-process/understand-the-implementation/design-concept:
|
|
33
|
+
en: 67b871bbb7dcc803
|
|
34
|
+
zh: 79a8fec9117ef52a
|
|
35
|
+
/deepseek-ai-dsh-subagent-spawn-in-process/understand-the-implementation/source-map:
|
|
36
|
+
en: b7c55a4bff3ae1f0
|
|
37
|
+
zh: 9d0f514f433250c6
|
|
38
|
+
/deepseek-ai-dsh-subagent-spawn-in-process/understand-the-implementation/run-flow:
|
|
39
|
+
en: 5f07f1044bf7c370
|
|
40
|
+
zh: d31a485a3e333500
|
|
41
|
+
/deepseek-ai-dsh-subagent-spawn-in-process/understand-the-implementation/ownership-and-scope:
|
|
42
|
+
en: 8af949dc29cb4a5c
|
|
43
|
+
zh: f4e4f9f9f4a4b7c9
|
|
44
|
+
/deepseek-ai-dsh-subagent-spawn-in-process/further-exploration:
|
|
45
|
+
en: c247efa590d8b78a
|
|
46
|
+
zh: 999f8281df521384
|
|
47
|
+
/deepseek-ai-dsh-subagent-spawn-in-process/model-experience:
|
|
48
|
+
en: 215e7ba838619b7b
|
|
49
|
+
zh: a311da3843709f90
|
|
50
|
+
/deepseek-ai-dsh-subagent-spawn-in-process/model-experience/child-agent-request:
|
|
51
|
+
en: 05e6180f1498fdf9
|
|
52
|
+
zh: 2b05d2b97bfa67da
|
|
53
|
+
/deepseek-ai-dsh-subagent-spawn-in-process/model-experience/child-agent-request/what-the-model-sees:
|
|
54
|
+
en: 2035bdd8640e5a8a
|
|
55
|
+
zh: 5afa645d7dbe31a5
|
|
56
|
+
/deepseek-ai-dsh-subagent-spawn-in-process/model-experience/child-agent-request/token-effect:
|
|
57
|
+
en: e74d21e38e4a53a9
|
|
58
|
+
zh: 6a5e3ef5fe0f4f14
|
|
59
|
+
/deepseek-ai-dsh-subagent-spawn-in-process/model-experience/child-agent-request/kv-cache-effect:
|
|
60
|
+
en: 78d800b26fb3b0af
|
|
61
|
+
zh: 313169b62c29af1d
|
|
62
|
+
/deepseek-ai-dsh-subagent-spawn-in-process/model-experience/parent-tool-result-indirectly:
|
|
63
|
+
en: 75d061c2151624a7
|
|
64
|
+
zh: 71e58e020b60ff90
|
|
65
|
+
/deepseek-ai-dsh-subagent-spawn-in-process/model-experience/parent-tool-result-indirectly/what-the-model-sees:
|
|
66
|
+
en: caf11edef2516b8c
|
|
67
|
+
zh: 25bcb16cceaad06d
|
|
68
|
+
/deepseek-ai-dsh-subagent-spawn-in-process/model-experience/parent-tool-result-indirectly/token-effect:
|
|
69
|
+
en: ff8045aa0f466c2a
|
|
70
|
+
zh: e38fc5c6af2ce076
|
|
71
|
+
/deepseek-ai-dsh-subagent-spawn-in-process/model-experience/parent-tool-result-indirectly/kv-cache-effect:
|
|
72
|
+
en: f5d5f97a153f7c70
|
|
73
|
+
zh: 3d6bc05b9eadfbc2
|
|
74
|
+
/deepseek-ai-dsh-subagent-spawn-in-process/known-limitations-and-deferred-work:
|
|
75
|
+
en: 68720f2a663a4aad
|
|
76
|
+
zh: a472436c5cc2b801
|
|
77
|
+
/deepseek-ai-dsh-subagent-spawn-in-process/known-limitations-and-deferred-work/dev-note:
|
|
78
|
+
en: e67f633dc6fe7773
|
|
79
|
+
zh: 3bb0c20c93f16f98
|
package/README.md
CHANGED
|
@@ -1,3 +1,148 @@
|
|
|
1
|
-
|
|
1
|
+
---
|
|
2
|
+
description: "In-process spawn subagent backend for users and maintainers choosing, configuring, or debugging fresh-child delegation."
|
|
3
|
+
kind: "package-reference"
|
|
4
|
+
---
|
|
2
5
|
|
|
3
|
-
|
|
6
|
+
# @deepseek-ai/dsh-subagent-spawn-in-process
|
|
7
|
+
|
|
8
|
+
English | [中文](README.zh.md)
|
|
9
|
+
|
|
10
|
+
## Summary
|
|
11
|
+
|
|
12
|
+
`dsh-subagent-spawn-in-process` is an in-process subagent backend: it runs each delegated task in a fresh child agent that shares this process and its agent factory, LLM, and tool services. The child starts with an empty conversation, so a task prompt must stand alone; it inherits the parent's working directory, session lineage, provider, model, reasoning effort, and output-token limit unless `request.agentOptions` overrides them. A delegation tool or API call reaches it under the `spawn` provider name. Choose it for the cheapest delegation transport; choose the fork backend when the child must build on the parent's completed conversation turns.
|
|
13
|
+
|
|
14
|
+
## Table of Contents
|
|
15
|
+
|
|
16
|
+
- [Use this package](#use-this-package)
|
|
17
|
+
- [Understand the implementation](#understand-the-implementation)
|
|
18
|
+
- [Further Exploration](#further-exploration)
|
|
19
|
+
- [Model Experience](#model-experience)
|
|
20
|
+
- [Known Limitations and Deferred Work](#known-limitations-and-deferred-work)
|
|
21
|
+
- [Dev Note](#dev-note)
|
|
22
|
+
|
|
23
|
+
-----
|
|
24
|
+
|
|
25
|
+
<a id="use-this-package"></a>
|
|
26
|
+
## Use this package
|
|
27
|
+
|
|
28
|
+
Mount this backend in a composition that delegates work to fresh in-process children. The common path is explicit: load the subagent service and this backend, then point a delegation tool such as `dsh-tool-subagent` at the `spawn` provider.
|
|
29
|
+
|
|
30
|
+
### When to choose it
|
|
31
|
+
|
|
32
|
+
Choose the spawn backend when the child needs no parent conversation and running in this process is acceptable. Avoid it when the child must build on completed parent turns — the fork backend seeds that history — or when the child must run outside this process, which the out-of-process backends provide. Because the child inherits the parent's working directory and LLM selection by default, a self-contained prompt behaves exactly as written.
|
|
33
|
+
|
|
34
|
+
### Minimal configuration
|
|
35
|
+
|
|
36
|
+
Load the subagent service and this backend, then configure one delegation tool per target. This is the smallest composition that exposes a `subagent` tool backed by spawn:
|
|
37
|
+
|
|
38
|
+
```yaml
|
|
39
|
+
- name: '@deepseek-ai/dsh-subagent'
|
|
40
|
+
- name: '@deepseek-ai/dsh-subagent-spawn-in-process'
|
|
41
|
+
- name: '@deepseek-ai/dsh-tool-subagent'
|
|
42
|
+
config:
|
|
43
|
+
provider: spawn
|
|
44
|
+
```
|
|
45
|
+
|
|
46
|
+
| Field | Default | Meaning |
|
|
47
|
+
|---|---|---|
|
|
48
|
+
| `providerName` | `spawn` | Provider name registered on `ctx.subagents` |
|
|
49
|
+
|
|
50
|
+
The generated [configuration catalog](../../../docs/config-catalog.md#deepseek-aidsh-subagent-spawn-in-process) is the exhaustive source for every accepted field and its JSDoc.
|
|
51
|
+
|
|
52
|
+
### What a delegation does
|
|
53
|
+
|
|
54
|
+
One tool call creates a background child and returns its session id immediately. The child works in its own session; the parent receives its final answer in a completion notice. The child can also send messages through `send_message`. A rejected start leaves no published child. Programmatic callers such as workflows can await the activation result directly.
|
|
55
|
+
|
|
56
|
+
-----
|
|
57
|
+
|
|
58
|
+
<a id="understand-the-implementation"></a>
|
|
59
|
+
## Understand the implementation
|
|
60
|
+
|
|
61
|
+
<details>
|
|
62
|
+
<summary>Implementation internals — click to expand</summary>
|
|
63
|
+
|
|
64
|
+
This section explains provider preparation and the activation lifecycle owned by the subagent service.
|
|
65
|
+
|
|
66
|
+
### Design concept
|
|
67
|
+
|
|
68
|
+
This backend registers the provider and prepares a fresh child session. `dsh-subagent` owns activation depth checks, child creation, tool and persona setup, structured output, result collection, and disposal. The caller signal cancels unpublished creation; the published handle cancels and reaches quiescence through `dispose()`.
|
|
69
|
+
|
|
70
|
+
### Source map
|
|
71
|
+
|
|
72
|
+
| File | Role |
|
|
73
|
+
|---|---|
|
|
74
|
+
| [`src/index.ts`](src/index.ts) | Provider registration: `Config` schema, capability declaration, `prepareContinuable()` |
|
|
75
|
+
|
|
76
|
+
### Run flow
|
|
77
|
+
|
|
78
|
+
`startActivation()` resolves the provider and calls `prepareContinuable()`, then creates and publishes the child. Structured output is attached separately for each activation. Callers can await `result` and use `dispose()` to wait for the entire child subtree to reach quiescence.
|
|
79
|
+
|
|
80
|
+
### Ownership and scope
|
|
81
|
+
|
|
82
|
+
The child gets a fresh flat registration scope: parent tool restrictions and authority are never imported, and the filter the tool applies is composition, not a parent-derived grant. The backend advertises all five start-time capabilities, including `agentOptions`, because it controls the child's creation window and can enforce each one.
|
|
83
|
+
|
|
84
|
+
</details>
|
|
85
|
+
|
|
86
|
+
-----
|
|
87
|
+
|
|
88
|
+
<a id="further-exploration"></a>
|
|
89
|
+
## Further Exploration
|
|
90
|
+
|
|
91
|
+
Read these pages when the package-level contract is not enough; they move from the shared subagent model to the sibling backends and exhaustive configuration.
|
|
92
|
+
|
|
93
|
+
- [Subagent subsystem](../../../docs/subsystems/subagent.md) — start requests, results, live runs, and the provider contract.
|
|
94
|
+
- [dsh-subagent-fork-in-process](../subagent-fork-in-process/README.md) — the sibling backend that seeds completed parent turns.
|
|
95
|
+
- [dsh-tool-subagent](../tool-subagent/README.md) — the model-facing delegation tool that reaches this provider.
|
|
96
|
+
- [Generated configuration catalog](../../../docs/config-catalog.md#deepseek-aidsh-subagent-spawn-in-process) — every accepted config field and its source declaration.
|
|
97
|
+
|
|
98
|
+
-----
|
|
99
|
+
|
|
100
|
+
<a id="model-experience"></a>
|
|
101
|
+
## Model Experience
|
|
102
|
+
|
|
103
|
+
### Child-agent request
|
|
104
|
+
|
|
105
|
+
#### What the model sees
|
|
106
|
+
|
|
107
|
+
The fresh child receives the task content verbatim as its only user message in a new empty conversation, with the parent provider, model, reasoning effort, output-token limit, and working directory by default. A configured persona shadows global prompt text in the child's scope; a tool filter removes named global tools from its schemas, executable lookup, and PTC mode SDK bindings while leaving independently registered guidance. No parent conversation message is included; the filter is composition, not an inherited authority grant.
|
|
108
|
+
|
|
109
|
+
#### Token effect
|
|
110
|
+
|
|
111
|
+
The child pays for a new independent context and history, and no parent-history token is duplicated. A persona changes the child's repeated prompt cost; a tool filter changes its schema or generated SDK cost.
|
|
112
|
+
|
|
113
|
+
#### KV Cache effect
|
|
114
|
+
|
|
115
|
+
The child's request cache is independent of the parent's. Child history grows append-only, while persona, tool-filter, generated-SDK, provider, or model changes establish a different child prefix.
|
|
116
|
+
|
|
117
|
+
### Parent tool result, indirectly
|
|
118
|
+
|
|
119
|
+
#### What the model sees
|
|
120
|
+
|
|
121
|
+
Through `dsh-tool-subagent`, the parent first receives the child session id, then a completion notice with its final answer. Child-authored messages arrive through `send_message`. Internal child tool calls remain in the child session.
|
|
122
|
+
|
|
123
|
+
#### Token effect
|
|
124
|
+
|
|
125
|
+
Parent input grows by one data-dependent result, retained until compaction.
|
|
126
|
+
|
|
127
|
+
#### KV Cache effect
|
|
128
|
+
|
|
129
|
+
Append-only; newly visible content follows the reusable request prefix and does not invalidate existing KV-cache entries.
|
|
130
|
+
|
|
131
|
+
## Known Limitations and Deferred Work
|
|
132
|
+
|
|
133
|
+
<a id="known-limitations-and-deferred-work"></a>
|
|
134
|
+
|
|
135
|
+
|
|
136
|
+
These limits define when the backend is the wrong choice; they are current package constraints.
|
|
137
|
+
|
|
138
|
+
- **Fresh means no parent transcript** — the child inherits cwd, lineage, provider, model, reasoning effort, output-token limit, and explicitly configured persona or tool restrictions, but none of the parent's conversation; use the fork backend when completed-turn context is required.
|
|
139
|
+
|
|
140
|
+
<a id="dev-note"></a>
|
|
141
|
+
### Dev Note
|
|
142
|
+
|
|
143
|
+
<details>
|
|
144
|
+
<summary>Working context for maintainers — click to expand</summary>
|
|
145
|
+
|
|
146
|
+
None.
|
|
147
|
+
|
|
148
|
+
</details>
|
package/README.zh.md
ADDED
|
@@ -0,0 +1,148 @@
|
|
|
1
|
+
---
|
|
2
|
+
description: "面向用户与维护者的进程内 spawn subagent 后端说明,用于选择、配置或排查全新子级委派。"
|
|
3
|
+
kind: "package-reference"
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# @deepseek-ai/dsh-subagent-spawn-in-process
|
|
7
|
+
|
|
8
|
+
[English](README.md) | 中文
|
|
9
|
+
|
|
10
|
+
## 概述
|
|
11
|
+
|
|
12
|
+
`dsh-subagent-spawn-in-process` 是一个进程内 subagent 后端:它在当前进程中运行每个委派任务,子 agent(智能体)是一个全新子 `Agent`,复用宿主的 agent 工厂及 LLM(大语言模型)/工具服务。子 agent 以空对话开始,因此任务提示词必须自足;除非 `request.agentOptions` 覆盖,否则它继承父 agent 的工作目录、会话谱系、提供方、模型、推理强度与输出 token 上限。委派工具或 API 调用以 `spawn` 提供方名称找到它。需要成本最低的委派传输时选择它;需要子 agent 建立在父级已完成对话轮次之上时,请选择 fork 后端。
|
|
13
|
+
|
|
14
|
+
## 目录
|
|
15
|
+
|
|
16
|
+
- [使用本包](#use-this-package)
|
|
17
|
+
- [理解实现](#understand-the-implementation)
|
|
18
|
+
- [进一步探索](#further-exploration)
|
|
19
|
+
- [模型体验](#model-experience)
|
|
20
|
+
- [已知限制与延期工作](#known-limitations-and-deferred-work)
|
|
21
|
+
- [开发备注](#dev-note)
|
|
22
|
+
|
|
23
|
+
-----
|
|
24
|
+
|
|
25
|
+
<a id="use-this-package"></a>
|
|
26
|
+
## 使用本包
|
|
27
|
+
|
|
28
|
+
在需要把工作委派给全新进程内子 agent 的组合中挂载此后端。常用配置路径很明确:加载 subagent 服务与本后端,再把 `dsh-tool-subagent` 之类的委派工具指向 `spawn` 提供方。
|
|
29
|
+
|
|
30
|
+
### 何时选择
|
|
31
|
+
|
|
32
|
+
当子 agent 不需要父级对话、且可以接受在本进程内运行时,选择 spawn 后端。当子 agent 必须建立在已完成父级轮次之上时——fork 后端会提供这些历史——或必须在本进程之外运行时(进程外后端提供此能力),请避免使用它。由于子 agent 默认继承父级的工作目录与 LLM 选择,自足的提示词会按原样生效。
|
|
33
|
+
|
|
34
|
+
### 最小配置
|
|
35
|
+
|
|
36
|
+
先加载 subagent 服务与本后端,再为每个目标配置一个委派工具。这是暴露由 spawn 支撑的 `subagent` 工具的最小组合:
|
|
37
|
+
|
|
38
|
+
```yaml
|
|
39
|
+
- name: '@deepseek-ai/dsh-subagent'
|
|
40
|
+
- name: '@deepseek-ai/dsh-subagent-spawn-in-process'
|
|
41
|
+
- name: '@deepseek-ai/dsh-tool-subagent'
|
|
42
|
+
config:
|
|
43
|
+
provider: spawn
|
|
44
|
+
```
|
|
45
|
+
|
|
46
|
+
| 字段 | 默认值 | 含义 |
|
|
47
|
+
|---|---|---|
|
|
48
|
+
| `providerName` | `spawn` | 注册到 `ctx.subagents` 的提供方名称 |
|
|
49
|
+
|
|
50
|
+
生成的[配置目录](../../../docs/config-catalog.zh.md#deepseek-aidsh-subagent-spawn-in-process)是每个受支持字段及其 JSDoc 的穷尽式真源。
|
|
51
|
+
|
|
52
|
+
### 一次委派会做什么
|
|
53
|
+
|
|
54
|
+
一次工具调用创建后台子 agent 并立即返回子会话 ID。子级在自己的会话中工作,父级通过完成通知收到其最终答案。子级也可以通过 `send_message` 发送消息。被拒绝的启动不会留下已发布的子 agent;工作流等程序调用方可以直接等待 activation 的结果。
|
|
55
|
+
|
|
56
|
+
-----
|
|
57
|
+
|
|
58
|
+
<a id="understand-the-implementation"></a>
|
|
59
|
+
## 理解实现
|
|
60
|
+
|
|
61
|
+
<details>
|
|
62
|
+
<summary>实现细节——点击展开</summary>
|
|
63
|
+
|
|
64
|
+
本节说明提供方准备工作,以及由 subagent 服务拥有的 activation 生命周期。
|
|
65
|
+
|
|
66
|
+
### 设计理念
|
|
67
|
+
|
|
68
|
+
本后端注册提供方并准备全新子会话。`dsh-subagent` 拥有 activation 的深度检查、子 agent 创建、工具和 persona 设置、结构化输出、结果收集及资源释放;发布前的调用方信号取消创建,发布后的句柄通过 `dispose()` 取消并等待完全停稳。
|
|
69
|
+
|
|
70
|
+
### 源码地图
|
|
71
|
+
|
|
72
|
+
| 文件 | 职责 |
|
|
73
|
+
|---|---|
|
|
74
|
+
| [`src/index.ts`](src/index.ts) | 提供方注册:`Config` schema、能力声明、`prepareContinuable()` |
|
|
75
|
+
|
|
76
|
+
### 运行流程
|
|
77
|
+
|
|
78
|
+
`startActivation()` 解析提供方并调用 `prepareContinuable()`,随后创建并发布子 agent。每次 activation 单独安装结构化输出。调用方可以等待 `result`,并通过 `dispose()` 等待整个子树完全停稳。
|
|
79
|
+
|
|
80
|
+
### 所有权与作用域
|
|
81
|
+
|
|
82
|
+
子 agent 获得全新的扁平注册作用域:父级工具限制与权限绝不会被导入,工具所施加的过滤属于组合而非父级派生授权。后端声明包括 `agentOptions` 在内的全部五项启动时能力,因为它控制子 agent 的创建窗口,可以逐一强制执行。
|
|
83
|
+
|
|
84
|
+
</details>
|
|
85
|
+
|
|
86
|
+
-----
|
|
87
|
+
|
|
88
|
+
<a id="further-exploration"></a>
|
|
89
|
+
## 进一步探索
|
|
90
|
+
|
|
91
|
+
当包级约定不够用时阅读以下页面;它们从共享 subagent 模型进入兄弟后端与穷尽式配置。
|
|
92
|
+
|
|
93
|
+
- [Subagent 子系统](../../../docs/subsystems/subagent.zh.md)——启动请求、结果、实时运行与提供方约定。
|
|
94
|
+
- [dsh-subagent-fork-in-process](../subagent-fork-in-process/README.zh.md)——以已完成父级轮次作初始内容的兄弟后端。
|
|
95
|
+
- [dsh-tool-subagent](../tool-subagent/README.zh.md)——指向该提供方的面向模型委派工具。
|
|
96
|
+
- [生成配置目录](../../../docs/config-catalog.zh.md#deepseek-aidsh-subagent-spawn-in-process)——每个受支持配置字段及其源声明。
|
|
97
|
+
|
|
98
|
+
-----
|
|
99
|
+
|
|
100
|
+
<a id="model-experience"></a>
|
|
101
|
+
## 模型体验
|
|
102
|
+
|
|
103
|
+
### 子 agent 请求
|
|
104
|
+
|
|
105
|
+
#### 模型看到什么
|
|
106
|
+
|
|
107
|
+
全新子 agent 逐字接收任务内容,作为新空对话中的唯一用户消息,默认使用父级提供方、模型、推理强度、输出 token 上限与工作目录。配置的 persona 会在子 agent 作用域中遮蔽全局提示词文本;工具过滤器会从其 schema、可执行工具查找与 PTC mode SDK 绑定中移除指定的全局工具,但保留独立注册的指导内容。不包含任何父级对话消息;过滤属于组合,而非继承的权限授予。
|
|
108
|
+
|
|
109
|
+
#### Token 影响
|
|
110
|
+
|
|
111
|
+
子 agent 会为全新的独立上下文与历史消耗 token,不复制任何父级历史 token。persona 会改变该子 agent 反复使用的提示词成本;工具过滤器会改变其 schema 或生成 SDK 的成本。
|
|
112
|
+
|
|
113
|
+
#### KV Cache 影响
|
|
114
|
+
|
|
115
|
+
子 agent 的请求缓存与父级相互独立。子 agent 历史仅追加;persona、工具过滤、生成 SDK、提供方或模型变化会建立不同的子 agent 前缀。
|
|
116
|
+
|
|
117
|
+
### 父级工具结果(间接)
|
|
118
|
+
|
|
119
|
+
#### 模型看到什么
|
|
120
|
+
|
|
121
|
+
通过 `dsh-tool-subagent`,父级先收到子会话 ID,随后收到包含最终答案的完成通知。子级自行编写的消息通过 `send_message` 到达。子级内部工具调用保留在子会话中。
|
|
122
|
+
|
|
123
|
+
#### Token 影响
|
|
124
|
+
|
|
125
|
+
父级输入增加一个取决于数据的结果,并保留到上下文压缩(context compaction)为止。
|
|
126
|
+
|
|
127
|
+
#### KV Cache 影响
|
|
128
|
+
|
|
129
|
+
仅追加;新增可见内容位于可复用请求前缀之后,不会使现有 KV Cache 条目失效。
|
|
130
|
+
|
|
131
|
+
## 已知限制与延期工作
|
|
132
|
+
|
|
133
|
+
<a id="known-limitations-and-deferred-work"></a>
|
|
134
|
+
|
|
135
|
+
|
|
136
|
+
这些限制说明何时选择该后端是错误的;它们是当前包约束。
|
|
137
|
+
|
|
138
|
+
- **全新表示不含父级 transcript(文本记录)**——子 agent 继承 cwd、谱系、提供方、模型、推理强度、输出 token 上限及显式配置的 persona/工具限制,但不继承父级的任何对话;需要已完成轮次上下文时,请使用 fork 后端。
|
|
139
|
+
|
|
140
|
+
<a id="dev-note"></a>
|
|
141
|
+
### 开发备注
|
|
142
|
+
|
|
143
|
+
<details>
|
|
144
|
+
<summary>维护者的工作上下文——点击展开</summary>
|
|
145
|
+
|
|
146
|
+
无。
|
|
147
|
+
|
|
148
|
+
</details>
|
package/lib/index.js
ADDED
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import z from "@deepseek-ai/schemastery";
|
|
2
|
+
//#region lib/types/index.js
|
|
3
|
+
/**
|
|
4
|
+
* The in-process SPAWN subagent backend: registers a {@link SubagentProvider} on
|
|
5
|
+
* `ctx.subagents` that runs each child as a fresh child {@link Agent} on the same cordis
|
|
6
|
+
* context (its own session, own system prompt, zero parent context). The cheapest transport,
|
|
7
|
+
* reusing the agent factory's quiescent teardown.
|
|
8
|
+
* @module @qlzt/dsh-subagent-spawn-in-process
|
|
9
|
+
*/
|
|
10
|
+
const name = "subagent-spawn-in-process";
|
|
11
|
+
const inject = ["subagents"];
|
|
12
|
+
const Config = z.object({ providerName: z.string().default("spawn") });
|
|
13
|
+
/**
|
|
14
|
+
* The spawn provider. Supports every start-time capability: `depthLimit` (it
|
|
15
|
+
* constructs the child, so it can enforce a recursion cap), `outputSchema`
|
|
16
|
+
* (the scoped structured runtime), `agentOptions` (merged over the parent
|
|
17
|
+
* route), and `toolFilter`/`persona` (scoped `restrict()` and a scoped
|
|
18
|
+
* shadowing persona section, applied in the child's creation window).
|
|
19
|
+
*/
|
|
20
|
+
var SpawnInProcessProvider = class {
|
|
21
|
+
name;
|
|
22
|
+
capabilities = {
|
|
23
|
+
agentOptions: true,
|
|
24
|
+
outputSchema: true,
|
|
25
|
+
depthLimit: true,
|
|
26
|
+
toolFilter: true,
|
|
27
|
+
persona: true
|
|
28
|
+
};
|
|
29
|
+
inheritsParentContext = false;
|
|
30
|
+
constructor(name) {
|
|
31
|
+
this.name = name;
|
|
32
|
+
}
|
|
33
|
+
prepareContinuable() {
|
|
34
|
+
return Promise.resolve({});
|
|
35
|
+
}
|
|
36
|
+
};
|
|
37
|
+
function apply(ctx, config) {
|
|
38
|
+
ctx.subagents.registerProvider(new SpawnInProcessProvider(config.providerName));
|
|
39
|
+
}
|
|
40
|
+
//#endregion
|
|
41
|
+
export { Config, apply, inject, name };
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The in-process SPAWN subagent backend: registers a {@link SubagentProvider} on
|
|
3
|
+
* `ctx.subagents` that runs each child as a fresh child {@link Agent} on the same cordis
|
|
4
|
+
* context (its own session, own system prompt, zero parent context). The cheapest transport,
|
|
5
|
+
* reusing the agent factory's quiescent teardown.
|
|
6
|
+
* @module @qlzt/dsh-subagent-spawn-in-process
|
|
7
|
+
*/
|
|
8
|
+
import type { Context } from '@deepseek-ai/cordis';
|
|
9
|
+
import z from '@deepseek-ai/schemastery';
|
|
10
|
+
export declare const name = "subagent-spawn-in-process";
|
|
11
|
+
export declare const inject: string[];
|
|
12
|
+
/** Config: the registry name to register the provider under. */
|
|
13
|
+
export interface Config {
|
|
14
|
+
/** Provider name on `ctx.subagents` (default `spawn`). */
|
|
15
|
+
providerName: string;
|
|
16
|
+
}
|
|
17
|
+
export declare const Config: z<Config>;
|
|
18
|
+
export declare function apply(ctx: Context, config: Config): void;
|
|
19
|
+
//# sourceMappingURL=index.d.ts.map
|
package/package.json
CHANGED
|
@@ -1,6 +1,55 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@qlzt/dsh-subagent-spawn-in-process",
|
|
3
|
-
"
|
|
4
|
-
"
|
|
5
|
-
"
|
|
6
|
-
|
|
3
|
+
"description": "In-process spawn subagent backend: runs a fresh child agent on ctx.agents",
|
|
4
|
+
"version": "0.2.1-alpha.3",
|
|
5
|
+
"publishConfig": {
|
|
6
|
+
"access": "public"
|
|
7
|
+
},
|
|
8
|
+
"repository": {
|
|
9
|
+
"type": "git",
|
|
10
|
+
"url": "https://gitee.com/zsping1989/deepseek-harness.git",
|
|
11
|
+
"directory": "packages/subagent/subagent-spawn-in-process"
|
|
12
|
+
},
|
|
13
|
+
"type": "module",
|
|
14
|
+
"main": "lib/index.js",
|
|
15
|
+
"types": "lib/types/index.d.ts",
|
|
16
|
+
"exports": {
|
|
17
|
+
".": {
|
|
18
|
+
"types": "./lib/types/index.d.ts",
|
|
19
|
+
"default": "./lib/index.js"
|
|
20
|
+
},
|
|
21
|
+
"./src/*": "./src/*",
|
|
22
|
+
"./package.json": "./package.json"
|
|
23
|
+
},
|
|
24
|
+
"files": [
|
|
25
|
+
"lib/index.js",
|
|
26
|
+
"lib/types/**/*.d.ts"
|
|
27
|
+
],
|
|
28
|
+
"license": "MIT",
|
|
29
|
+
"peerDependencies": {
|
|
30
|
+
"@qlzt/dsh-subagent": "0.2.1-alpha.3",
|
|
31
|
+
"@deepseek-ai/cordis": "~4.0.5-alpha.1"
|
|
32
|
+
},
|
|
33
|
+
"dependencies": {
|
|
34
|
+
"@deepseek-ai/schemastery": "~3.18.5-alpha.1"
|
|
35
|
+
},
|
|
36
|
+
"devDependencies": {
|
|
37
|
+
"@deepseek-ai/cordis-plugin-loader": "~1.0.6-alpha.1",
|
|
38
|
+
"@deepseek-ai/dsh-agent": "0.2.1-alpha.3",
|
|
39
|
+
"@deepseek-ai/dsh-agent-loop": "0.2.1-alpha.3",
|
|
40
|
+
"@deepseek-ai/dsh-agent-loop-testkit": "0.2.1-alpha.3",
|
|
41
|
+
"@deepseek-ai/dsh-bash-local": "0.2.1-alpha.3",
|
|
42
|
+
"@deepseek-ai/dsh-subprocess-local": "0.2.1-alpha.3",
|
|
43
|
+
"@deepseek-ai/dsh-llm": "0.2.1-alpha.3",
|
|
44
|
+
"@deepseek-ai/dsh-llm-deepseek": "0.2.1-alpha.3",
|
|
45
|
+
"@deepseek-ai/dsh-llm-deepseek-api-key": "0.2.1-alpha.3",
|
|
46
|
+
"@deepseek-ai/dsh-session": "0.2.1-alpha.3",
|
|
47
|
+
"@deepseek-ai/dsh-subagent": "0.2.1-alpha.3",
|
|
48
|
+
"@deepseek-ai/dsh-tool-bash": "0.2.1-alpha.3",
|
|
49
|
+
"@deepseek-ai/dsh-tool-subagent": "0.2.1-alpha.3",
|
|
50
|
+
"@deepseek-ai/cordis": "~4.0.5-alpha.1",
|
|
51
|
+
"@deepseek-ai/dsh-session-projection": "0.2.1-alpha.3",
|
|
52
|
+
"@deepseek-ai/dsh-session-persistence-jsonl": "0.2.1-alpha.3"
|
|
53
|
+
},
|
|
54
|
+
"dsh": {}
|
|
55
|
+
}
|