start({ kind, label, owner, run }) preflights everything that can fail
(the attachSurface fence, validation, the owner-cleanup attach) BEFORE
invoking the producer's run() starter, then commits atomically —
'work started but never got a collectable id' is now structurally
impossible instead of a producer try/catch rollback obligation (the
P1 review fix, rebuilt on #185's declare/execute split). Producers
lose their catch-wraps; the leak tests now pin the stronger property
that a failed preflight never spawns anything. TaskRegistration splits
into TaskStart (identity + run) and TaskHooks (cancel/done/readOutput);
docs, type-equiv manifest, catalogs, and both RFCs move with it.
@deepseek-ai/dsh-tool-tasks
The model-facing background task control surface over ctx.tasks: three kind-agnostic tools, the completion-notice injection, and the prompt section that teaches the background habit. Loading this plugin calls ctx.tasks.attachSurface('tool-tasks'), which is what arms producers' ctx.tasks.start().
Tools
task_output(task_id, wait?, timeout_ms?)— non-blocking read by default (stream kinds: the consuming delta since the previous read; final kinds: the final answer once terminal); every response ends with a[status: …]line (generic status + producer detail, e.g.[status: completed, exit code: 0]).wait: trueblocks until settlement, bounded bywaitTimeoutMs/maxWaitTimeoutMsconfig; a timed-out wait returns[status: running]and leaves the task alive.task_list()— the caller's tasks,<id> [<kind>] <status> — <label>per line.task_kill(task_id, reason?)— requests cancellation and returns immediately; the loggedreasonis forwarded to the producer. An already-terminal task is described via a non-consuming snapshot (never eats a pending delta).
ACP render intent: all three are generic cards (read/read/execute) — a task read is not a terminal.
Completion notices
On onTaskDone, injects background task <id> (<kind>: <label>) finished [status: …]. Read its output with task_output. into the owning agent's session (agent.inject() — durable context for the next request, not a wake-up). Suppressed when the snapshot is reported (the model already killed it, or a read/wait returned the end) — never a redundant "finished". The disposed-owner race is contained; a missing agent registry drops the notice.
Config
| key | default | meaning |
|---|---|---|
waitTimeoutMs |
30000 |
wait duration when task_output sets wait without timeout_ms |
maxWaitTimeoutMs |
600000 |
hard cap; larger model-supplied timeout_ms values are clamped |
A config whose default exceeds the cap fails loud at load.