A request signal aborted BEFORE the run starts never fires an `abort` event (`addEventListener` only fires on the transition), so the backend-level bridge missed it and ran the child to `completed`. The driver now checks `request.signal?.aborted` at the top of the result path and settles `aborted` without running the child. Regression test proven red on the pre-fix code. Also refresh two stale RFC prose blocks the round-1 fix left behind: the subagent RFC's Problem statement (cited the removed `TODO(sub-agents)` markers and claimed nothing existed yet) and the unify-id RFC's fork/spawn risk bullet (described the seam as "explicitly deferred" via `AgentLoop.create`'s old TODO), now pointing at the realized seam.
@deepseek-ai/dsh-subagent-spawn
The in-process spawn subagent backend: a SubagentProvider that runs each child as a fresh child Agent on the same cordis context (ctx.agents) — its own session, its own (or the parent's) model, zero inherited conversation. The cheapest transport, reusing the agent factory's quiescent AgentHandle teardown.
It also exports the shared in-process run driver (startInProcessRun) that the fork backend builds on — spawn and fork differ only in the session seed.
What it does
start(request) →
- computes child depth =
depthOf(parent) + 1; ifrequest.maxDepthis set and exceeded, throwsSubagentDepthError(thedepthLimitcapability); - creates a child via
ctx.agents.createwith a freshAgentId/SessionId, the parent'scwd+parentSessionlineage, andagentOptions(the child inherits the parent's model by default — a child with no model can't run — overridable viarequest.agentOptions.model; the system prompt is NOT inherited); - drives the one-shot:
child.send(prompt)thenawait child.whenIdle()(ordering matters —sendenqueues synchronously, sowhenIdleobserves the queued work and resolves on the child'srunning → idletransition, never before the turn starts); - reads the result: the last
assistant/messagecontent (deep-cloned — the log is frozen) and the lastturn/end.reasonmapped to aSubagentStopReason.
dispose() delegates to AgentHandle.dispose() (stop loop → await quiescence → remove session); cancel() cancels the child's in-flight turn.
Capabilities
{ outputSchema: false, depthLimit: true, toolFilter: false }. It constructs the child, so it enforces a recursion cap; structured output and tool-scoping are deferred (the service rejects a request needing either before start runs).
Config
| Key | Meaning |
|---|---|
providerName |
Registry name on ctx.subagents (default spawn). |
Depth tracking
Delegation depth rides on a merge-extensible AgentOptions.subagentDepth field (0 for a top-level agent, parent + 1 for a child), so a nested spawn reads its parent's depth from parent.options.subagentDepth. Read it with the exported depthOf(agent).