delegation-layer 0.1.38 → 0.2.0

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.
Files changed (28) hide show
  1. package/README.md +45 -320
  2. package/package.json +1 -1
  3. package/plugins/delegation-layer/.claude-plugin/plugin.json +1 -1
  4. package/plugins/delegation-layer/.codex-plugin/plugin.json +1 -1
  5. package/plugins/delegation-layer/skills/agent-integration/SKILL.md +127 -355
  6. package/plugins/delegation-layer/skills/agent-integration/evals/cases.json +240 -0
  7. package/plugins/delegation-layer/skills/agent-integration/evals/routing.json +54 -0
  8. package/plugins/delegation-layer/skills/agent-integration/examples/read-only-task.md +29 -6
  9. package/plugins/delegation-layer/skills/agent-integration/examples/workspace-write-task.md +12 -10
  10. package/plugins/delegation-layer/skills/agent-integration/references/collaboration.md +5 -2
  11. package/plugins/delegation-layer/skills/agent-integration/references/command-reference.md +412 -145
  12. package/plugins/delegation-layer/skills/agent-integration/references/continuation.md +20 -12
  13. package/plugins/delegation-layer/skills/agent-integration/references/interaction.md +20 -7
  14. package/plugins/delegation-layer/skills/agent-integration/references/result-handling.md +246 -81
  15. package/plugins/delegation-layer/skills/agent-integration/references/routing-rule.json +1 -1
  16. package/plugins/delegation-layer/skills/agent-integration/references/workspaces.md +33 -0
  17. package/skills/agent-integration/SKILL.md +127 -355
  18. package/skills/agent-integration/evals/cases.json +240 -0
  19. package/skills/agent-integration/evals/routing.json +54 -0
  20. package/skills/agent-integration/examples/read-only-task.md +29 -6
  21. package/skills/agent-integration/examples/workspace-write-task.md +12 -10
  22. package/skills/agent-integration/references/collaboration.md +5 -2
  23. package/skills/agent-integration/references/command-reference.md +412 -145
  24. package/skills/agent-integration/references/continuation.md +20 -12
  25. package/skills/agent-integration/references/interaction.md +20 -7
  26. package/skills/agent-integration/references/result-handling.md +246 -81
  27. package/skills/agent-integration/references/routing-rule.json +1 -1
  28. package/skills/agent-integration/references/workspaces.md +33 -0
@@ -1,405 +1,177 @@
1
1
  ---
2
2
  name: agent-integration
3
- description: Use Delegate for work assigned to another agent, model, or separate harness CLI session. Load this before a provider-specific skill or plugin, including when a user names a CLI for research, implementation, tests, reviews, consultations, comparisons, or debates. A named destination still routes through Delegate. Ordinary same-harness subagents and questions about tools remain local; respect an explicit choice of another integration.
3
+ description: Use Delegate for work assigned to another agent, model, or separate harness CLI session. Load this before a provider-specific skill or plugin, including when a user names a CLI for research, implementation, tests, reviews, consultations, comparisons, or debates. Also manage optional Delegate Teams and explicit Member selection. A named destination still routes through Delegate. Ordinary same-harness subagents and questions about tools remain local; respect an explicit choice of another integration.
4
4
  ---
5
5
 
6
6
  # Delegation Layer
7
7
 
8
8
  ## When to use
9
9
 
