@fishwithcat/dsh-subagent 0.2.2-alpha.2 → 0.2.2-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
@@ -24,44 +24,44 @@
24
24
  en: 86c982223fab1a3a
25
25
  zh: 3d220d8ed84eab9a
26
26
  /deepseek-ai-dsh-subagent/use-this-package/activation-capacity:
27
- en: d6a567f0a6c3de68
28
- zh: a189b92bb09f5ce2
27
+ en: 20093dab58cd4909
28
+ zh: 10d10db250c9e4c9
29
29
  /deepseek-ai-dsh-subagent/use-this-package/delegated-approval-policy:
30
30
  en: 74e2486bed4b9b20
31
31
  zh: 32102b1847731d35
32
32
  /deepseek-ai-dsh-subagent/use-this-package/local-and-external-children:
33
- en: 013644290e74493e
34
- zh: 05014c3c3773edeb
33
+ en: 191ef1dabe2fce7c
34
+ zh: f799fdcbb5c5a171
35
35
  /deepseek-ai-dsh-subagent/use-this-package/child-presets:
36
36
  en: a740e5e9bdd661d9
37
37
  zh: 712a5458fc8b3615
38
38
  /deepseek-ai-dsh-subagent/use-this-package/messaging-interrupting-and-discovering:
39
- en: 050177fbbaade432
40
- zh: 99f2b9f98088314d
39
+ en: bf3175c2218a16dd
40
+ zh: 4be9271efe71ddb7
41
41
  /deepseek-ai-dsh-subagent/use-this-package/failure-and-recovery:
42
- en: 245fb0d5c3df5ccf
43
- zh: e69eed9e5070ce25
42
+ en: 0dc416ded19e304e
43
+ zh: 4726e5fe5f188709
44
44
  /deepseek-ai-dsh-subagent/understand-the-implementation:
45
45
  en: 74d91b364b23f88d
46
46
  zh: 19cc558105efe8df
47
47
  /deepseek-ai-dsh-subagent/understand-the-implementation/design-concept:
48
- en: ed526b6f34a3d6bf
49
- zh: 47a90717b89d4c79
48
+ en: e6f77fc75a73b0ab
49
+ zh: 7133698a3923e192
50
50
  /deepseek-ai-dsh-subagent/understand-the-implementation/source-map:
51
- en: 410b6215e3a29221
52
- zh: d17d6ea102fe8f87
51
+ en: 5923a61c09d9ae04
52
+ zh: 15202a92872a11e9
53
53
  /deepseek-ai-dsh-subagent/understand-the-implementation/provider-preparation-and-structured-output:
54
- en: f78c5e931f3a3676
55
- zh: 3c63f637dbaa8101
54
+ en: 61cddba23f4e7d1c
55
+ zh: 052c8331a747403f
56
56
  /deepseek-ai-dsh-subagent/understand-the-implementation/activation-settlement:
57
- en: 3cac7a3d58cda7ea
58
- zh: 74e3234e5101bd1d
57
+ en: fc8938de925b1a97
58
+ zh: b50e1f948d60b93c
59
59
  /deepseek-ai-dsh-subagent/understand-the-implementation/restoring-child-composition:
60
- en: d338e68edd438f57
61
- zh: 0496090cc567b19d
60
+ en: 843f9f4319ca2ae3
61
+ zh: 218bf355816d4ff6
62
62
  /deepseek-ai-dsh-subagent/understand-the-implementation/ownership-and-invariants:
63
- en: b74886a091a327d4
64
- zh: 2124546878ba1aa2
63
+ en: ab5d2c41f06b8fea
64
+ zh: 13a9ca3685fa799b
65
65
  /deepseek-ai-dsh-subagent/further-exploration:
66
66
  en: 86a3e3ad13e29989
67
67
  zh: e5138d34086252b2
@@ -72,14 +72,29 @@
72
72
  en: f7cec22ba9d3fb4f
73
73
  zh: 67b1d40f9b136f71
74
74
  /deepseek-ai-dsh-subagent/model-experience/settlement-notice/what-the-model-sees:
75
- en: 8e28e4542cd6bcb6
76
- zh: c840f65ffb8fcfbd
75
+ en: d5e6377fabfee1ca
76
+ zh: f5c442401264a60d
77
77
  /deepseek-ai-dsh-subagent/model-experience/settlement-notice/token-effect:
78
78
  en: f98ad834e8ce8950
79
79
  zh: cf509805dd934094
80
80
  /deepseek-ai-dsh-subagent/model-experience/settlement-notice/kv-cache-effect:
81
81
  en: d6b1d618083da79b
82
82
  zh: 9a28942b7d53c382
83
+ /deepseek-ai-dsh-subagent/model-experience/continuable-child-return-guidance:
84
+ en: 710ebcdce8e283e2
85
+ zh: cc07cf31e572b0cf
86
+ /deepseek-ai-dsh-subagent/model-experience/continuable-child-return-guidance/what-the-model-sees:
87
+ en: c4fd0220e51f1f20
88
+ zh: 0dc2a3ab3aced3eb
89
+ /deepseek-ai-dsh-subagent/model-experience/continuable-child-return-guidance/what-the-model-sees/return-guidance:
90
+ en: 24538ab91a15b0e4
91
+ zh: 86f96219c94ee1b1
92
+ /deepseek-ai-dsh-subagent/model-experience/continuable-child-return-guidance/token-effect:
93
+ en: 889c86126ff12689
94
+ zh: 67162193846cf83f
95
+ /deepseek-ai-dsh-subagent/model-experience/continuable-child-return-guidance/kv-cache-effect:
96
+ en: 7078382a73f743f7
97
+ zh: 1431825f5568a96b
83
98
  /deepseek-ai-dsh-subagent/model-experience/child-delegation-scope-statement:
84
99
  en: dc8544657916e194
85
100
  zh: b0feff0764b5d903
@@ -99,8 +114,8 @@
99
114
  en: 59e848fca82a46fb
100
115
  zh: fcd6a8a2bb58609f
101
116
  /deepseek-ai-dsh-subagent/known-limitations-and-deferred-work:
102
- en: b663a2e94185901c
103
- zh: 8d2937aa203bda59
117
+ en: 746c75e25114ab8b
118
+ zh: 168d577f1fcc4281
104
119
  /deepseek-ai-dsh-subagent/known-limitations-and-deferred-work/dev-note:
105
120
  en: 25cc0909348666bb
106
121
  zh: 95517f12de100049