10
- Use this skill before selecting a provider-specific plugin or launching an
11
- external harness to do work. Requests such as “ask Codex to review this”,
12
- “get Antigravity’s opinion”, and “have Claude investigate” are external
13
- collaboration even when the user never mentions Delegate. The same applies
14
- when you decide external expertise is useful to fulfill the user's task.
15
- These names are examples; discover supported destinations through the CLI.
16
- A destination name identifies who should do the work; it does not by itself
17
- select a provider-specific skill, plugin, or direct CLI integration.
18
- “Claude Code Router” and “CCR” mean `ccr:print`, not ordinary Claude Code.
19
- For that request, use Delegate with a CCR model alias; a Claude-specific skill
20
- or subscription model does not fulfill the requested route.
21
-
22
- Ordinary subagents within the current harness remain available. Naming the
23
- current harness (for example, “have Claude investigate” while using Claude)
24
- also permits native delegation unless the user requests a separate session.
25
- A separate CLI session uses Delegate even when its brand matches yours. A subagent
26
- or plugin that calls an external harness is still external collaboration and
27
- uses Delegate. Merely discussing a provider, editing documentation about it,
28
- or troubleshooting its installation does not trigger delegation. Respect an
29
- explicit user choice of another integration; this skill does not override it.
30
-
31
- The local `delegate` CLI is the integration surface for external work. Do not
32
- replace it with a provider command, a provider-specific plugin, or an API call.
33
- Do not inspect, authenticate, install, or repair provider CLIs to bypass a
34
- Delegate blocker.
35
-
36
- A reported blocker is a valid final response to a delegation request. It does
37
- not turn that request into an environment-repair task. The supervisor recovery
38
- exception is `failure.code: "supervisor_upgrade_required"` with
39
- `next_action: "run_supervisor_migrate"`: run Delegate's own
40
- `supervisor migrate` command once with the exact same state root, then retry the
41
- exact original admission command once only when migration succeeds. Preserve
42
- its argv and intent: `dispatch` remains `dispatch`, and `continue` remains
43
- `continue`. The migration response field `next_action: "retry_dispatch"` is a
44
- protocol name for this command-neutral retry; it never authorizes replacing a
45
- failed `continue` with a fresh dispatch. This is internal Delegate recovery,
46
- not Pueue administration. Never run `pueue`, `pueued`, socket inspection,
47
- process searches, root deletion, or a provider CLI during recovery. Executable
48
- path or hash drift alone is handled by normal adoption and does not require
49
- this command.
50
- Managed admission also permits the two explicit `watch_workspace` responses
51
- in the task-record table below. They keep the exact admission command and
52
- inputs, including `continue`; they do not authorize environment repair.
53
- When a response says `failure.next_action: "stop_and_report"`, that attempt is
54
- finished. Include its failure in your final response without opening a
55
- clarification dialog to choose a fallback. For `task_record: not_created`,
56
- identify the requested destination and include the saved JSON failure response
57
- verbatim. A `task_id` can be returned even when no task record was created. Do
58
- not infer that an unavailable provider is uninstalled or unauthenticated. Do
59
- not append inferred state paths or provider-setup diagnoses, run diagnostic
60
- commands, or use another integration.
61
- Troubleshooting requires a separate user request. Other independently requested
62
- tasks may proceed; the failed attempt must remain reported as failed or blocked.
63
-
64
- ## Rules
65
-
66
- 1. Check whether `delegate` is already installed. A plugin SessionStart hook
67
- normally bootstraps the self-contained CLI when it is missing. This skill
68
- never installs or repairs the CLI itself. If `delegate` is still missing or
69
- unusable, report the bootstrap failure and stop; never fall back to a native
70
- provider command.
71
- 2. Preserve a named harness or provider, even when the user supplied a natural
72
- name rather than a provider ID. Use `dispatch --auto` when none was chosen.
73
- Provider selection, executable checks, compatibility checks, authentication
74
- gates, and supervisor admission belong inside Delegation Layer.
75
- 3. Give every turn an absolute workspace, an explicit permission mode, and a
76
- finite budget. Keep the state root outside the workspace. Reuse a supplied
77
- `DELEGATE_ROOT` for all providers and tasks; do not invent per-provider or
78
- per-task state roots. Task IDs separate work within that root. Managed Git
79
- workspaces are optional; read [managed workspace guidance](references/workspaces.md)
80
- before creating or attaching one.
81
- 4. Use `--json` and save each response separately with its requested destination,
82
- model, effort, workspace, and returned `task_id`. Never merge concurrent
83
- responses into an unlabeled output stream. Read `admission`, `liveness`,
84
- `publication`, `status`, `outcome`, `continuation`, `task_record`, `failure`,
85
- and `error` as separate fields.
86
- Delegate owns the supervisor lifecycle. Never install, configure, start,
87
- inspect, or repair Pueue, and never poll a task unless the response says its
88
- `task_record` is `created`.
89
- 5. Observe tasks only through Delegate `status`, `collect`, or `events`.
90
- Do not run `ps`, `pgrep`, process-tree searches, or supervisor commands to
91
- monitor delegated work. Pending output is normal startup or work in progress;
92
- empty `pending_requests` means keep collecting, not diagnose the environment.
93
- Environment diagnostics require a separately requested troubleshooting task.
94
- Keep collection in the
95
- foreground until all requested tasks reach a terminal result or an explicit
96
- blocker. Do not end a headless turn promising a background notification.
97
- Pending publication (exit 3) means keep waiting, not success. When the JSON
98
- reports `pending.kind: "lifetime-finalization"`, the resident guardian still
99
- owns cleanup; keep observing that same task without supervisor repair,
100
- process commands, redispatch, or provider fallback. When the JSON
101
- includes an outstanding `interaction.pending_requests` batch, follow
102
- [active-task interaction](references/interaction.md) before waiting again. Only detach
103
- when the user explicitly requests it, retaining the exact task IDs.
104
- Collection may reconcile the saved Pueue binding and recover the guardian
105
- lifetime only for an already-requested stop. A queue-row end alone cannot
106
- publish terminal facts; collection never launches a provider or retries a
107
- task.
108
- 6. If `failure.next_action` is `recheck`, follow
109
- [offline recovery](references/result-handling.md#offline-recovery) once for
110
- that task. Rechecking saved evidence does not run the provider again.
111
- Otherwise, report a rejected result without redispatching or reading raw
112
- output as an answer.
113
- 7. If a task is timed out and its JSON says `continuation.resumable: true`, use
114
- `continue --task TASK_ID`, optionally with a new `--brief`. Do not create a
115
- fresh unrelated dispatch to replace a resumable task. The one other automatic
116
- route is an `interrupted` task from `status` or `collect`, and only when
117
- `failure.code` is `"task_interrupted"`, `failure.next_action` is
118
- `"continue_task"`, and `continuation.resumable` is `true`; see
119
- [interrupted turn](references/continuation.md#interrupted-turn). A
120
- cancellation, `stop_and_report`, or failed admission always takes precedence
121
- over `resumable: true`.
122
- 8. Treat `blocked` authentication as unresolved. Do not call it compatible,
123
- successful, or failed provider behavior, and do not invent login commands.
124
- 9. Never put credentials, tokens, or unrestricted provider output in a brief,
125
- option, receipt, or agent message.
126
- 10. Permission modes select provider-native behavior, not an independent sandbox.
127
- Providers load their own configuration and extensions. If a task is rejected,
128
- report delegate's evidence; do not assume the user's configuration is faulty
129
- or remove MCP servers, plugins, settings, or credentials to make it pass.
130
- 11. The model chooses ordinary-task fan-out by issuing independent `dispatch`
131
- commands concurrently. The private supervisor does not impose a task-count
132
- or CPU-based limit. Use this for independent investigation, debate, review,
133
- or provider comparison. For independent parallel writes, choose
134
- `--isolation git-worktree` automatically unless the user explicitly chooses
135
- shared coordination; the model chooses fan-out and task scope. A read-only
136
- review may attach a retained workspace with `--workspace ID`. To fork a
137
- worker from current uncommitted content, follow
138
- [checkpoint before fork](references/workspaces.md#checkpoint-before-fork):
139
- fork only from a `checkpointed`, `usable` checkpoint commit. If your own
140
- turn holds the workspace, do not wait or retry through `--cwd`; report so
141
- the Lead checkpoints after your turn closes.
142
-
143
- For an explicit Codex code review, use the discoverable `codex:review` profile
144
- with one persisted target: `--review-target uncommitted`,
145
- `--review-target base:BRANCH`, or `--review-target commit:SHA`. It is read-only
146
- and does not support `--interactive`, continuation, or workspace-write. Use
147
- ordinary `codex:exec` when the request is a general investigation or asks the
148
- provider to edit files; the review profile is for Codex's native review
149
- operation and keeps the reviewed Git state explicit. The brief is retained as
150
- task evidence; the review target supplies Codex's review scope because its
151
- native command does not accept a prompt with the target flag.
152
- For a complete managed-workspace turn, review the recorded initial base against
153
- its captured tree through an ordinary read-only task. Include both sealed refs
154
- and an explicit `git diff BASE TREE` scope. A native `uncommitted` review covers
155
- current staged, unstaged, and untracked changes; it excludes worker commits.
156
- Do not pass a tree as a native branch target. Preserve an explicitly requested
157
- native review target and state its narrower scope. See [workspace review
158
- guidance](references/workspaces.md#recovery-and-review-scope).
10
+ Load this skill before choosing tools for work assigned to an external agent,
11
+ model, or separate harness session, including collaboration you choose.
12
+ A named CLI identifies the destination; discover its provider ID through
13
+ Delegate. “CCR” or “Claude Code Router” means `ccr:print`; read
14
+ [CCR guidance](references/ccr.md).
15
+
16
+ Ordinary subagents inside the current harness remain available, even when that
17
+ harness is named. A separate CLI session uses Delegate, including another
18
+ instance of your current harness. Discussing, documenting, or configuring a
19
+ tool is local work. Respect an explicit user choice of another integration.
20
+
21
+ For optional Team management or explicit Member selection, use
22
+ [Teams](references/command-reference.md#teams). Management is local configuration
23
+ through Delegate CLI and does not launch a provider. Teams are never required
24
+ for ordinary delegation.
25
+
26
+ For recurring tasks, use the [schedule commands](references/command-reference.md#schedules)
27
+ and the independent [scheduler runtime](references/command-reference.md#scheduler-runtime).
28
+
29
+ ## Boundaries
30
+
31
+ - Preserve the requested destination, exact model ID, effort, permissions,
32
+ workspace, and state root. Do not guess ambiguous model IDs.
33
+ - Delegate owns task lifecycle and evidence. Providers and users own their CLI
34
+ installations, accounts, settings, extensions, and native sessions.
35
+ - Permissions request native behavior, not an independent sandbox.
36
+ `workspace-write` authorizes unattended commands and edits; native access
37
+ can extend beyond the workspace.
38
+ - A `stop_and_report` ends that attempt, not investigation of its cause.
39
+ Follow [failure diagnosis](references/result-handling.md#failure-diagnosis)
40
+ without another generic troubleshooting request: inspect bounded evidence,
41
+ distinguish facts from uncertainty, and propose a concrete next step.
42
+ Do not retry, substitute an integration, or change configuration without
43
+ authorization covering that action. Independent requests may proceed.
44
+ - Observe through Delegate `status`, `collect`, or `events`; do not use
45
+ process searches or Pueue commands. Delegate manages its supervisor.
46
+ - Keep credentials and unrestricted private provider output out of briefs,
47
+ options, control responses, and messages.
159
48
 
160
49
  ## Operating procedure
161
50
 
162
51
  ### 1. Verify the control CLI
163
52
 
164
- Run a quick local check:
165
-
166
53
  ```sh
167
54
  command -v delegate && delegate --version
168
55
  ```
169
56
 
170
- If discovery fails, report that Delegation Layer is missing. If the version
171
- command fails, report that the installed CLI is unusable. Stop in either case.
172
- Do not substitute a provider command.
57
+ If missing or unusable, report and stop. This skill does not install or repair
58
+ the CLI. A trusted plugin startup hook normally handles bootstrap.
173
59
 
174
60
  ### 2. Discover only when useful
175
61
 
176
- If no destination was named, use automatic selection directly. If the user
177
- named a harness (for example, “Codex”), resolve its exact provider ID from:
62
+ If a Team/Member was requested, inspect the scoped target and follow
63
+ [Member selection](references/command-reference.md#using-a-member). Preserve
64
+ explicit caller choices; do not replace a missing requested Member with another.
65
+ Without a Team target, if no destination was named, use `--auto`. Otherwise resolve the named
66
+ destination through `providers --json` and preserve it with `--provider`.
67
+ Read [providers and capabilities](references/command-reference.md#providers-and-capabilities)
68
+ for discovery and required options. Catalog support is not host readiness;
69
+ a normal task needs no separate preflight.
70
+
71
+ Keep provider defaults when model/effort were not requested and are not
72
+ required. For an explicit choice or natural-language model name, read
73
+ [model selection](references/command-reference.md#choosing-models-and-effort).
74
+ An exact requested ID passes unchanged even when discovery omits it. Ask for
75
+ an exact ID only when a name remains ambiguous.
76
+
77
+ For work likely to need questions or guidance, read
78
+ [interaction](references/interaction.md) before dispatch and use `--interactive`
79
+ when supported. Check clarification and steering separately; automatic
80
+ interactive selection does not require steering support.
81
+ For explicit native Codex review, read
82
+ [review scope](references/command-reference.md#codex-review).
178
83
 
179
- ```sh
180
- delegate --root "${DELEGATE_ROOT:-$HOME/delegation-state}" providers --json
181
- ```
84
+ ### 3. Prepare separate paths and a finite brief
182
85
 
183
- Use the matching catalog ID with `--provider`; do not silently substitute
184
- `--auto` or another provider. If the name is ambiguous, clarify the intended
185
- destination. If it is absent, report that this build does not support it.
186
- The catalog is not proof that a provider is installed, authenticated, or ready.
187
- Dispatch performs admission checks; a separate preflight is not needed for a
188
- normal task. For an explicitly requested readiness check, see
189
- [preflight guidance](references/command-reference.md#checking-readiness).
190
-
191
- The catalog and `capabilities` response expose supported permission modes,
192
- request options, continuation, native interaction, and the read-only mechanism. A read-only
193
- capability with `containment: "provider-owned"` selects the provider's native
194
- behavior but is not an independent delegate-owned sandbox. This is separate
195
- from guardian-owned process-lifetime containment. Static discovery
196
- does not prove authentication or live acceptance; use the dispatch or live
197
- acceptance result for that evidence.
198
-
199
- Read `required_options` in provider discovery before dispatch. Supply every
200
- required option; a provider's optional defaults do not replace required inputs.
201
- For CCR / Claude Code Router or a CCR model request, read
202
- [CCR model selection](references/ccr.md). A CCR route is external collaboration
203
- even when you are already using Claude. Do not assume every open-source model
204
- name belongs to CCR; clarify only if discovery leaves the destination ambiguous.
205
-
206
- Keep provider defaults when no model or effort was requested and neither is required. When an explicit
207
- choice is needed, read [model and effort guidance](references/command-reference.md#choosing-models-and-effort).
208
- Pass exact requested model IDs and effort values unchanged through Delegate's
209
- public `--model` and `--effort` fields; discovery is advisory, never an allowlist.
210
- For a natural-language model name, resolve one exact ID through discovery. If
211
- it remains ambiguous or discovery is unavailable, ask for the exact model ID;
212
- do not turn a display name into a guessed alias. An explicit ID needs no such
213
- clarification just because it is absent from discovery.
214
-
215
- For planning, consultation, debate, or other external work that may need
216
- answers or guidance while it runs, read [active-task interaction](references/interaction.md)
217
- and use `--interactive` when supported. Answer known facts yourself; ask the
218
- user for missing preferences, authorization, or scope. Keep ordinary native
219
- subagents available under the same-harness rule above.
86
+ Use a supplied brief or write the worker's bounded assignment and acceptance
87
+ criteria to a regular file. Do not copy the orchestration request or ask workers
88
+ to recruit others unless recursive delegation was requested.
220
89
 
221
- ### 3. Prepare separate paths and a finite brief
90
+ Keep the state root outside provider-writable workspaces, provider runtime
91
+ directories, and temporary trees they may write. For every task command pass
92
+ `--root "${DELEGATE_ROOT:-$HOME/delegation-state}"` directly in that shell
93
+ invocation. If the user explicitly requests another root, use that exact path
94
+ consistently. Task IDs separate tasks; do not invent per-task roots.
222
95
 
223
- Use an existing task brief when one is supplied. Otherwise create a bounded
224
- brief file that contains the requested work and its acceptance criteria. Keep
225
- the state root outside the workspace and provider-writable trees (which can
226
- include the system temporary directory). Use `DELEGATE_ROOT` when supplied.
227
- Pass a regular file path for `--brief`, not shell process substitution such as
228
- `<(...)` or an ephemeral `/dev/fd/...` path.
229
-
230
- Run path preparation and dispatch in **one shell/tool invocation**, as shown
231
- below. Shell variables may disappear between tool calls. For later commands,
232
- use the actual saved absolute paths or assign them again in that invocation;
233
- never pass an empty `--root`, `--brief`, or `--cwd`.
234
-
235
- Write the brief as the **worker’s own assignment**, not a copy of the
236
- orchestration request. For “consult another agent about X”, tell the worker
237
- “Investigate X and return your findings; you are the assigned worker, do not
238
- delegate this assignment.” Keep dispatching, answering questions, and
239
- collecting results in the lead session unless recursive delegation was
240
- explicitly requested.
241
-
242
- Replace the example brief below with that bounded worker assignment. Do not place the state
243
- root inside the workspace or place secrets in either path’s task data. Keep it
244
- outside provider configuration and runtime directories as well. If delegate
245
- rejects a caller-supplied state root, report the placement error rather than
246
- silently replacing that root. For every task command, use
247
- `--root "${DELEGATE_ROOT:-$HOME/delegation-state}"` as shown below. This reads the supplied root in each shell call and uses the
248
- same default when none was supplied; no root setup or new directory choice is
249
- needed. If the user explicitly requests another root, substitute that exact
250
- absolute path consistently. Do not change provider settings or switch roots
251
- when waiting, replying, steering, or continuing.
96
+ Prepare paths and dispatch in one tool invocation; shell variables may not
97
+ persist between calls. Use saved absolute paths in later calls. Do not use
98
+ process substitution or ephemeral `/dev/fd` paths for briefs.
99
+
100
+ For independent parallel writes, choose managed worktrees unless the user
101
+ explicitly chooses shared coordination. Read
102
+ [workspaces](references/workspaces.md) before creating or attaching one.
103
+ To fork current uncommitted content, the Lead follows
104
+ [checkpoint before fork](references/workspaces.md#checkpoint-before-fork).
105
+ A worker must not checkpoint a workspace its own turn holds.
252
106
 
253
107
  ### 4. Dispatch one bounded turn
254
108
 
255
- Use automatic selection unless the user named a destination.
256
- For a named harness or provider resolved in step 2, replace `--auto` with `--provider PROVIDER_ID`; never
257
- combine the two.
109
+ Use the [read-only task example](examples/read-only-task.md), or its
110
+ [authorized write variation](examples/workspace-write-task.md). The
111
+ [command reference](references/command-reference.md#dispatch) owns flags and defaults.
258
112
 
259
- Capture the dispatch exit code with `if`, as below. This prints the response
260
- even when dispatch fails and the surrounding shell has `set -e` enabled.
113
+ Capture each response and exit status once in the original invocation.
114
+ Never dispatch again to recover output or discover the prior exit code.
115
+ Keep concurrent requests independently associated; see
116
+ [parallel reviews and debates](references/collaboration.md).
261
117
 
262
- ```sh
263
- WORKSPACE="$PWD"
264
- BRIEF="$(mktemp)"
265
- RESPONSE="$(mktemp)"
266
- cat >"$BRIEF" <<'EOF'
267
- Describe the delegated task, the files or behavior to change, and the checks
268
- that must pass. Keep the response concise and report validation evidence.
269
- EOF
270
- printf 'Saved response: %s\n' "$RESPONSE"
271
- if delegate --root "${DELEGATE_ROOT:-$HOME/delegation-state}" dispatch --auto \
272
- --brief "$BRIEF" \
273
- --cwd "$WORKSPACE" \
274
- --permission read-only \
275
- --budget 30m \
276
- --json >"$RESPONSE"; then
277
- dispatch_exit=0
278
- else
279
- dispatch_exit=$?
280
- fi
281
- cat "$RESPONSE"
282
- printf '\nDispatch exit: %s; saved response: %s\n' "$dispatch_exit" "$RESPONSE"
283
- ```
284
-
285
- For an authorized code change, use `--permission workspace-write`; this requests
286
- unattended native tool execution, including shell commands and file edits.
287
- The provider may allow access beyond the selected workspace. Delegate supplies
288
- the native approval options; do not add provider flags or call its CLI yourself.
289
- Keep the budget finite. A successful dispatch means the request was durably admitted;
290
- it does not mean the delegated work finished.
291
-
292
- For independent work, the model may run several complete `dispatch` commands
293
- concurrently. Keep each task's brief, workspace, permission, and task ID
294
- independent. Do not configure Pueue or wait for one task before dispatching the
295
- next solely to serialize ordinary work. Inspect each returned task separately
296
- with `status` and `collect`. Use independent tool calls or separate response
297
- files, never background commands writing to the same stdout. Read
298
- [parallel reviews and debates](references/collaboration.md) when coordinating
299
- multiple participants or challenge rounds.
300
-
301
- Capture the response and exit status in the **original** dispatch invocation,
302
- as above. Read the saved response if you need it again. Never repeat dispatch
303
- to obtain its exit code, recover output, or confirm that it worked: each call
304
- can create new paid work. Once a response says `task_record: created`, save its
305
- `task_id` and switch to observation. A missing exit code does not undo admission.
306
-
307
- Save the exact `task_id` from the JSON response. Apply this decision separately
308
- for **each attempt**, including requests issued together:
309
-
310
- | Response | Next action |
311
- |---|---|
312
- | Usage error, no JSON response | Correct the reported syntax using Delegate help or `providers --json`, then invoke that request again. Parsing failed before admission. |
313
- | `task_record: not_created`, `failure.code: supervisor_upgrade_required`, and `failure.next_action: run_supervisor_migrate` | Run `delegate --root "<the exact absolute state root used by the failed command>" supervisor migrate --json` once. Retry the exact original admission argv once only after `supervisor_control.state: migrated` and `supervisor_control.next_action: retry_dispatch`; otherwise stop and report the migration response. Preserve an explicit custom root exactly. A failed `continue` must be retried as the same `continue`; never replace it with a fresh `dispatch` or a direct provider call. |
314
- | `task_record: not_created` and `failure.next_action: correct_request` | Correct that request and retry it. |
315
- | `task_record: not_created`, `failure.code: workspace_provision_pending` or `workspace_busy`, and `failure.next_action: watch_workspace` | Follow [managed workspace recovery](references/result-handling.md#managed-workspace-results) using the same root and workspace. Once ready, retry the exact admission command and inputs. A failed `continue` remains that same `continue`, never a new dispatch. |
316
- | `task_record: not_created` with any other next action | Report that attempt's failure and stop it. Do not diagnose provider setup or substitute an integration. |
317
- | `task_record: created` | Use `status` before taking any other action. Do not dispatch again. |
318
- | `task_record: unknown` or an ambiguous response | Stop and report; do not retry an uncertain task creation. |
319
-
320
- One attempt's `stop_and_report` does not prevent correcting another independent
321
- request's usage error. Keep the failed attempt reported as failed. With an
322
- explicit task ID, absence can race another dispatch creating the same ID;
323
- never retry that uncertain ID or run Pueue commands.
118
+ **Before any observation or retry, read and apply
119
+ [task creation](references/result-handling.md#task-creation).**
120
+ A task ID alone is not creation. That reference owns admission decisions,
121
+ including the same-root supervisor migration exception, workspace waits,
122
+ resource refusals, and uncertain creation. A failed continuation retains its
123
+ original command and intent.
324
124
 
325
125
  ### 5. Observe and collect
326
126
 
327
- Use the same state root and task ID. Each command below resolves the root
328
- in its own shell call, so it does not depend on a previous shell variable:
127
+ Follow [observation decisions](references/result-handling.md#observe-and-collect)
128
+ with the same root and created task ID:
329
129
 
330
130
  ```sh
331
131
  delegate --root "${DELEGATE_ROOT:-$HOME/delegation-state}" status TASK_ID --json
332
132
  delegate --root "${DELEGATE_ROOT:-$HOME/delegation-state}" collect TASK_ID --watch 5s --json
333
133
  ```
334
134
 
335
- Check `status` first: if it is `timed_out` or `interrupted`, follow step 6 even
336
- when publication is pending or unknown and no outcome is present. If `interaction.pending_requests` is
337
- nonempty and the interaction is not closed, answer the questions using
338
- [active-task interaction](references/interaction.md) before collecting again.
339
- Otherwise, if `collect` exits with code `3` because publication is still
340
- pending, wait a short interval and run
341
- `collect` again. Do not dispatch again. Continue until
342
- the response has a terminal `outcome` or a bounded operational error that
343
- requires the caller’s attention.
344
-
345
- Accept a result only when the terminal outcome is present and its publication
346
- is committed. A rejected outcome is terminal evidence and must be reported as
347
- rejected. Payload and raw output are returned as validated descriptors; do not
348
- copy unrestricted provider output into the control response.
135
+ Apply the owning decision order before waiting: terminal outcomes and concrete
136
+ errors, cancellation/timeout/interruption, interaction, then pending
137
+ observation. Keep collection in the foreground until completion or a reported
138
+ blocker; detach only when requested and retain the exact task IDs and root.
139
+ A pending watch is not success. Read the complete validated answer and check
140
+ the requested deliverables before claiming completion.
349
141
 
350
142
  ### 6. Continue a timed out or interrupted turn
351
143
 
352
- When `status` or `collect` reports `timed_out` or `interrupted`, read
353
- [continuation and timeout recovery](references/continuation.md). Unless a
354
- cancellation or `stop_and_report` applies, a `timed_out` task with
355
- `continuation.resumable: true` may use `continue --task TASK_ID`. An
356
- `interrupted` task may use it only under all three conditions in rule 7;
357
- otherwise report it. When continuing, use the original state root and a finite
358
- budget, then observe the returned successor ID. Do not
359
- wait indefinitely for pending publication or restart the task as an unrelated
360
- dispatch. If continuation is unavailable, report its reason, except the busy
361
- managed-workspace case in [continuation and timeout
362
- recovery](references/continuation.md). Apply the same
363
- `failure` and `task_record` decisions as for dispatch; never repeat an uncertain
364
- successor creation.
144
+ Read [continuation](references/continuation.md) for eligibility, cancellation
145
+ precedence, and exact-session follow-up. Preserve the root and finite budget,
146
+ then apply [task creation](references/result-handling.md#task-creation) to the
147
+ successor response. Never replace an uncertain or failed continuation with a
148
+ fresh dispatch.
365
149
 
366
150
  ## Comparisons, debate, and follow-up
367
151
 
368
- Choose a finite scope and number of rounds appropriate to the user's request.
369
- For independent opinions, dispatch separate briefs to the chosen destinations
370
- and collect each result. Summarize the relevant findings as task data in the
371
- next brief; do not forward credentials or unrestricted output. Use a supported
372
- `continue` for an exact-session follow-up, or a new bounded task for an
373
- independent question. Preserve which agent supplied each finding, explain
374
- agreements and disagreements, and stop at the agreed scope or a blocker.
375
- An external worker should perform its assigned work; do not ask it to recursively
376
- recruit more agents unless that is explicitly part of the task.
152
+ Choose a finite scope and number of rounds. Collect each participant's actual
153
+ result before giving it to another participant as challenge material. Keep
154
+ attribution and failed/blocked requests visible. Use each participant's own
155
+ predecessor for an exact-session follow-up. The
156
+ [collaboration reference](references/collaboration.md) owns coordination examples.
377
157
 
378
158
  ## Details when needed
379
159
 
380
- - Read [command reference](references/command-reference.md) when choosing
381
- model/effort options or another public command.
382
- - Read [result handling](references/result-handling.md) when interpreting
383
- admission, publication, authentication, errors, or exit codes.
384
- - Read [continuation](references/continuation.md) for timeout or interruption
385
- recovery or an exact-session follow-up.
386
- - Read [managed workspaces](references/workspaces.md) for optional Git
387
- worktrees, capture, review scope, release, and forgetting, and
388
- [Git checkpoints](references/workspaces.md#git-checkpoints) before creating,
389
- observing, forking from, or removing a checkpoint.
390
- - Use [read-only example](examples/read-only-task.md),
391
- [write example](examples/workspace-write-task.md),
392
- [JSON examples](examples/json-results.md), and
393
- [managed workspace example](examples/managed-workspace.md) when constructing
394
- a task or parsing unfamiliar output. Do not load every reference for a
395
- routine dispatch.
160
+ - [Commands and discovery](references/command-reference.md)
161
+ - [Optional Teams and Members](references/command-reference.md#teams)
162
+ - [Task/result decisions](references/result-handling.md), including conditional offline recheck
163
+ - [Continuation](references/continuation.md)
164
+ - [Interaction](references/interaction.md)
165
+ - [Managed workspaces and checkpoints](references/workspaces.md)
166
+ - [Managed workspace example](examples/managed-workspace.md)
167
+ - [JSON examples](examples/json-results.md)
396
168
 
397
169
  ## Completion report
398
170
 
399
- Build the report from observed CLI responses and collected evidence. Copy
400
- returned values; do not reconstruct paths from example commands or shell
401
- defaults. Omit unobserved configuration details.
402
-
403
- Report the original task ID, selected provider ID when the CLI returns one,
404
- the final admission/liveness/publication fields, the terminal outcome and
405
- evidence descriptors, and any continuation or blocked-authentication state.
171
+ Use observed responses and validated evidence. Report each original task ID,
172
+ returned provider ID, admission/liveness/publication fields, terminal outcome,
173
+ evidence descriptors, and any successor or blocked authentication state.
174
+ For a `not_created` stop, name the requested destination and preserve its
175
+ saved JSON failure with sensitive content redacted. Report the evidence-backed
176
+ cause or what remains unknown and a specific next step; do not invent paths
177
+ or infer installation, authentication or configuration from rejection alone.