package/README.md CHANGED
@@ -50,7 +50,7 @@ The limits section on the **Plugins → Subagent** page edits the Host’s `suba
50
50
 
51
51
  ### Activation capacity
52
52
 
53
- Set `maxActiveSubagents` on the host plugin to limit live and materializing children in each activation tree. It defaults to `8` and accepts positive safe integers. A top-level parent starts a pool shared by its local and external descendants; the root parent consumes no slot. Creation and cold resume reserve before yielding, and disposal returns the slot only after cleanup. Waiting parents, pending inbox work, and stopping activations remain counted. Sending to a resident child reuses its slot. Delegation depth is a separate policy.
53
+ Set `maxActiveSubagents` on the host plugin to limit live and materializing children in each subagent tree. It defaults to `8` and accepts positive safe integers. A top-level parent starts a pool shared by its local and external descendants; the root parent consumes no slot. Creation and cold resume reserve before yielding, and disposal returns the slot only after cleanup. Instances with pending inbox work and stopping activations remain counted. Sending to a resident child reuses its slot. Delegation depth is a separate policy.
54
54
 
55
55
  The current `maxActiveSubagents` value is sampled before every new or cold-resumed Activation. Raising it admits more children in existing trees; lowering it leaves resident children running and refuses further admissions until usage is below the limit.
56
56
 
@@ -62,7 +62,9 @@ At capacity, creation or cold resume rejects with `ACTIVATION_LIMIT_REACHED` (br
62
62
 
63
63
  ### Local and external children
64
64
 
65
- `startActivation({ provider, label, request, signal, delivery })` returns `{ childId, messageId?, result, dispose }`. Supplying `childId` selects a local backend and guarantees `messageId`. Local children accept later messages and can cold-resume; external children expose one execution and reject continuation. `request.agentOptions` overrides supported child model settings. `delivery: 'parent'` supplies the model-facing completion notice; `delivery: 'caller'` lets workflows await the result without a parent notice or initial return guidance. Local parent delivery requires persistence; caller delivery can use an ephemeral local session. Cold resume requires persistence and Session query.
65
+ `startActivation({ provider, label, prompt, parent, signal, delivery })` returns `{ childId, messageId?, result, dispose }`. Supplying `childId` selects a local backend and guarantees `messageId`. Local children accept later messages and can cold-resume; external children expose one execution and reject continuation. `agentOptions` overrides supported child model settings. `delivery: 'parent'` supplies the model-facing completion notice; `delivery: 'caller'` lets workflows await the result without a parent notice or initial return guidance. Local parent delivery requires persistence; caller delivery can use an ephemeral local session. Cold resume requires persistence and Session query.
66
+
67
+ `rootOf(agent)` resolves a managed local Agent through its existing Activation and checks the exact live child and root instances. Intermediate creators can leave without changing that root; same-id replacements cannot inherit membership. Ordinary live Agents resolve to themselves, while unmanaged delegated Agents are rejected. The query does not activate Sessions.
66
68
 
67
69
  ### Child presets
68
70
 
@@ -70,11 +72,11 @@ In-process spawn accepts an independent `agentPreset`; fork and external backend
70
72
 
71
73
  ### Messaging, interrupting, and discovering
72
74
 
73
- Every exact live Agent can use `sendMessage()` with a direct continuable child; a resident continuable child can also use it with its direct parent. A working target receives the Agent message through Steer at its nearest step; an idle target starts a turn, and only a direct child can be cold-resumed. The parent can also interrupt a running descendant or list its children at any time. A browser continuation prompt independently selects Queue or Steer and may carry image parts: the Host admits and persists each image batch through the attachment store before the child inbox accepts the message, and refuses delivery when the child's declared model does not accept image input. Direct-child discovery reads the parent-owned `subagentCatalog` projection. `listChildren(parentSessionId, signal?)` owns a live-preferred Session observation and returns the catalog asynchronously without reading child logs. It forwards cancellation and releases the observation after materialization. Materialization preserves parent event order in O(D) time for D facts. External entries are leaves and require no child Session observation. Descendant discovery recursively reads local child catalogs in parent event order, observing each reachable Session once. It skips branches whose catalogs cannot be read and returns diagnostics for them; neither path loads or resumes a child Agent.
75
+ `sendMessage()` lets the live root and resident continuable subagents contact any other root or continuable member in the same tree by Session id. The target receives Steer input at its next step or starts an idle turn. Only the cold target resumes, under the subagent tree root; its creation ancestors stay offline and the message retains its actual sender. `rootOf()` resolves the caller’s live root. Agent interruption requires ancestor authority. Browser prompts and user interrupts address only the child Session; the Gateway checks the corresponding action on that Session before any side effect. Parent or global grants do not imply child access. Prompts require a live subagent tree root; the creator may be offline. User interrupts perform no restoration and accept absent targets as no-ops. They select Queue or Steer and admit image batches through the attachment store; incompatible target models reject images. `listDescendants()` discovers members recursively through parent-owned `subagentCatalog` projections. It preserves catalog order, reads each reachable Session once, skips external leaves, and reports unreadable branches without activating Agents.
74
76
 
75
77
  ### Failure and recovery
76
78
 
77
- Starting without the `agents` service rejects with `CONTINUATION_UNAVAILABLE`; an available runtime rejects a missing or replaced parent with `UNAUTHORIZED`. Providers implementing neither execution method are rejected at registration with `UNSUPPORTED_CAPABILITY`; unsupported requested capabilities reject creation with the same code. The caller signal cancels only unpublished work; after publication, `dispose()` cancels the exact activation and waits for its descendants, including pending startups, and their resource cleanup. `result` settles after teardown and notifications, carrying output, optional structured data, and a stop reason; capture failures reject it after teardown. Cleanup failures reject `dispose()` and mark the lifecycle end as failed; the result promise and parent notification retain the captured execution result.
79
+ Starting without the `agents` service rejects with `CONTINUATION_UNAVAILABLE`; an available runtime rejects a missing or replaced parent with `UNAUTHORIZED`. Providers implementing neither execution method are rejected at registration with `UNSUPPORTED_CAPABILITY`; unsupported requested capabilities reject creation with the same code. If a provider is removed or replaced while directory resolution is pending, creation rejects with `PROVIDER_CHANGED` before invoking either provider; retry the delegation against the current registration. The caller signal cancels only unpublished work; after publication, `dispose()` cancels the exact activation and waits for its resource cleanup. Creation descendants continue independently; hosts must await `drainDescendants([root])` before disposing the root handle to stop all members and await pending startup. `result` settles after teardown and notifications, carrying output, optional structured data, and a stop reason; capture failures reject it after teardown. Cleanup failures reject `dispose()` and mark the lifecycle end as failed; the result promise and parent notification retain the captured execution result.
78
80
 
79
81
  -----
80
82
 
@@ -89,7 +91,7 @@ This section explains how the service is built and where the observable behavior
89
91
  ### Design concept
90
92
 
91
93
  - **One service, many providers.** The service is a named-provider registry; each backend registers under a unique name and a request picks one by name.
92
- - **One managed lifetime.** `SubagentManager` owns startup, message admission, capacity, parent relationships, and disposal. Each activation retains a local AgentHandle or external SubagentRun directly; local inbox and idle state belong only to the local variant.
94
+ - **One managed lifetime.** `SubagentManager` owns startup, message admission, capacity, runtime ownership, and disposal. Each activation retains its lifecycle identity and a local AgentHandle or external SubagentRun; the manager publishes paired events through the service's scoped emitter. Local inbox and idle state belong only to the local variant.
93
95
  - **Fulfillment is publication.** `startActivation()` returns only after the child is accepted and its handle can cancel that exact execution.
94
96
  - **Trusted same-process values.** Requests, descriptors, and results are borrowed immutable; serialization and hostile-input validation belong at process and wire boundaries.
95
97
 
@@ -98,10 +100,9 @@ This section explains how the service is built and where the observable behavior
98
100
  | File | Role |
99
101
  |---|---|
100
102
  | [`src/index.ts`](src/index.ts) | Service entry: provider registry, start and continuation API, lifecycle events |
101
- | [`src/manager.ts`](src/manager.ts) | Unified startup, message admission, cold resume, parent ownership, settlement, and disposal |
103
+ | [`src/manager.ts`](src/manager.ts) | Unified startup, message admission, cold resume, runtime ownership, settlement, and disposal |
102
104
  | [`src/activation.ts`](src/activation.ts) | Execution records, capacity slots, child locks, and local output capture |
103
- | [`src/continuation-messages.ts`](src/continuation-messages.ts) | Adjacent-Agent messages, return guidance, and settlement notices |
104
- | [`src/internal.ts`](src/internal.ts) | Host-only Queue and Steer adapters plus standard adjacent-Agent messaging markers |
105
+ | [`src/continuation-messages.ts`](src/continuation-messages.ts) | Agent messages, return guidance, and settlement notices |
105
106
  | [`src/structured.ts`](src/structured.ts) | Activation-scoped structured capture and guards |
106
107
  | [`src/types.ts`](src/types.ts) | Public request, result, and provider contracts |
107
108
  | [`src/descriptor.ts`](src/descriptor.ts) | Versioned `subagent/descriptor` session-event vocabulary |
@@ -114,32 +115,34 @@ This section explains how the service is built and where the observable behavior
114
115
 
115
116
  ### Provider preparation and structured output
116
117
 
117
- The service validates requested capabilities before creation. Local providers supply only `prepareContinuable()`: spawn returns fresh state and fork returns a completed-turn seed. The manager captures the parent model settings, delegated permissions, and composition before creating the child. External providers retain `start()` as a transport adapter and retain their own permission systems. The common manager owns their published execution. Structured tools, instructions, validation, and terminal guards belong to one local activation; they are not persisted as resume configuration. The child can submit its structured result after consuming accepted input and releasing owned descendants. Staging a result closes further input through tool-result policy and any enclosing PTC execution; a rejected result reopens input, while a committed result keeps it closed. Later cold resume has no structured schema.
118
+ The service validates requested capabilities and binds execution to that exact provider instance before creation. The manager receives the bound operation rather than a provider lookup. Local providers supply only `prepareContinuable()`: spawn returns fresh state and fork returns a completed-turn seed. The manager captures the parent model settings, delegated permissions, and composition before creating the child. External providers retain `start()` as a transport adapter and retain their own permission systems. The common manager owns their published execution. Structured tools, instructions, validation, and terminal guards belong to one local activation; they are not persisted as resume configuration. The child can submit its structured result after consuming accepted input. Work that depends on descendants must explicitly wait for their results. Staging a result closes further input through tool-result policy and any enclosing PTC execution; a rejected result reopens input, while a committed result keeps it closed. Later cold resume has no structured schema.
118
119
 
119
120
  External providers mint a fresh `SubagentRun.id` for each execution in the runtime's shared Session id namespace, across all parents and providers. A collision with a resident Agent, Session, or activation rejects startup with `DUPLICATE_CHILD` and disposes the new external handle without replacing the existing execution.
120
121
 
121
122
  ### Activation settlement
122
123
 
123
- The manager reserves child identity and capacity, materializes a local Agent or external execution, and accepts the initial task. Local admission closes after Agent activity, pending input, and owned descendants finish, with activity revalidated after the final Session flush. Both local and external activations deliver their result after handle cleanup, capacity release, and settlement notifications. Host waits join progressing descendants and their cleanup, including failed executions; idle parked subtrees remain resident without delaying host completion. Closing admission and disposing the handle prevent late work from entering a released Agent. Parent delivery emits its notice after settlement; caller delivery leaves collection to the awaiting workflow. Headless hosts repeat `agent.whenIdle()` and `waitForChildren(agent)` until no child work remains and the parent stays idle with an unchanged Session sequence across the child check, so completion notices can produce the final parent answer.
124
+ The manager reserves child identity and capacity, materializes a local Agent or external execution, and accepts the initial task. Local admission closes after Agent activity and pending input finish, with activity revalidated after the final Session flush. Both local and external activations deliver their result after handle cleanup, capacity release, and settlement notifications. Host waits on the subagent tree root join progressing members and their cleanup, including failed executions; idle members with parked input remain resident without delaying host completion. Ordinary members do not wait for descendants. Closing admission and disposing the handle prevent late work from entering a released Agent. Parent delivery emits its notice after settlement only if the creator is still online; caller delivery leaves collection to the awaiting workflow. Headless hosts repeat `agent.whenIdle()` and `waitForTreeWork(agent)` until no child work remains and the parent stays idle with an unchanged Session sequence across the child check, so completion notices can produce the final parent answer.
125
+
126
+ Settlement attribution records the exact execution stop reason without altering model-facing notice content. Historical notices can omit this field; readers must not infer it from the English summary.
124
127
 
125
- A local Agent failure without a subsequently committed `turn/end` settles as `error` after its owned descendants finish. Unclaimed input cannot keep that failed activation resident. A later committed turn ending supersedes the live failure and supplies the recovered outcome.
128
+ A local Agent failure without a subsequently committed `turn/end` settles as `error` independently of its descendants. Unclaimed input cannot keep that failed activation resident. A later committed turn ending supersedes the live failure and supplies the recovered outcome.
126
129
 
127
130
  Successful local creation appends a `subagent/catalog` fact to the parent Session regardless of result delivery. External creation appends a catalog fact only with `delivery: 'parent'`; caller-owned external executions retain their caller's membership records. External entries use `mode: 'external'` to identify children without a local Session. Catalog entries record membership once at creation and carry no execution status. Complete results go to the caller or the parent completion notice. Projections exclude inherited facts. Direct lists read one parent projection, so completed local workflow children remain discoverable and can be opened or continued. Catalog payload v0 records local modes; v1 also accepts unknown mode; v2 records external executions. Readers support all three versions. Historical migration appends a v1 `subagent/catalog` from a readable child header when its descriptor is unavailable; local creation retains v0. Its `mode: 'unknown'` projection keeps the child visible without claiming continuation support; an existing complete entry remains authoritative.
128
131
 
129
132
  <a id="restoring-child-composition"></a>
130
133
  ### Restoring child composition
131
134
 
132
- An independently selected spawn records `agent-preset/selected` before its first own `subagent/descriptor`. Cold resume excludes the inherited event prefix and checks that ordering, then reads the preset id from the existing `agentPreset` projection. It mounts that id without requiring the original subagent provider to remain registered. A missing or broken selected preset rejects restoration; it does not fall back to the parent or deployment default.
135
+ Cold resume mounts the target's saved preset from its `agentPreset` projection or creation header without reading its creator's current composition. A missing or broken saved preset rejects restoration. The original subagent provider need not remain registered.
133
136
 
134
- Logs without that selection before the first own descriptor, including historical spawn and fork logs, retain `composeFrom` of the parent's current composition. A header preset id, an inherited selection, or a selection after the descriptor does not opt a child into independent restoration, including a fork with no inherited events. Session and descriptor formats are unchanged. Independent cold resume uses the currently registered preset definition, without preserving an earlier revision across restarts.
137
+ Targets without a saved preset use the host composition and retain their historical descriptor's persona and tool restrictions. Persisted permission policies replay from the target's own log. Restoration uses the currently registered preset definition, without preserving an earlier revision across restarts.
135
138
 
136
139
  ### Ownership and invariants
137
140
 
138
- - **The manager owns accepted work** — unpublished failures roll back; published handles cancel their exact activation and await child-first disposal.
141
+ - **The manager owns accepted work** — unpublished failures roll back; published handles cancel and release only their exact activation. Every instance belongs to the subagent tree root; creation parent ids remain unchanged.
139
142
  - **Registration is effect-scoped** — removing a provider blocks new starts but never revokes accepted runs.
140
- - **Agent-message authority is exact adjacency** — `sendMessage()` requires the exact live sender; every sender may target a direct continuable child, while only a sender with a resident continuable Activation may target its direct parent.
143
+ - **Agent-message authority follows the tree** — the exact live sender and target must belong to one root. Cold delivery verifies the target descriptor and creation catalogs before restoring only the target. Final inbox admission rechecks the sender and subagent tree root; failed restoration releases the new instance.
141
144
  - **The descriptor is log-only** — a session event absent from model history and retained across compaction; the writer records the resolved child provider, model, and reasoning effort for cold resume. Historical one-shot descriptors remain readable.
142
- - **This runtime answers archive admission for children** ([seam](../../workspace/workspace/README.md)) — `workspace/session-activity` reports the live subagent descendants inside a turn as the `subagent` family, found by the durable lineage this package records (`parentSession` with the subagent origin, any depth, never a fork) and labelled from each child's descriptor through a live Session observation when the Session query service is composed, otherwise by id; `workspace/session-stop` cancels each of them with the parent cause, one at a time, so one child refusing its cancel is logged while its siblings still stop. The parent's own turn, its jobs, and the archived-lineage step gate belong to the API Session Controller.
145
+ - **This runtime answers archive admission for children** ([seam](../../workspace/workspace/README.md)) — activity queries, parent-cause cancellation, and pre-step rejection use managed creation ancestors even after an intermediate creator goes offline. Agents without a published Activation use live header ancestry; ordinary forks remain independent. Labels use the current identity projection's latest descriptor only when it belongs to the child's own log; missing, invalid, inherited, or unlabelled identities report only the id. Reporting requires no Session query service and starts after identity projection registration. Each cancellation failure is contained. The Agent registry owns the parent’s turn, job providers own jobs, and the API Session Controller checks archived Sessions and available header ancestry.
143
146
 
144
147
  </details>
145
148
 
@@ -169,7 +172,7 @@ Read these pages when the package-level contract is not enough. They move from t
169
172
 
170
173
  #### What the model sees
171
174
 
172
- Parent delivery emits a user-role status notice containing the child’s nonempty final text blocks. When the child's last action before that text was a message to its parent, with no input claimed and no tool call logged after it, the notice replaces them with `It sent you a message just before finishing, so its closing message is omitted.`; the parent recovers omitted closing text only by messaging the child again. External notices also state that further messages are unsupported. Reasoning and other nontext blocks are excluded. Every parent notice includes available structured output as `Structured result: <JSON>` and the provider’s safe diagnostic as a separate text block. Empty closing text is reported as `It left no closing message.` Caller delivery emits no notice; SDK lifecycle notifications retain complete child output when cleanup succeeds.
175
+ Parent delivery sends a user-role status notice to the resident direct parent in the same tree, including an idle parent. It does not restore an offline parent. The notice contains the child’s nonempty final text blocks. When the child's last action before that text was a message to its parent, with no input claimed and no tool call logged after it, the notice replaces them with `It sent you a message just before finishing, so its closing message is omitted.`; the parent recovers omitted closing text only by messaging the child again. External notices also state that further messages are unsupported. Reasoning and other nontext blocks are excluded. Every parent notice includes available structured output as `Structured result: <JSON>` and the provider’s safe diagnostic as a separate text block. Empty closing text is reported as `It left no closing message.` Caller delivery emits no notice; SDK lifecycle notifications retain complete child output when cleanup succeeds.
173
176
 
174
177
  #### Token effect
175
178
 
@@ -179,6 +182,26 @@ One notice per settled activation using parent delivery. Caller delivery adds no
179
182
 
180
183
  Append-only in the parent: the notice follows its reusable request prefix. Reaching an idle parent starts one independent model request; reaching a busy one does not.
181
184
 
185
+ ### Continuable child return guidance
186
+
187
+ #### What the model sees
188
+
189
+ Local children using `delivery: 'parent'` receive the result-delivery guidance below in their initial task, whether or not messaging tools are installed. Tool usage and communication identity belong to [tool-subagent-control](../tool-subagent-control/README.md).
190
+
191
+ ##### Return guidance
192
+
193
+ ```markdown
194
+ Your final answer is delivered automatically if your parent is still online. Include the result and relevant evidence in that answer; the parent does not receive your full transcript, tool output, or reasoning. If your last action is a message to your parent, the completion notice omits your final answer; include the result and relevant evidence in that message.
195
+ ```
196
+
197
+ #### Token effect
198
+
199
+ One fixed guidance block per local parent-delivered child's initial task; caller delivery adds none.
200
+
201
+ #### KV Cache effect
202
+
203
+ The guidance remains in the child's retained task history. It does not change the parent's system prompt.
204
+
182
205
  ### Child delegation-scope statement
183
206
 
184
207
  #### What the model sees
@@ -214,13 +237,11 @@ These limits define when the seam is a poor fit or needs special operational car
214
237
 
215
238
  - **Descendant reads are sequential** — each reachable catalog, including one-shot children, takes one observation. A cold Session without a valid prepared observation requires a full-log read; large cold trees can accumulate storage latency.
216
239
  - **External children execute once** — ACP, DSH SDK, Codex, and Claude Code have no local child Session and accept no follow-up input. Their parent-owned records remain discoverable after disposal.
217
- - **Adjacent model messaging only** — `sendMessage()` requires an exact live sender; every sender may target a direct continuable child, while only a sender with a resident continuable Activation may target its direct parent. Browser prompts use a separate human Queue-or-Steer control path.
218
- - **A direct parent must remain live for child-to-parent delivery** — the service has no durable parent mailbox; a missing parent rejects the message instead of accepting work it cannot wake.
240
+ - **Messaging stays within one tree** — targets use Session ids and must be the root or continuable members. Only the restored target consumes activation capacity. Browser prompts retain their separate human Queue-or-Steer control path.
219
241
  - **Wake gap during cancellation convergence** — a follow-up accepted after an interrupt signal but before the Agent becomes idle stays queued until another waking send.
220
242
  - **Pending injected context retains an Activation** — settlement conservatively treats every Inbox occurrence as unfinished. Context parked after the Agent becomes idle keeps the child and its live ancestors resident until a waking delivery claims it, a queue mutation removes it, or manager teardown discards it. Host completion joins active work, pending child creation, and resource cleanup, but does not wait for a subtree containing only idle parked inboxes; it neither completes those activation results nor discards their messages.
221
243
  - **Process-local residency** — the Activation inbox and ownership graph do not coordinate two harness processes; concurrent access to one persistence store needs a durable mailbox and cross-process lease protocol.
222
244
  - **No replay of accepted-but-unlogged messages** — a crash can lose an accepted prompt that never reached the child's session log; the lost message is not replayed automatically.
223
- - **No durable parent mailbox** — child-to-parent messages require a resident continuable child and live direct parent, and provide acceptance identity rather than exactly-once delivery.
224
245
  - **Lifecycle events are observe-only** — a run-affecting `subagent/end` continuation or decision API waits for a concrete consumer.
225
246
 
226
247
  <a id="dev-note"></a>
package/README.zh.md CHANGED
@@ -50,7 +50,7 @@ kind: "package-reference"
50
50
 
51
51
  ### Activation 容量
52
52
 
53
- 在 Host 插件上设置 `maxActiveSubagents`,限制每棵 activation 树中在线和正在创建的子级数量。默认值为 `8`,接受正安全整数。顶层父级建立由本地和外部后代共享的池,根父级不占名额。新建和冷恢复在让出执行前预留名额,资源释放完成后才归还。等待后代、有待处理收件箱内容以及正在停止的 activation 仍计入容量;向驻留子级发送消息复用其名额。委派深度是独立策略。
53
+ 在 Host 插件上设置 `maxActiveSubagents`,限制每棵 subagent 树中在线和正在创建的子级数量。默认值为 `8`,接受正安全整数。顶层父级建立由本地和外部后代共享的池,根父级不占名额。新建和冷恢复在让出执行前预留名额,资源释放完成后才归还。有待处理收件箱内容以及正在停止的 activation 仍计入容量;向驻留子级发送消息复用其名额。委派深度是独立策略。
54
54
 
55
55
  每次新建或冷恢复 Activation 前都会读取当前 `maxActiveSubagents`。调高后已有树可接纳更多子代理;调低后驻留子代理继续运行,使用量降至上限以下前拒绝新接纳。
56
56
 
@@ -62,7 +62,9 @@ kind: "package-reference"
62
62
 
63
63
  ### 本地与外部子级
64
64
 
65
- `startActivation({ provider, label, request, signal, delivery })` 返回 `{ childId, messageId?, result, dispose }`。提供 `childId` 会选择本地后端,并保证返回 `messageId`。本地子级接受后续消息并支持冷恢复;外部子级只暴露一次执行,拒绝继续输入。`request.agentOptions` 覆盖后端支持的子级模型设置。`delivery: 'parent'` 提供面向模型的完成通知;`delivery: 'caller'` 让工作流等待结果,不发送父级通知,也不附加初始返回指导。本地父级投递需要持久化,调用方投递可以使用临时本地会话;冷恢复需要持久化与 Session 查询服务。
65
+ `startActivation({ provider, label, prompt, parent, signal, delivery })` 返回 `{ childId, messageId?, result, dispose }`。提供 `childId` 会选择本地后端,并保证返回 `messageId`。本地子级接受后续消息并支持冷恢复;外部子级只暴露一次执行,拒绝继续输入。`agentOptions` 覆盖后端支持的子级模型设置。`delivery: 'parent'` 提供面向模型的完成通知;`delivery: 'caller'` 让工作流等待结果,不发送父级通知,也不附加初始返回指导。本地父级投递需要持久化,调用方投递可以使用临时本地会话;冷恢复需要持久化与 Session 查询服务。
66
+
67
+ `rootOf(agent)` 通过托管本地 Agent 已有的 Activation 解析树根,并校验子级和树根的确切存活实例。中间创建者退出不改变该树根;同 id 替代实例不能继承成员身份。普通存活 Agent 返回自身,非托管的委派 Agent 会被拒绝。查询不会激活 Session。
66
68
 
67
69
  ### 子级 preset
68
70
 
@@ -70,11 +72,11 @@ kind: "package-reference"
70
72
 
71
73
  ### 消息、中断与发现
72
74
 
73
- 每个确切在线 Agent 都可以对直接可继续 child 使用 `sendMessage()`;驻留的可继续 child 还可以对自己的直接 parent 使用它。正在工作的目标通过 Steer 在最近 step 接收 Agent 消息;空闲目标启动轮次,且只有直接 child 可以冷恢复。parent 也可以随时中断正在运行的后代或列举自己的子级。浏览器发出的继续执行 prompt 会独立选择 Queue 或 Steer,并且可以携带图片部分:Host 先通过附件存储完成整批图片的准入与持久化,子级 inbox 才接受这条消息;当子级声明的模型不接受图片输入时拒绝投递。 直接子级发现读取 parent 自有的 `subagentCatalog` projection。`listChildren(parentSessionId, signal?)` 持有一次优先实时来源的 Session 观察,异步返回目录,不读取子级日志。它转发取消信号,并在物化后释放观察。物化以 O(D) 时间保留 D 条事实的父日志事件顺序。外部条目是叶节点,不需要观察子 Session。后代发现按父事件顺序递归读取子级目录,每个可达 Session 观察一次。无法读取目录的分支会被跳过,并返回诊断;两条路径都不加载或恢复子级 Agent。
75
+ `sendMessage()` 允许在线根和驻留的可继续子代理,按 Session id 联系同一棵树中的任意其他根或可继续成员。目标在下一步接收 Steer 输入,或在空闲时开始轮次。仅在 subagent 树根下恢复冷目标,其创建祖先保持离线;消息保留实际发送者。`rootOf()` 解析调用方的在线根。Agent 中断要求祖先权限。浏览器提示词和用户中断仅按子 Session 寻址;Gateway 在任何副作用之前检查该 Session 上对应操作的权限。父级或 global 授权不意味着子级访问权。提示词要求 subagent 树根在线;创建者可以离线。用户中断不恢复目标,目标缺席时接受为无操作。提示词选择 Queue 或 Steer,经附件存储接受图片批次;不兼容的目标模型拒绝图片。`listDescendants()` 通过父级拥有的 `subagentCatalog` 投影递归发现成员。它保留目录顺序,每个可达 Session 读取一次,跳过外部叶子,并报告不可读分支而不激活 Agent。
74
76
 
75
77
  ### 失败与恢复
76
78
 
77
- 缺少 `agents` 服务时,启动请求以 `CONTINUATION_UNAVAILABLE` 拒绝;运行时可用但父级缺失或被替换时,以 `UNAUTHORIZED` 拒绝。未实现任何执行方法的提供方会在注册时以 `UNSUPPORTED_CAPABILITY` 被拒绝;请求不受支持的能力会以同一码使创建失败。调用方信号仅取消尚未发布的工作;发布后通过 `dispose()` 取消该次 activation,并等待其后代(包括正在启动的后代)及其资源清理完成。`result` 在清理与通知结束后完成,携带输出、可选结构化数据与停止原因;结果捕获故障在清理后使其拒绝。清理失败使 `dispose()` 拒绝,并将生命周期结束事件标记为失败;结果 promise 与父级通知保留已捕获的执行结果。
79
+ 缺少 `agents` 服务时,启动请求以 `CONTINUATION_UNAVAILABLE` 拒绝;运行时可用但父级缺失或被替换时,以 `UNAUTHORIZED` 拒绝。未实现任何执行方法的提供方会在注册时以 `UNSUPPORTED_CAPABILITY` 被拒绝;请求不受支持的能力会以同一码使创建失败。如果等待目录解析期间提供方被移除或替换,创建会在调用任何一方之前以 `PROVIDER_CHANGED` 拒绝;调用方可根据当前注册重试委派。调用方信号仅取消尚未发布的工作;发布后通过 `dispose()` 取消该次 activation,并等待其资源清理完成。创建后代独立继续运行;宿主必须在释放根句柄前等待 `drainDescendants([root])`,以停止所有成员并等待正在启动的工作。`result` 在清理与通知结束后完成,携带输出、可选结构化数据与停止原因;结果捕获故障在清理后使其拒绝。清理失败使 `dispose()` 拒绝,并将生命周期结束事件标记为失败;结果 promise 与父级通知保留已捕获的执行结果。
78
80
 
79
81
  -----
80
82
 
@@ -89,7 +91,7 @@ kind: "package-reference"
89
91
  ### 设计理念
90
92
 
91
93
  - **一个服务,多个提供方。** 服务是具名提供方注册表;每个后端以唯一名称注册,请求按名称选择一个。
92
- - **统一受管理生命周期。** `SubagentManager` 统一管理启动、消息准入、容量、父子关系与释放。每条 activation 直接持有本地 AgentHandle 或外部 SubagentRun;本地 inbox 与空闲状态仅属于本地分支。
94
+ - **统一受管理生命周期。** `SubagentManager` 统一管理启动、消息准入、容量、运行归属与释放。每条 activation 持有生命周期标识和本地 AgentHandle 或外部 SubagentRun;manager 通过服务的作用域事件发送器发布成对事件。本地 inbox 与空闲状态仅属于本地分支。
93
95
  - **兑现即发布。** `startActivation()` 仅在子级已接受且句柄可取消该次执行后返回。
94
96
  - **同进程值可信。** 请求、描述符与结果按不可变约定借用;序列化与不可信输入校验属于进程与协议边界。
95
97
 
@@ -98,10 +100,9 @@ kind: "package-reference"
98
100
  | 文件 | 职责 |
99
101
  |---|---|
100
102
  | [`src/index.ts`](src/index.ts) | 服务入口:提供方注册表、启动与继续 API、生命周期事件 |
101
- | [`src/manager.ts`](src/manager.ts) | 统一管理启动、消息准入、冷恢复、父子所有权、结算与释放 |
103
+ | [`src/manager.ts`](src/manager.ts) | 统一管理启动、消息准入、冷恢复、运行归属、结算与释放 |
102
104
  | [`src/activation.ts`](src/activation.ts) | 执行期记录、容量槽、子级锁与本地输出捕获 |
103
- | [`src/continuation-messages.ts`](src/continuation-messages.ts) | 相邻 Agent 消息、返回指引与结算通知 |
104
- | [`src/internal.ts`](src/internal.ts) | Host 专用 Queue 与 Steer 适配器,以及标准相邻 Agent 消息标记 |
105
+ | [`src/continuation-messages.ts`](src/continuation-messages.ts) | agent 消息、返回指引与结算通知 |
105
106
  | [`src/structured.ts`](src/structured.ts) | Activation 局部结构化捕获与保护 |
106
107
  | [`src/types.ts`](src/types.ts) | 公开的请求、结果与提供方约定 |
107
108
  | [`src/descriptor.ts`](src/descriptor.ts) | 版本化的 `subagent/descriptor` 会话事件词汇 |
@@ -114,32 +115,34 @@ kind: "package-reference"
114
115
 
115
116
  ### 提供方准备与结构化输出
116
117
 
117
- 服务在创建前校验请求能力。本地提供方只提供 `prepareContinuable()`:spawn 返回全新状态,fork 返回已完成轮次的初始内容。管理器在创建子级前捕获父级模型设置、委派权限和组合。外部提供方保留 `start()` 作为传输适配器,并保留各自的权限系统;统一管理器拥有已发布的执行。结构化工具、指令、校验与终止保护仅属于一次本地 activation,不作为恢复配置持久化。子代理只能在消费已接受的输入且所属后代释放后提交结构化结果。结果暂存后,在工具结果策略及外层 PTC 执行完成前拒绝继续输入;结果被拒绝后重新开放输入,提交成功后则保持关闭。后续冷恢复不带结构化 schema。
118
+ 服务在创建前校验请求能力,并把执行绑定到该确切提供方实例。管理器接收绑定后的操作,而不再按名称查找提供方。本地提供方只提供 `prepareContinuable()`:spawn 返回全新状态,fork 返回已完成轮次的初始内容。管理器在创建子级前捕获父级模型设置、委派权限和组合。外部提供方保留 `start()` 作为传输适配器,并保留各自的权限系统;统一管理器拥有已发布的执行。结构化工具、指令、校验与终止保护仅属于一次本地 activation,不作为恢复配置持久化。子代理消费已接受的输入后即可提交结构化结果。依赖后代结果的工作必须显式等待。结果暂存后,在工具结果策略及外层 PTC 执行完成前拒绝继续输入;结果被拒绝后重新开放输入,提交成功后则保持关闭。后续冷恢复不带结构化 schema。
118
119
 
119
120
  外部提供方为每次执行生成新的 `SubagentRun.id`,在运行时共享的 Session id 命名空间中跨所有父级和提供方保持唯一。与驻留 Agent、Session 或 activation 冲突时,启动以 `DUPLICATE_CHILD` 拒绝,并释放新的外部句柄,不替换已有执行。
120
121
 
121
122
  ### Activation 结算
122
123
 
123
- 管理器预留子级身份与容量,创建本地 Agent 或外部执行,并接受初始任务。本地 Agent 活动、待处理输入及所拥有的后代均结束后,管理器在最终 Session flush 后重新验证活动状态并关闭准入。本地与外部 activation 都在句柄清理、容量归还及结算通知结束后交付结果。宿主等待会汇合仍在推进的后代及其清理,包括失败的执行;空闲停放子树继续驻留,但不延迟宿主完成。关闭准入并释放句柄可防止迟到工作进入已释放的 Agent。父级投递在结算后发送通知;调用方投递由等待中的工作流收集。Headless 宿主交替等待 `agent.whenIdle()` 与 `waitForChildren(agent)`,直至没有子级工作,且父级在检查子级期间保持空闲、Session 序号不变,让完成通知可驱动父级生成最终答案。
124
+ 管理器预留子级身份与容量,创建本地 Agent 或外部执行,并接受初始任务。本地 Agent 活动和待处理输入结束后,管理器在最终 Session flush 后重新验证活动状态并关闭准入。本地与外部 activation 都在句柄清理、容量归还及结算通知结束后交付结果。宿主在 subagent 树根上等待仍在推进的成员及其清理,包括失败的执行;有停放输入的空闲成员继续驻留,但不延迟宿主完成。普通成员不等待后代。关闭准入并释放句柄可防止迟到工作进入已释放的 Agent。父级投递仅在创建者仍在线时于结算后发送通知;调用方投递由等待中的工作流收集。Headless 宿主交替等待 `agent.whenIdle()` 与 `waitForTreeWork(agent)`,直至没有子级工作,且父级在检查子级期间保持空闲、Session 序号不变,让完成通知可驱动父级生成最终答案。
125
+
126
+ 结算归属信息记录确切的执行停止原因,不改变面向模型的通知内容。历史通知可以缺少该字段;读取方不得从英文摘要推断它。
124
127
 
125
- 本地 Agent 发生失败且后续没有成功提交 `turn/end` 时,会在所拥有的后代结束后以 `error` 结算。未认领的输入不会使该失败 activation 一直驻留。后续成功提交的轮次结束记录会取代实时失败,提供恢复后的结果。
128
+ 本地 Agent 发生失败且后续没有成功提交 `turn/end` 时,会独立于后代以 `error` 结算。未认领的输入不会使该失败 activation 一直驻留。后续成功提交的轮次结束记录会取代实时失败,提供恢复后的结果。
126
129
 
127
130
  本地创建成功后,无论结果交付给谁,都会向父 Session 追加 `subagent/catalog` 事实。外部创建仅在使用 `delivery: 'parent'` 时追加目录事实;调用方拥有的外部执行保留调用方自己的成员记录。外部条目以 `mode: 'external'` 标记没有本地 Session 的子级。目录仅在创建时记录一次成员关系,不携带执行状态。完整结果交给调用方或父级完成通知。投影排除继承事实。直接列表读取一个父级投影,因此已完成的本地工作流子级仍可被发现、打开或继续。Catalog 载荷 v0 记录本地模式,v1 还接受未知模式,v2 记录外部执行,读取器支持三版。历史迁移在 descriptor 不可用时根据可读子 header 追加 v1 `subagent/catalog`;本地创建保留 v0。其 `mode: 'unknown'` 投影让子会话保持可见,但不表示支持继续执行;已有完整条目仍具有权威性。
128
131
 
129
132
  <a id="restoring-child-composition"></a>
130
133
  ### 恢复子级组装
131
134
 
132
- 独立选择的 spawn 在首条自有 `subagent/descriptor` 之前记录 `agent-preset/selected`。冷恢复排除继承事件前缀并检查此顺序,再从已有 `agentPreset` 投影读取 preset id。恢复挂载该 id,不要求原始 subagent 提供方仍然注册。所选 preset 缺失或损坏时拒绝恢复,不回退到父方或部署默认值。
135
+ 冷恢复从目标的 `agentPreset` 投影或创建 header 读取已保存的 preset 并挂载,不读取创建者当前组装。已保存的 preset 缺失或损坏时拒绝恢复。原始 subagent 提供方不必仍然注册。
133
136
 
134
- 首条自有 descriptor 前没有该选择的日志,包括历史 spawn 与 fork 日志,继续通过 `composeFrom` 加入父方当前组装。header 中的 preset id、继承的选择或 descriptor 之后的选择,都不会让子级采用独立恢复;没有继承事件的 fork 也遵守此规则。Session 与 descriptor 格式不变。独立冷恢复使用当前注册的 preset 定义,不跨重启保留旧代际。
137
+ 没有保存 preset 的目标使用宿主组装,并保留历史 descriptor 中的 persona 和工具限制。持久权限策略从目标自身日志回放。恢复使用当前注册的 preset 定义,不跨重启保留旧代际。
135
138
 
136
139
  ### 所有权与不变式
137
140
 
138
- - **管理器拥有已接受工作**——未发布的失败会回滚;已发布句柄取消对应 activation,并等待子级优先释放。
141
+ - **管理器拥有已接受工作**——未发布的失败会回滚;已发布句柄仅取消并释放确切 activation。所有实例归 subagent 树根管理;创建父级 id 保持不变。
139
142
  - **注册受 effect 作用域约束**——移除提供方会阻止新启动,但绝不撤销已接受的运行。
140
- - **Agent 消息权限基于确切相邻关系**——`sendMessage()` 要求确切在线 sender;每个 sender 都可以指定直接可继续 child,只有具备驻留可继续 Activation 的 sender 可以指定自己的直接 parent。
143
+ - **Agent 消息权限由树决定**——确切在线发送者和目标必须属于同一个根。冷投递验证目标描述符和创建目录后仅恢复目标。最终收件箱准入重新检查发送者与 subagent 树根;恢复失败释放新建实例。
141
144
  - **描述符仅进日志**——它是会话事件,不进入模型历史,并跨压缩(compaction)保留;写入器记录解析后的子级提供方、模型与推理强度,用于冷恢复。历史 one-shot 描述符仍可读取。
142
- - **本 runtime 为子代理回答归档准入**([接缝](../../workspace/workspace/README.zh.md))——`workspace/session-activity` 把回合中的在线子代理子孙作为 `subagent` 族报告:按本包记录的持久化血缘查找(带 subagent 来源的 `parentSession`,任意深度,从不包括 fork),组合了 Session query 服务时经一次活会话 observation 从各 child 的描述符取名称,否则只报 id;`workspace/session-stop` 以父级原因逐个取消它们,一个拒绝取消的 child 只记日志,其兄弟仍会停止。父级自身的回合、它的任务以及已归档血缘的步骤门禁归 API Session Controller。
145
+ - **本 runtime 为子代理回答归档准入**([接缝](../../workspace/workspace/README.zh.md))——活动查询、以父级原因取消和步骤执行前的拒绝都使用托管实例的创建祖先,即使中间创建者已离线。尚无已发布 Activation 的 Agent 使用在线 header 血缘;普通 fork 保持独立。名称取自当前身份投影中的最新 descriptor,且该 descriptor 必须属于孩子自身的日志;身份缺失、无效、来自继承或没有名称时只报告 id。报告不依赖 Session query 服务,并在身份投影注册完成后启用。每次取消的失败都单独收敛。Agent 注册表拥有父级回合,job 提供方拥有任务,API Session Controller 检查已归档 Session 和可用的 header 血缘。
143
146
 
144
147
  </details>
145
148
 
@@ -169,7 +172,7 @@ kind: "package-reference"
169
172
 
170
173
  #### 模型看到什么
171
174
 
172
- 父级投递发送包含子级最终输出中非空文本块的 user-role 状态通知。若子级在该文本之前的最后一个动作是向父级发送消息,且此后既未领取输入也未记录任何工具调用,通知会以 `It sent you a message just before finishing, so its closing message is omitted.` 替代这些文本块;父级只有再次向子级发送消息才能取回被省略的收尾文本。外部通知还说明不支持后续消息。推理及其他非文本块被排除。每条父级通知都会以 `Structured result: <JSON>` 附带可用的结构化输出,并以独立文本块附带提供方安全诊断。收尾文本为空时,通知使用 `It left no closing message.`。调用方投递不发送通知;清理成功时 SDK 生命周期通知保留完整子级输出。
175
+ 父级投递向同树中驻留的直接父级发送 user-role 状态通知,包括空闲父级。它不会恢复离线父级。通知包含子级最终输出中的非空文本块。若子级在该文本之前的最后一个动作是向父级发送消息,且此后既未领取输入也未记录任何工具调用,通知会以 `It sent you a message just before finishing, so its closing message is omitted.` 替代这些文本块;父级只有再次向子级发送消息才能取回被省略的收尾文本。外部通知还说明不支持后续消息。推理及其他非文本块被排除。每条父级通知都会以 `Structured result: <JSON>` 附带可用的结构化输出,并以独立文本块附带提供方安全诊断。收尾文本为空时,通知使用 `It left no closing message.`。调用方投递不发送通知;清理成功时 SDK 生命周期通知保留完整子级输出。
173
176
 
174
177
  #### Token 影响
175
178
 
@@ -179,6 +182,26 @@ kind: "package-reference"
179
182
 
180
183
  在父级中仅追加:通知位于其可复用请求前缀之后。到达空闲父级会启动一次独立的模型请求,到达繁忙父级则不会。
181
184
 
185
+ ### 可继续执行子级的返回指导
186
+
187
+ #### 模型看到什么
188
+
189
+ 采用 `delivery: 'parent'` 的本地子级会在初始任务中收到以下结果交付指导,与是否安装通信工具无关。工具用法和通信身份由 [tool-subagent-control](../tool-subagent-control/README.zh.md) 提供。
190
+
191
+ ##### 返回指导
192
+
193
+ ```markdown
194
+ Your final answer is delivered automatically if your parent is still online. Include the result and relevant evidence in that answer; the parent does not receive your full transcript, tool output, or reasoning. If your last action is a message to your parent, the completion notice omits your final answer; include the result and relevant evidence in that message.
195
+ ```
196
+
197
+ #### Token 影响
198
+
199
+ 每个采用父级交付的本地子级初始任务增加一个固定指导块;调用方交付不增加。
200
+
201
+ #### KV Cache 影响
202
+
203
+ 指导保留在子级的任务历史中,不改变父级系统提示词。
204
+
182
205
  ### 子级委派范围声明
183
206
 
184
207
  #### 模型看到什么
@@ -214,13 +237,11 @@ You are a delegated subagent: your permission scope was fixed when you were star
214
237
 
215
238
  - **后代读取串行执行**——每个可达目录(包括一次性子级)都需要一次观察。冷 Session 缺少有效的 prepared 观察时需要读取完整日志;大型冷会话树可能累积存储延迟。
216
239
  - **外部子级执行一次**——ACP、DSH SDK、Codex 与 Claude Code 没有本地子 Session,也不接受后续输入。释放后仍可发现父级拥有的执行记录。
217
- - **仅允许相邻模型消息**——`sendMessage()` 要求确切在线 sender;每个 sender 都可以指定直接可继续 child,只有具备驻留可继续 Activation 的 sender 可以指定自己的直接 parent。浏览器提示使用独立的人类 Queue 或 Steer 控制路径。
218
- - **child 到 parent 的投递要求直接 parent 保持在线**——服务没有持久 parent mailbox;parent 缺失时会拒绝消息,而非接受无法唤醒的工作。
240
+ - **消息限定在一棵树内**——目标使用 Session id,必须是根或可继续成员。仅恢复的目标占用激活容量。浏览器提示词保留独立的人类 Queue 或 Steer 控制路径。
219
241
  - **取消收敛期间存在唤醒缺口**——中断信号发出后、Agent 进入 idle 前被接受的后续消息会保持排队,直到另一条唤醒发送到达。
220
242
  - **待处理的注入上下文会保留 Activation**——settlement 会保守地把每个 Inbox occurrence 都视为未完成。Agent 进入 idle 后停放的上下文会让 child 及其在线祖先继续驻留,直到唤醒投递将其 claim、queue 变更将其移除,或 manager teardown 将其丢弃。宿主完成检查等待活动工作、待创建子级与资源清理,但不会等待仅包含空闲停放 Inbox 的子树;它既不结算这些 activation 的结果,也不丢弃其消息。
221
243
  - **驻留仅限进程内**——Activation inbox 与所有权图不会在两个 harness 进程之间协调;对单个持久化存储的并发访问需要持久化邮箱与跨进程租约协议。
222
244
  - **不回放已接受但未记录的消息**——崩溃可能丢失从未写入子会话日志、已被接受的提示词;丢失的消息不会自动回放。
223
- - **没有持久化 parent mailbox**——child 到 parent 的消息要求驻留的可继续 child 与在线直接 parent,提供的是接受标识,不保证恰好一次投递。
224
245
  - **生命周期事件只供观察**——影响运行的 `subagent/end` 延续或决策接口仍需等待具体消费方。
225
246
 
226
247
  <a id="dev-note"></a>