delegation-layer 0.1.20 → 0.1.21
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.md +2 -0
- package/package.json +1 -1
- package/plugins/delegation-layer/.claude-plugin/plugin.json +1 -1
- package/plugins/delegation-layer/.codex-plugin/plugin.json +1 -1
- package/plugins/delegation-layer/skills/agent-integration/SKILL.md +52 -16
- package/plugins/delegation-layer/skills/agent-integration/evals/evals.json +40 -0
- package/plugins/delegation-layer/skills/agent-integration/examples/json-results.md +2 -2
- package/plugins/delegation-layer/skills/agent-integration/examples/read-only-task.md +1 -2
- package/plugins/delegation-layer/skills/agent-integration/examples/workspace-write-task.md +1 -2
- package/plugins/delegation-layer/skills/agent-integration/references/collaboration.md +2 -2
- package/plugins/delegation-layer/skills/agent-integration/references/command-reference.md +8 -2
- package/plugins/delegation-layer/skills/agent-integration/references/continuation.md +1 -1
- package/plugins/delegation-layer/skills/agent-integration/references/interaction.md +110 -0
- package/plugins/delegation-layer/skills/agent-integration/references/result-handling.md +4 -2
- package/plugins/delegation-layer/skills/agent-integration/references/routing-rule.json +1 -1
- package/plugins/delegation-layer/skills/agent-integration/scripts/delegate-routing-context.sh +15 -1
- package/skills/agent-integration/SKILL.md +52 -16
- package/skills/agent-integration/evals/evals.json +40 -0
- package/skills/agent-integration/examples/json-results.md +2 -2
- package/skills/agent-integration/examples/read-only-task.md +1 -2
- package/skills/agent-integration/examples/workspace-write-task.md +1 -2
- package/skills/agent-integration/references/collaboration.md +2 -2
- package/skills/agent-integration/references/command-reference.md +8 -2
- package/skills/agent-integration/references/continuation.md +1 -1
- package/skills/agent-integration/references/interaction.md +110 -0
- package/skills/agent-integration/references/result-handling.md +4 -2
- package/skills/agent-integration/references/routing-rule.json +1 -1
- package/skills/agent-integration/scripts/delegate-routing-context.sh +15 -1
package/README.md
CHANGED
|
@@ -20,6 +20,8 @@ already use instead of replacing them.
|
|
|
20
20
|
and time budget.
|
|
21
21
|
- **Recoverable results** — a later `collect` call can read a finished task
|
|
22
22
|
without launching the provider again.
|
|
23
|
+
- **Clarify while work runs** — answer native questions through Delegate; steer
|
|
24
|
+
an active Codex turn without restarting it. [Interactive tasks](docs/cli-reference.md#interactive-tasks).
|
|
23
25
|
- **Resumable turns** — a durable timeout can continue the exact provider
|
|
24
26
|
session through a linked successor task.
|
|
25
27
|
- **Runtime compatibility** — the selected provider's executable and advertised
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "delegation-layer",
|
|
3
3
|
"displayName": "Delegation Layer",
|
|
4
|
-
"version": "0.1.
|
|
4
|
+
"version": "0.1.21",
|
|
5
5
|
"description": "Consult external AI harnesses and CCR-configured models for reviews, research, implementation, and debate through the resumable Delegate CLI.",
|
|
6
6
|
"author": {
|
|
7
7
|
"name": "Hesham Karam",
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "delegation-layer",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.21",
|
|
4
4
|
"description": "Consult external AI harnesses and CCR-configured models for reviews, research, implementation, and debate through the resumable Delegate CLI.",
|
|
5
5
|
"author": {
|
|
6
6
|
"name": "Hesham Karam",
|
|
@@ -64,10 +64,17 @@ tasks may proceed; the failed attempt must remain reported as failed or blocked.
|
|
|
64
64
|
Delegate owns the supervisor lifecycle. Never install, configure, start,
|
|
65
65
|
inspect, or repair Pueue, and never poll a task unless the response says its
|
|
66
66
|
`task_record` is `created`.
|
|
67
|
-
5. Observe
|
|
67
|
+
5. Observe tasks only through Delegate `status`, `collect`, or `events`.
|
|
68
|
+
Do not run `ps`, `pgrep`, process-tree searches, or supervisor commands to
|
|
69
|
+
monitor delegated work. Pending output is normal startup or work in progress;
|
|
70
|
+
empty `pending_requests` means keep collecting, not diagnose the environment.
|
|
71
|
+
Environment diagnostics require a separately requested troubleshooting task.
|
|
72
|
+
Keep collection in the
|
|
68
73
|
foreground until all requested tasks reach a terminal result or an explicit
|
|
69
74
|
blocker. Do not end a headless turn promising a background notification.
|
|
70
|
-
Pending publication (exit 3) means keep waiting, not success.
|
|
75
|
+
Pending publication (exit 3) means keep waiting, not success. When the JSON
|
|
76
|
+
includes an outstanding `interaction.pending_requests` batch, follow
|
|
77
|
+
[active-task interaction](references/interaction.md) before waiting again. Only detach
|
|
71
78
|
when the user explicitly requests it, retaining the exact task IDs.
|
|
72
79
|
Collection may recover the
|
|
73
80
|
saved supervisor only to observe an already-requested budget stop; it never
|
|
@@ -121,7 +128,7 @@ normal task. For an explicitly requested readiness check, see
|
|
|
121
128
|
[preflight guidance](references/command-reference.md#checking-readiness).
|
|
122
129
|
|
|
123
130
|
The catalog and `capabilities` response expose supported permission modes,
|
|
124
|
-
request options, continuation, and the read-only mechanism. A read-only
|
|
131
|
+
request options, continuation, native interaction, and the read-only mechanism. A read-only
|
|
125
132
|
capability with `containment: "provider-owned"` selects the provider's native
|
|
126
133
|
behavior but is not an independent delegate-owned sandbox. Static discovery
|
|
127
134
|
does not prove authentication or live acceptance; use the dispatch or live
|
|
@@ -143,25 +150,41 @@ it remains ambiguous or discovery is unavailable, ask for the exact model ID;
|
|
|
143
150
|
do not turn a display name into a guessed alias. An explicit ID needs no such
|
|
144
151
|
clarification just because it is absent from discovery.
|
|
145
152
|
|
|
153
|
+
For planning, consultation, debate, or other external work that may need
|
|
154
|
+
answers or guidance while it runs, read [active-task interaction](references/interaction.md)
|
|
155
|
+
and use `--interactive` when supported. Answer known facts yourself; ask the
|
|
156
|
+
user for missing preferences, authorization, or scope. Keep ordinary native
|
|
157
|
+
subagents available under the same-harness rule above.
|
|
158
|
+
|
|
146
159
|
### 3. Prepare separate paths and a finite brief
|
|
147
160
|
|
|
148
161
|
Use an existing task brief when one is supplied. Otherwise create a bounded
|
|
149
162
|
brief file that contains the requested work and its acceptance criteria. Keep
|
|
150
163
|
the state root outside the workspace and provider-writable trees (which can
|
|
151
|
-
include the system temporary directory). Use `DELEGATE_ROOT` when supplied
|
|
164
|
+
include the system temporary directory). Use `DELEGATE_ROOT` when supplied.
|
|
152
165
|
|
|
153
166
|
Run path preparation and dispatch in **one shell/tool invocation**, as shown
|
|
154
167
|
below. Shell variables may disappear between tool calls. For later commands,
|
|
155
168
|
use the actual saved absolute paths or assign them again in that invocation;
|
|
156
169
|
never pass an empty `--root`, `--brief`, or `--cwd`.
|
|
157
170
|
|
|
158
|
-
|
|
171
|
+
Write the brief as the **worker’s own assignment**, not a copy of the
|
|
172
|
+
orchestration request. For “consult another agent about X”, tell the worker
|
|
173
|
+
“Investigate X and return your findings; you are the assigned worker, do not
|
|
174
|
+
delegate this assignment.” Keep dispatching, answering questions, and
|
|
175
|
+
collecting results in the lead session unless recursive delegation was
|
|
176
|
+
explicitly requested.
|
|
177
|
+
|
|
178
|
+
Replace the example brief below with that bounded worker assignment. Do not place the state
|
|
159
179
|
root inside the workspace or place secrets in either path’s task data. Keep it
|
|
160
180
|
outside provider configuration and runtime directories as well. If delegate
|
|
161
181
|
rejects a caller-supplied state root, report the placement error rather than
|
|
162
|
-
silently replacing that root.
|
|
163
|
-
|
|
164
|
-
root
|
|
182
|
+
silently replacing that root. For every task command, use
|
|
183
|
+
`--root "${DELEGATE_ROOT:-$HOME/delegation-state}"` as shown below. This reads the supplied root in each shell call and uses the
|
|
184
|
+
same default when none was supplied; no root setup or new directory choice is
|
|
185
|
+
needed. If the user explicitly requests another root, substitute that exact
|
|
186
|
+
absolute path consistently. Do not change provider settings or switch roots
|
|
187
|
+
when waiting, replying, steering, or continuing.
|
|
165
188
|
|
|
166
189
|
### 4. Dispatch one bounded turn
|
|
167
190
|
|
|
@@ -170,19 +193,22 @@ For a named harness or provider resolved in step 2, replace `--auto` with `--pro
|
|
|
170
193
|
combine the two:
|
|
171
194
|
|
|
172
195
|
```sh
|
|
173
|
-
STATE_ROOT="${DELEGATE_ROOT:-$HOME/delegation-state}"
|
|
174
196
|
WORKSPACE="$PWD"
|
|
175
197
|
BRIEF="$(mktemp)"
|
|
198
|
+
RESPONSE="$(mktemp)"
|
|
176
199
|
cat >"$BRIEF" <<'EOF'
|
|
177
200
|
Describe the delegated task, the files or behavior to change, and the checks
|
|
178
201
|
that must pass. Keep the response concise and report validation evidence.
|
|
179
202
|
EOF
|
|
180
|
-
delegate --root "$
|
|
203
|
+
delegate --root "${DELEGATE_ROOT:-$HOME/delegation-state}" dispatch --auto \
|
|
181
204
|
--brief "$BRIEF" \
|
|
182
205
|
--cwd "$WORKSPACE" \
|
|
183
206
|
--permission read-only \
|
|
184
207
|
--budget 30m \
|
|
185
|
-
--json
|
|
208
|
+
--json >"$RESPONSE"
|
|
209
|
+
dispatch_exit=$?
|
|
210
|
+
cat "$RESPONSE"
|
|
211
|
+
printf '\nDispatch exit: %s; saved response: %s\n' "$dispatch_exit" "$RESPONSE"
|
|
186
212
|
```
|
|
187
213
|
|
|
188
214
|
For an authorized code change, use `--permission workspace-write`; this requests
|
|
@@ -201,6 +227,12 @@ files, never background commands writing to the same stdout. Read
|
|
|
201
227
|
[parallel reviews and debates](references/collaboration.md) when coordinating
|
|
202
228
|
multiple participants or challenge rounds.
|
|
203
229
|
|
|
230
|
+
Capture the response and exit status in the **original** dispatch invocation,
|
|
231
|
+
as above. Read the saved response if you need it again. Never repeat dispatch
|
|
232
|
+
to obtain its exit code, recover output, or confirm that it worked: each call
|
|
233
|
+
can create new paid work. Once a response says `task_record: created`, save its
|
|
234
|
+
`task_id` and switch to observation. A missing exit code does not undo admission.
|
|
235
|
+
|
|
204
236
|
Save the exact `task_id` from the JSON response. Apply this decision separately
|
|
205
237
|
for **each attempt**, including requests issued together:
|
|
206
238
|
|
|
@@ -219,16 +251,20 @@ never retry that uncertain ID or run Pueue commands.
|
|
|
219
251
|
|
|
220
252
|
### 5. Observe and collect
|
|
221
253
|
|
|
222
|
-
Use the same state root and task ID
|
|
254
|
+
Use the same state root and task ID. Each command below resolves the root
|
|
255
|
+
in its own shell call, so it does not depend on a previous shell variable:
|
|
223
256
|
|
|
224
257
|
```sh
|
|
225
|
-
delegate --root "$
|
|
226
|
-
delegate --root "$
|
|
258
|
+
delegate --root "${DELEGATE_ROOT:-$HOME/delegation-state}" status TASK_ID --json
|
|
259
|
+
delegate --root "${DELEGATE_ROOT:-$HOME/delegation-state}" collect TASK_ID --watch 5s --json
|
|
227
260
|
```
|
|
228
261
|
|
|
229
262
|
Check `status` first: if it is `timed_out`, follow step 6 even when publication
|
|
230
|
-
is pending and no outcome is present.
|
|
231
|
-
|
|
263
|
+
is pending and no outcome is present. If `interaction.pending_requests` is
|
|
264
|
+
nonempty and the interaction is not closed, answer the questions using
|
|
265
|
+
[active-task interaction](references/interaction.md) before collecting again.
|
|
266
|
+
Otherwise, if `collect` exits with code `3` because publication is still
|
|
267
|
+
pending, wait a short interval and run
|
|
232
268
|
`collect` again. Do not dispatch again. Continue until
|
|
233
269
|
the response has a terminal `outcome` or a bounded operational error that
|
|
234
270
|
requires the caller’s attention.
|
|
@@ -56,6 +56,46 @@
|
|
|
56
56
|
"name": "write-timeout",
|
|
57
57
|
"prompt": "An authorized write task has status timed_out, publication unknown, no outcome, and continuation.resumable true.",
|
|
58
58
|
"expected": ["delegate continue --task", "same state root", "new task id", "do not wait indefinitely for an outcome", "no fresh unrelated dispatch"]
|
|
59
|
+
},
|
|
60
|
+
{
|
|
61
|
+
"name": "admitted-without-explicit-exit-marker",
|
|
62
|
+
"prompt": "Dispatch returned task_record created, admission admitted, and a task_id. The shell output did not include a separate EXIT marker. Confirm the task and collect its result.",
|
|
63
|
+
"expected": ["use status with returned task_id", "read saved dispatch response if needed", "do not dispatch again to print an exit code", "exactly one admitted task for the assignment"]
|
|
64
|
+
},
|
|
65
|
+
{
|
|
66
|
+
"name": "supplied-root-across-shell-calls",
|
|
67
|
+
"prompt": "DELEGATE_ROOT is already set. Consult a separate external agent and answer its questions; each shell tool call starts a new shell.",
|
|
68
|
+
"expected": ["use supplied DELEGATE_ROOT on dispatch, status, collect, reply, steer, and continue", "resolve the same root in each shell call", "no invented task-specific root"]
|
|
69
|
+
},
|
|
70
|
+
{
|
|
71
|
+
"name": "pending-without-questions",
|
|
72
|
+
"prompt": "The admitted task is running. Collect exits 3 with pending publication, empty pending_requests, and no operational error.",
|
|
73
|
+
"expected": ["keep collecting the same task", "no ps or pgrep or process-tree inspection", "no supervisor commands", "no duplicate dispatch", "answer through delegate reply when a question appears"]
|
|
74
|
+
},
|
|
75
|
+
{
|
|
76
|
+
"name": "interactive-worker-assignment",
|
|
77
|
+
"prompt": "Consult a separate external agent about a pricing plan and answer its questions from README.md.",
|
|
78
|
+
"expected": ["brief assigns the pricing investigation directly", "worker does not recruit another external agent", "lead answers through delegate reply", "do not copy the orchestration request verbatim"]
|
|
79
|
+
},
|
|
80
|
+
{
|
|
81
|
+
"name": "interactive-clarification",
|
|
82
|
+
"prompt": "An external planning task returned pending.kind interaction with question IDs, choices, and free_text false. The requested preference is not in the user brief.",
|
|
83
|
+
"expected": ["read references/interaction.md", "ask user for missing preference", "reply through delegate with exact request and question IDs", "stable message ID", "continue collecting"]
|
|
84
|
+
},
|
|
85
|
+
{
|
|
86
|
+
"name": "interactive-steering",
|
|
87
|
+
"prompt": "The user adds guidance while an interactive external task is running and its capabilities advertise steering.",
|
|
88
|
+
"expected": ["delegate steer", "preserve task model permission and budget", "do not cancel and redispatch", "receipt is not completion"]
|
|
89
|
+
},
|
|
90
|
+
{
|
|
91
|
+
"name": "interactive-unknown-delivery",
|
|
92
|
+
"prompt": "A reply submission lost its CLI response. Its recorded delivery is unknown.",
|
|
93
|
+
"expected": ["same message ID and exact content to retrieve receipt", "no new message ID retry", "no native CLI bypass", "observe task"]
|
|
94
|
+
},
|
|
95
|
+
{
|
|
96
|
+
"name": "interactive-unsupported-destination",
|
|
97
|
+
"prompt": "A named external provider supports continuation but neither native clarification nor steering. The user wants a discussion with it.",
|
|
98
|
+
"expected": ["preserve named provider", "ordinary bounded turns and continuation", "explain no active-turn questions", "do not pass unsupported interactive flag"]
|
|
59
99
|
}
|
|
60
100
|
]
|
|
61
101
|
}
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
# JSON decision sketch
|
|
2
2
|
|
|
3
3
|
```sh
|
|
4
|
-
delegate --root "$
|
|
5
|
-
delegate --root "$
|
|
4
|
+
delegate --root "${DELEGATE_ROOT:-$HOME/delegation-state}" status "$TASK_ID" --json
|
|
5
|
+
delegate --root "${DELEGATE_ROOT:-$HOME/delegation-state}" collect "$TASK_ID" --watch 5s --json
|
|
6
6
|
```
|
|
7
7
|
|
|
8
8
|
Decision order:
|
|
@@ -1,10 +1,9 @@
|
|
|
1
1
|
# Read-only task
|
|
2
2
|
|
|
3
3
|
```sh
|
|
4
|
-
STATE_ROOT="${DELEGATE_ROOT:-$HOME/delegation-state}"
|
|
5
4
|
BRIEF="$(mktemp)"
|
|
6
5
|
printf '%s\n' 'Inspect the workspace and summarize the current test failures. Do not edit files.' >"$BRIEF"
|
|
7
|
-
delegate --root "$
|
|
6
|
+
delegate --root "${DELEGATE_ROOT:-$HOME/delegation-state}" dispatch --auto \
|
|
8
7
|
--brief "$BRIEF" --cwd "$PWD" --permission read-only --budget 15m --json
|
|
9
8
|
```
|
|
10
9
|
|
|
@@ -1,8 +1,7 @@
|
|
|
1
1
|
# Authorized workspace write task
|
|
2
2
|
|
|
3
3
|
```sh
|
|
4
|
-
|
|
5
|
-
delegate --root "$STATE_ROOT" dispatch --auto \
|
|
4
|
+
delegate --root "${DELEGATE_ROOT:-$HOME/delegation-state}" dispatch --auto \
|
|
6
5
|
--brief "$PWD/delegated-task.md" --cwd "$PWD" \
|
|
7
6
|
--permission workspace-write --budget 30m --json
|
|
8
7
|
```
|
|
@@ -19,14 +19,14 @@ RECEIPTS="$(mktemp -d)" || exit 1
|
|
|
19
19
|
# Set these absolute paths and catalog IDs in this same tool invocation.
|
|
20
20
|
# BRIEF_A and BRIEF_B contain the real independent assignments.
|
|
21
21
|
(
|
|
22
|
-
delegate --root "$
|
|
22
|
+
delegate --root "${DELEGATE_ROOT:-$HOME/delegation-state}" dispatch --provider "$PROVIDER_A" \
|
|
23
23
|
--brief "$BRIEF_A" --cwd "$WORKSPACE_A" \
|
|
24
24
|
--permission read-only --budget 30m --json \
|
|
25
25
|
>"$RECEIPTS/review-a.json" 2>"$RECEIPTS/review-a.stderr"
|
|
26
26
|
printf '%s\n' "$?" >"$RECEIPTS/review-a.exit"
|
|
27
27
|
) &
|
|
28
28
|
(
|
|
29
|
-
delegate --root "$
|
|
29
|
+
delegate --root "${DELEGATE_ROOT:-$HOME/delegation-state}" dispatch --provider "$PROVIDER_B" \
|
|
30
30
|
--brief "$BRIEF_B" --cwd "$WORKSPACE_B" \
|
|
31
31
|
--permission read-only --budget 30m --json \
|
|
32
32
|
>"$RECEIPTS/review-b.json" 2>"$RECEIPTS/review-b.stderr"
|
|
@@ -14,6 +14,9 @@ All paths passed to `--root`, `--cwd`, and `--brief` must be absolute. Add
|
|
|
14
14
|
| `delegate status TASK --json` | Reconcile and observe task state | No provider launch |
|
|
15
15
|
| `delegate collect TASK --watch 5s --json` | Read or wait for publication | No provider launch |
|
|
16
16
|
| `delegate continue --task TASK ... --json` | Create an exact-session successor | Yes, at most once for the successor |
|
|
17
|
+
| `delegate reply TASK --request ID --answers FILE --id MESSAGE_ID --json` | Answer a pending native question | No new launch |
|
|
18
|
+
| `delegate steer TASK --brief FILE --id MESSAGE_ID --json` | Guide a supported active turn | No new launch |
|
|
19
|
+
| `delegate events TASK --after SEQUENCE --watch 5s --json` | Read a bounded interaction event page | No |
|
|
17
20
|
| `delegate logs TASK --json` | Return validated output descriptors | No |
|
|
18
21
|
| `delegate cancel TASK --json` | Record one explicit stop request | Stops, does not relaunch |
|
|
19
22
|
|
|
@@ -30,9 +33,11 @@ Dispatch flags:
|
|
|
30
33
|
- `--auto`: let the CLI select a ready provider;
|
|
31
34
|
- `--provider ID`: preserve the caller’s named harness or provider, resolved through the catalog;
|
|
32
35
|
- `--model MODEL` and `--effort VALUE`: provider-advertised choices (CCR requires a model alias);
|
|
33
|
-
Codex maps effort to TOML `model_reasoning_effort
|
|
36
|
+
Codex maps effort to TOML `model_reasoning_effort` for ordinary turns or a native
|
|
37
|
+
turn parameter for interactive turns, while Claude and AGY
|
|
34
38
|
pass native effort flags; Pi maps effort to `--thinking`; OpenCode maps it to
|
|
35
39
|
`--variant`; CCR forwards effort to Claude and uses `--model` as a CCR alias; `default` is omitted;
|
|
40
|
+
- `--interactive`: enable advertised native clarification and steering; see [interaction](interaction.md);
|
|
36
41
|
- `--native-timeout DURATION`: optional provider-native timeout where advertised.
|
|
37
42
|
|
|
38
43
|
Model discovery uses the same `--provider ID` profiles and accepts an optional
|
|
@@ -47,7 +52,8 @@ Continuation flags:
|
|
|
47
52
|
|
|
48
53
|
- `--task TASK`: predecessor task ID;
|
|
49
54
|
- `--brief FILE`: optional new follow-up instruction;
|
|
50
|
-
- `--budget DURATION`, `--model MODEL`, and `--effort VALUE`: optional overrides
|
|
55
|
+
- `--budget DURATION`, `--model MODEL`, and `--effort VALUE`: optional overrides;
|
|
56
|
+
- `--interactive`: enable interaction when supported; already-interactive predecessors keep it.
|
|
51
57
|
|
|
52
58
|
## Choosing models and effort
|
|
53
59
|
|
|
@@ -17,7 +17,7 @@ When `status` or `collect` reports a timed-out turn with:
|
|
|
17
17
|
run:
|
|
18
18
|
|
|
19
19
|
```sh
|
|
20
|
-
delegate --root "$
|
|
20
|
+
delegate --root "${DELEGATE_ROOT:-$HOME/delegation-state}" continue \
|
|
21
21
|
--task PREDECESSOR_TASK_ID \
|
|
22
22
|
--brief FOLLOW_UP_BRIEF \
|
|
23
23
|
--budget 30m \
|
|
@@ -0,0 +1,110 @@
|
|
|
1
|
+
# Questions and guidance during an active task
|
|
2
|
+
|
|
3
|
+
Use this reference when an external task may need clarification or guidance
|
|
4
|
+
before it finishes, including planning, consultation, and debate. Use only
|
|
5
|
+
Delegate commands; do not open a terminal session with the provider.
|
|
6
|
+
|
|
7
|
+
## Choose the transport
|
|
8
|
+
|
|
9
|
+
Read the selected provider's `interaction` capability and
|
|
10
|
+
`interaction.supported_modes`. `clarification` and `steering` are independent.
|
|
11
|
+
Add `--interactive` to dispatch when the chosen provider and permission mode
|
|
12
|
+
support the interaction you need. Keep the user's exact provider, model,
|
|
13
|
+
effort, workspace, permission, and budget.
|
|
14
|
+
|
|
15
|
+
Without a named provider, `dispatch --auto --interactive` selects among
|
|
16
|
+
providers that support interaction. If a named provider does not support it,
|
|
17
|
+
use ordinary bounded turns and `continue` for discussion when native
|
|
18
|
+
continuation is available. Explain that questions cannot be answered during
|
|
19
|
+
that provider's active turn. Never replace the requested provider silently.
|
|
20
|
+
|
|
21
|
+
In the worker brief, explicitly request **native structured clarification**:
|
|
22
|
+
"Use your native question tool to request clarification and await its answer.
|
|
23
|
+
Do not ask only in final text or a progress message and then sleep: the lead
|
|
24
|
+
can answer structured requests, not an unstructured prompt. If the question
|
|
25
|
+
tool is unavailable, report that blocker and finish instead of waiting."
|
|
26
|
+
Assign the actual work directly; the worker should not start another delegate.
|
|
27
|
+
|
|
28
|
+
No change is needed for self-contained tasks that do not need mid-turn input.
|
|
29
|
+
Continuation inherits interaction from its predecessor. `continue --task ID
|
|
30
|
+
--interactive` can enable it for a previously ordinary task.
|
|
31
|
+
|
|
32
|
+
## Respond to questions
|
|
33
|
+
|
|
34
|
+
1. Save the admitted task ID and state root. Run `collect TASK_ID --watch 30s
|
|
35
|
+
--json` with that same root. Exit 3 is pending, not completion. Collection
|
|
36
|
+
returns early when there is an outstanding native question.
|
|
37
|
+
2. Read `interaction.pending_requests`. Use the returned request ID, question
|
|
38
|
+
IDs, options, `multiple`, and `free_text`; do not invent or guess IDs.
|
|
39
|
+
3. Answer facts already supplied by the user or verified during the task.
|
|
40
|
+
Ask the user for missing preferences, business decisions, new scope, or
|
|
41
|
+
authorization. Do not guess an answer to keep the worker moving. A question
|
|
42
|
+
reply does not approve tool access or change the task's permission mode.
|
|
43
|
+
4. Write one JSON object mapping **every question ID in that request** to an
|
|
44
|
+
array of answer strings. A single-choice question takes one value. Use exact
|
|
45
|
+
option labels unless `free_text` permits another answer. Example:
|
|
46
|
+
|
|
47
|
+
```json
|
|
48
|
+
{"color": ["Blue"], "sections": ["Summary", "Evidence"]}
|
|
49
|
+
```
|
|
50
|
+
|
|
51
|
+
5. Allocate a new 32-character lowercase hexadecimal message ID and save it
|
|
52
|
+
together with the exact answers. Submit once:
|
|
53
|
+
|
|
54
|
+
```sh
|
|
55
|
+
delegate --root "${DELEGATE_ROOT:-$HOME/delegation-state}" reply "$task_id" \
|
|
56
|
+
--request "$request_id" --answers "$answers_file" \
|
|
57
|
+
--id "$message_id" --json
|
|
58
|
+
```
|
|
59
|
+
|
|
60
|
+
6. Keep collecting. A receipt is not task completion. Only the task's
|
|
61
|
+
authoritative `outcome` establishes the final result.
|
|
62
|
+
|
|
63
|
+
Use the same root expression for dispatch, collection, reply, and steering.
|
|
64
|
+
If the user explicitly chose another root, use that exact path for all of
|
|
65
|
+
them. The other variables stand for actual values saved from this task;
|
|
66
|
+
reassign them in each shell invocation if your tool does not preserve variables.
|
|
67
|
+
A pending response without questions means keep collecting, not inspect OS
|
|
68
|
+
processes or dispatch a replacement task.
|
|
69
|
+
|
|
70
|
+
## Guide active work
|
|
71
|
+
|
|
72
|
+
When `interaction.capabilities.steering` is true and the task is active, put
|
|
73
|
+
additional guidance in a brief file and submit:
|
|
74
|
+
|
|
75
|
+
```sh
|
|
76
|
+
delegate --root "${DELEGATE_ROOT:-$HOME/delegation-state}" steer "$task_id" \
|
|
77
|
+
--brief "$guidance_file" --id "$message_id" --json
|
|
78
|
+
```
|
|
79
|
+
|
|
80
|
+
Steering is guidance to the existing turn. It does not change provider, model,
|
|
81
|
+
effort, workspace, permission, or budget. Once the turn ends, use `continue`
|
|
82
|
+
for another authorized turn instead. Do not cancel and redispatch simply to
|
|
83
|
+
send guidance.
|
|
84
|
+
|
|
85
|
+
## Interpret delivery precisely
|
|
86
|
+
|
|
87
|
+
| State | What it establishes |
|
|
88
|
+
| --- | --- |
|
|
89
|
+
| `queued` | Delegate durably accepted the message; native delivery is pending. |
|
|
90
|
+
| `unknown` | Delivery was reserved or attempted, but its result is uncertain. |
|
|
91
|
+
| `sent` | The native input write completed; no native acknowledgement is established. |
|
|
92
|
+
| `acknowledged` | A correlated native response acknowledged the message. This does not prove the model followed guidance. |
|
|
93
|
+
| `rejected` | The message could not be delivered or the native protocol rejected it. Read the reason. |
|
|
94
|
+
|
|
95
|
+
If a submission response was lost, repeat the **same message ID and exact
|
|
96
|
+
content** to recover its receipt. Never allocate a fresh ID to retry an
|
|
97
|
+
`unknown` delivery. Delegate will not replay an ambiguous native write.
|
|
98
|
+
Changed content with an existing ID is a conflict. Observe the task instead
|
|
99
|
+
of guessing whether it consumed the message.
|
|
100
|
+
|
|
101
|
+
`events TASK_ID --after SEQUENCE --watch 30s --json` returns a bounded event
|
|
102
|
+
page. Save the returned `cursor` for the next page. Events and interaction
|
|
103
|
+
state are progress evidence, not a replacement for `collect` and `outcome`.
|
|
104
|
+
|
|
105
|
+
Waiting for an answer consumes the original execution budget; it does not
|
|
106
|
+
pause or extend it. `interaction.deadline` shows the recorded wall-clock
|
|
107
|
+
boundary when execution has started. If the task ends while waiting, do not
|
|
108
|
+
reply to the old request. Follow the ordinary continuation guidance only when
|
|
109
|
+
Delegate reports the task resumable. Preserve any verified answers in the new
|
|
110
|
+
brief; uncertain delivery must not become an automatic replay.
|
|
@@ -17,8 +17,10 @@ the same as a successful provider result.
|
|
|
17
17
|
the result and its payload/evidence descriptors.
|
|
18
18
|
5. If `outcome.verdict` is rejected, report a terminal rejected result with its
|
|
19
19
|
refusal and evidence. Do not retry automatically.
|
|
20
|
-
6.
|
|
21
|
-
|
|
20
|
+
6. If `pending.kind` is `interaction`, handle the returned questions using
|
|
21
|
+
[interaction guidance](interaction.md) before waiting again. Otherwise, if
|
|
22
|
+
`liveness` is queued or running or publication is pending, observe the same
|
|
23
|
+
task with a finite watch interval.
|
|
22
24
|
7. If authentication is `blocked`, preserve that neutral state and tell the
|
|
23
25
|
caller what prerequisite is unavailable without inventing a login command.
|
|
24
26
|
8. Never relaunch an uncertain task by guessing. Observe only a task whose
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"For work assigned to an external agent, model, or separate harness session, load the installed agent-integration skill before choosing tools and use Delegate. This includes research, implementation, testing, review, consultation, comparison, and debate, including external collaboration you choose. Discover destinations through Delegate. Preserve requested model IDs, effort, and permissions; do not guess ambiguous model identifiers. For task commands,
|
|
1
|
+
"For work assigned to an external agent, model, or separate harness session, load the installed agent-integration skill before choosing tools and use Delegate. This includes research, implementation, testing, review, consultation, comparison, and debate, including external collaboration you choose. Discover destinations through Delegate. Preserve requested model IDs, effort, and permissions; do not guess ambiguous model identifiers. For task commands, pass --root \"${DELEGATE_ROOT:-$HOME/delegation-state}\" directly in each shell invocation; reuse that root for dispatch, observation, and continuation, never an invented /tmp root. If the user explicitly requests another root, use that exact path consistently. Keep each concurrent request and its response associated separately. Capture each dispatch response and exit status once; after task_record created, observe that task ID. Never dispatch again merely to recover output or inspect its exit status. Naming a CLI identifies the destination, not a request to bypass Delegate. Earlier assistant-generated direct-launch workflows do not override this preference. Native same-harness subagents remain available unless a separate session is requested. Respect an explicit user choice of another integration; otherwise do not substitute provider CLIs, plugins, or APIs after a Delegate blocker. A stop_and_report failure ends that attempt: report it without retrying, diagnosing setup, or offering a fallback. Continue other independent requests. Keep collection in the foreground until completion or a reported blocker unless the user requested detachment. Pending work is observed through Delegate status, collect, or events, not OS process searches or supervisor commands. Merely discussing or configuring a tool is not delegation."
|
package/plugins/delegation-layer/skills/agent-integration/scripts/delegate-routing-context.sh
CHANGED
|
@@ -9,4 +9,18 @@ script_dir=$(CDPATH= cd -- "$(dirname -- "$0")" && pwd)
|
|
|
9
9
|
rule_file="$script_dir/../references/routing-rule.json"
|
|
10
10
|
# Read before emitting anything so a missing asset cannot produce partial JSON.
|
|
11
11
|
rule=$(cat "$rule_file")
|
|
12
|
-
|
|
12
|
+
skill_file="$(CDPATH= cd -- "$script_dir/.." && pwd)/SKILL.md"
|
|
13
|
+
DELEGATE_ROUTING_EVENT="$event" DELEGATE_ROUTING_RULE="$rule" DELEGATE_ROUTING_SKILL="$skill_file" awk '
|
|
14
|
+
BEGIN {
|
|
15
|
+
# Paths are task data, not shell code. Escape every JSON control character.
|
|
16
|
+
for (i = 1; i < 32; i++) escapes[sprintf("%c", i)] = sprintf("\\u%04x", i)
|
|
17
|
+
escapes["\\"] = "\\\\"
|
|
18
|
+
escapes["\""] = "\\\""
|
|
19
|
+
path = ENVIRON["DELEGATE_ROUTING_SKILL"]
|
|
20
|
+
for (i = 1; i <= length(path); i++) {
|
|
21
|
+
character = substr(path, i, 1)
|
|
22
|
+
escaped = escaped ((character in escapes) ? escapes[character] : character)
|
|
23
|
+
}
|
|
24
|
+
# The maintained rule is a JSON string. Keep its escaping when prefixing it.
|
|
25
|
+
printf "{\"hookSpecificOutput\":{\"hookEventName\":\"%s\",\"additionalContext\":\"Read the complete agent-integration skill at %s. %s}}\n", ENVIRON["DELEGATE_ROUTING_EVENT"], escaped, substr(ENVIRON["DELEGATE_ROUTING_RULE"], 2)
|
|
26
|
+
}'
|
|
@@ -64,10 +64,17 @@ tasks may proceed; the failed attempt must remain reported as failed or blocked.
|
|
|
64
64
|
Delegate owns the supervisor lifecycle. Never install, configure, start,
|
|
65
65
|
inspect, or repair Pueue, and never poll a task unless the response says its
|
|
66
66
|
`task_record` is `created`.
|
|
67
|
-
5. Observe
|
|
67
|
+
5. Observe tasks only through Delegate `status`, `collect`, or `events`.
|
|
68
|
+
Do not run `ps`, `pgrep`, process-tree searches, or supervisor commands to
|
|
69
|
+
monitor delegated work. Pending output is normal startup or work in progress;
|
|
70
|
+
empty `pending_requests` means keep collecting, not diagnose the environment.
|
|
71
|
+
Environment diagnostics require a separately requested troubleshooting task.
|
|
72
|
+
Keep collection in the
|
|
68
73
|
foreground until all requested tasks reach a terminal result or an explicit
|
|
69
74
|
blocker. Do not end a headless turn promising a background notification.
|
|
70
|
-
Pending publication (exit 3) means keep waiting, not success.
|
|
75
|
+
Pending publication (exit 3) means keep waiting, not success. When the JSON
|
|
76
|
+
includes an outstanding `interaction.pending_requests` batch, follow
|
|
77
|
+
[active-task interaction](references/interaction.md) before waiting again. Only detach
|
|
71
78
|
when the user explicitly requests it, retaining the exact task IDs.
|
|
72
79
|
Collection may recover the
|
|
73
80
|
saved supervisor only to observe an already-requested budget stop; it never
|
|
@@ -121,7 +128,7 @@ normal task. For an explicitly requested readiness check, see
|
|
|
121
128
|
[preflight guidance](references/command-reference.md#checking-readiness).
|
|
122
129
|
|
|
123
130
|
The catalog and `capabilities` response expose supported permission modes,
|
|
124
|
-
request options, continuation, and the read-only mechanism. A read-only
|
|
131
|
+
request options, continuation, native interaction, and the read-only mechanism. A read-only
|
|
125
132
|
capability with `containment: "provider-owned"` selects the provider's native
|
|
126
133
|
behavior but is not an independent delegate-owned sandbox. Static discovery
|
|
127
134
|
does not prove authentication or live acceptance; use the dispatch or live
|
|
@@ -143,25 +150,41 @@ it remains ambiguous or discovery is unavailable, ask for the exact model ID;
|
|
|
143
150
|
do not turn a display name into a guessed alias. An explicit ID needs no such
|
|
144
151
|
clarification just because it is absent from discovery.
|
|
145
152
|
|
|
153
|
+
For planning, consultation, debate, or other external work that may need
|
|
154
|
+
answers or guidance while it runs, read [active-task interaction](references/interaction.md)
|
|
155
|
+
and use `--interactive` when supported. Answer known facts yourself; ask the
|
|
156
|
+
user for missing preferences, authorization, or scope. Keep ordinary native
|
|
157
|
+
subagents available under the same-harness rule above.
|
|
158
|
+
|
|
146
159
|
### 3. Prepare separate paths and a finite brief
|
|
147
160
|
|
|
148
161
|
Use an existing task brief when one is supplied. Otherwise create a bounded
|
|
149
162
|
brief file that contains the requested work and its acceptance criteria. Keep
|
|
150
163
|
the state root outside the workspace and provider-writable trees (which can
|
|
151
|
-
include the system temporary directory). Use `DELEGATE_ROOT` when supplied
|
|
164
|
+
include the system temporary directory). Use `DELEGATE_ROOT` when supplied.
|
|
152
165
|
|
|
153
166
|
Run path preparation and dispatch in **one shell/tool invocation**, as shown
|
|
154
167
|
below. Shell variables may disappear between tool calls. For later commands,
|
|
155
168
|
use the actual saved absolute paths or assign them again in that invocation;
|
|
156
169
|
never pass an empty `--root`, `--brief`, or `--cwd`.
|
|
157
170
|
|
|
158
|
-
|
|
171
|
+
Write the brief as the **worker’s own assignment**, not a copy of the
|
|
172
|
+
orchestration request. For “consult another agent about X”, tell the worker
|
|
173
|
+
“Investigate X and return your findings; you are the assigned worker, do not
|
|
174
|
+
delegate this assignment.” Keep dispatching, answering questions, and
|
|
175
|
+
collecting results in the lead session unless recursive delegation was
|
|
176
|
+
explicitly requested.
|
|
177
|
+
|
|
178
|
+
Replace the example brief below with that bounded worker assignment. Do not place the state
|
|
159
179
|
root inside the workspace or place secrets in either path’s task data. Keep it
|
|
160
180
|
outside provider configuration and runtime directories as well. If delegate
|
|
161
181
|
rejects a caller-supplied state root, report the placement error rather than
|
|
162
|
-
silently replacing that root.
|
|
163
|
-
|
|
164
|
-
root
|
|
182
|
+
silently replacing that root. For every task command, use
|
|
183
|
+
`--root "${DELEGATE_ROOT:-$HOME/delegation-state}"` as shown below. This reads the supplied root in each shell call and uses the
|
|
184
|
+
same default when none was supplied; no root setup or new directory choice is
|
|
185
|
+
needed. If the user explicitly requests another root, substitute that exact
|
|
186
|
+
absolute path consistently. Do not change provider settings or switch roots
|
|
187
|
+
when waiting, replying, steering, or continuing.
|
|
165
188
|
|
|
166
189
|
### 4. Dispatch one bounded turn
|
|
167
190
|
|
|
@@ -170,19 +193,22 @@ For a named harness or provider resolved in step 2, replace `--auto` with `--pro
|
|
|
170
193
|
combine the two:
|
|
171
194
|
|
|
172
195
|
```sh
|
|
173
|
-
STATE_ROOT="${DELEGATE_ROOT:-$HOME/delegation-state}"
|
|
174
196
|
WORKSPACE="$PWD"
|
|
175
197
|
BRIEF="$(mktemp)"
|
|
198
|
+
RESPONSE="$(mktemp)"
|
|
176
199
|
cat >"$BRIEF" <<'EOF'
|
|
177
200
|
Describe the delegated task, the files or behavior to change, and the checks
|
|
178
201
|
that must pass. Keep the response concise and report validation evidence.
|
|
179
202
|
EOF
|
|
180
|
-
delegate --root "$
|
|
203
|
+
delegate --root "${DELEGATE_ROOT:-$HOME/delegation-state}" dispatch --auto \
|
|
181
204
|
--brief "$BRIEF" \
|
|
182
205
|
--cwd "$WORKSPACE" \
|
|
183
206
|
--permission read-only \
|
|
184
207
|
--budget 30m \
|
|
185
|
-
--json
|
|
208
|
+
--json >"$RESPONSE"
|
|
209
|
+
dispatch_exit=$?
|
|
210
|
+
cat "$RESPONSE"
|
|
211
|
+
printf '\nDispatch exit: %s; saved response: %s\n' "$dispatch_exit" "$RESPONSE"
|
|
186
212
|
```
|
|
187
213
|
|
|
188
214
|
For an authorized code change, use `--permission workspace-write`; this requests
|
|
@@ -201,6 +227,12 @@ files, never background commands writing to the same stdout. Read
|
|
|
201
227
|
[parallel reviews and debates](references/collaboration.md) when coordinating
|
|
202
228
|
multiple participants or challenge rounds.
|
|
203
229
|
|
|
230
|
+
Capture the response and exit status in the **original** dispatch invocation,
|
|
231
|
+
as above. Read the saved response if you need it again. Never repeat dispatch
|
|
232
|
+
to obtain its exit code, recover output, or confirm that it worked: each call
|
|
233
|
+
can create new paid work. Once a response says `task_record: created`, save its
|
|
234
|
+
`task_id` and switch to observation. A missing exit code does not undo admission.
|
|
235
|
+
|
|
204
236
|
Save the exact `task_id` from the JSON response. Apply this decision separately
|
|
205
237
|
for **each attempt**, including requests issued together:
|
|
206
238
|
|
|
@@ -219,16 +251,20 @@ never retry that uncertain ID or run Pueue commands.
|
|
|
219
251
|
|
|
220
252
|
### 5. Observe and collect
|
|
221
253
|
|
|
222
|
-
Use the same state root and task ID
|
|
254
|
+
Use the same state root and task ID. Each command below resolves the root
|
|
255
|
+
in its own shell call, so it does not depend on a previous shell variable:
|
|
223
256
|
|
|
224
257
|
```sh
|
|
225
|
-
delegate --root "$
|
|
226
|
-
delegate --root "$
|
|
258
|
+
delegate --root "${DELEGATE_ROOT:-$HOME/delegation-state}" status TASK_ID --json
|
|
259
|
+
delegate --root "${DELEGATE_ROOT:-$HOME/delegation-state}" collect TASK_ID --watch 5s --json
|
|
227
260
|
```
|
|
228
261
|
|
|
229
262
|
Check `status` first: if it is `timed_out`, follow step 6 even when publication
|
|
230
|
-
is pending and no outcome is present.
|
|
231
|
-
|
|
263
|
+
is pending and no outcome is present. If `interaction.pending_requests` is
|
|
264
|
+
nonempty and the interaction is not closed, answer the questions using
|
|
265
|
+
[active-task interaction](references/interaction.md) before collecting again.
|
|
266
|
+
Otherwise, if `collect` exits with code `3` because publication is still
|
|
267
|
+
pending, wait a short interval and run
|
|
232
268
|
`collect` again. Do not dispatch again. Continue until
|
|
233
269
|
the response has a terminal `outcome` or a bounded operational error that
|
|
234
270
|
requires the caller’s attention.
|
|
@@ -56,6 +56,46 @@
|
|
|
56
56
|
"name": "write-timeout",
|
|
57
57
|
"prompt": "An authorized write task has status timed_out, publication unknown, no outcome, and continuation.resumable true.",
|
|
58
58
|
"expected": ["delegate continue --task", "same state root", "new task id", "do not wait indefinitely for an outcome", "no fresh unrelated dispatch"]
|
|
59
|
+
},
|
|
60
|
+
{
|
|
61
|
+
"name": "admitted-without-explicit-exit-marker",
|
|
62
|
+
"prompt": "Dispatch returned task_record created, admission admitted, and a task_id. The shell output did not include a separate EXIT marker. Confirm the task and collect its result.",
|
|
63
|
+
"expected": ["use status with returned task_id", "read saved dispatch response if needed", "do not dispatch again to print an exit code", "exactly one admitted task for the assignment"]
|
|
64
|
+
},
|
|
65
|
+
{
|
|
66
|
+
"name": "supplied-root-across-shell-calls",
|
|
67
|
+
"prompt": "DELEGATE_ROOT is already set. Consult a separate external agent and answer its questions; each shell tool call starts a new shell.",
|
|
68
|
+
"expected": ["use supplied DELEGATE_ROOT on dispatch, status, collect, reply, steer, and continue", "resolve the same root in each shell call", "no invented task-specific root"]
|
|
69
|
+
},
|
|
70
|
+
{
|
|
71
|
+
"name": "pending-without-questions",
|
|
72
|
+
"prompt": "The admitted task is running. Collect exits 3 with pending publication, empty pending_requests, and no operational error.",
|
|
73
|
+
"expected": ["keep collecting the same task", "no ps or pgrep or process-tree inspection", "no supervisor commands", "no duplicate dispatch", "answer through delegate reply when a question appears"]
|
|
74
|
+
},
|
|
75
|
+
{
|
|
76
|
+
"name": "interactive-worker-assignment",
|
|
77
|
+
"prompt": "Consult a separate external agent about a pricing plan and answer its questions from README.md.",
|
|
78
|
+
"expected": ["brief assigns the pricing investigation directly", "worker does not recruit another external agent", "lead answers through delegate reply", "do not copy the orchestration request verbatim"]
|
|
79
|
+
},
|
|
80
|
+
{
|
|
81
|
+
"name": "interactive-clarification",
|
|
82
|
+
"prompt": "An external planning task returned pending.kind interaction with question IDs, choices, and free_text false. The requested preference is not in the user brief.",
|
|
83
|
+
"expected": ["read references/interaction.md", "ask user for missing preference", "reply through delegate with exact request and question IDs", "stable message ID", "continue collecting"]
|
|
84
|
+
},
|
|
85
|
+
{
|
|
86
|
+
"name": "interactive-steering",
|
|
87
|
+
"prompt": "The user adds guidance while an interactive external task is running and its capabilities advertise steering.",
|
|
88
|
+
"expected": ["delegate steer", "preserve task model permission and budget", "do not cancel and redispatch", "receipt is not completion"]
|
|
89
|
+
},
|
|
90
|
+
{
|
|
91
|
+
"name": "interactive-unknown-delivery",
|
|
92
|
+
"prompt": "A reply submission lost its CLI response. Its recorded delivery is unknown.",
|
|
93
|
+
"expected": ["same message ID and exact content to retrieve receipt", "no new message ID retry", "no native CLI bypass", "observe task"]
|
|
94
|
+
},
|
|
95
|
+
{
|
|
96
|
+
"name": "interactive-unsupported-destination",
|
|
97
|
+
"prompt": "A named external provider supports continuation but neither native clarification nor steering. The user wants a discussion with it.",
|
|
98
|
+
"expected": ["preserve named provider", "ordinary bounded turns and continuation", "explain no active-turn questions", "do not pass unsupported interactive flag"]
|
|
59
99
|
}
|
|
60
100
|
]
|
|
61
101
|
}
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
# JSON decision sketch
|
|
2
2
|
|
|
3
3
|
```sh
|
|
4
|
-
delegate --root "$
|
|
5
|
-
delegate --root "$
|
|
4
|
+
delegate --root "${DELEGATE_ROOT:-$HOME/delegation-state}" status "$TASK_ID" --json
|
|
5
|
+
delegate --root "${DELEGATE_ROOT:-$HOME/delegation-state}" collect "$TASK_ID" --watch 5s --json
|
|
6
6
|
```
|
|
7
7
|
|
|
8
8
|
Decision order:
|
|
@@ -1,10 +1,9 @@
|
|
|
1
1
|
# Read-only task
|
|
2
2
|
|
|
3
3
|
```sh
|
|
4
|
-
STATE_ROOT="${DELEGATE_ROOT:-$HOME/delegation-state}"
|
|
5
4
|
BRIEF="$(mktemp)"
|
|
6
5
|
printf '%s\n' 'Inspect the workspace and summarize the current test failures. Do not edit files.' >"$BRIEF"
|
|
7
|
-
delegate --root "$
|
|
6
|
+
delegate --root "${DELEGATE_ROOT:-$HOME/delegation-state}" dispatch --auto \
|
|
8
7
|
--brief "$BRIEF" --cwd "$PWD" --permission read-only --budget 15m --json
|
|
9
8
|
```
|
|
10
9
|
|
|
@@ -1,8 +1,7 @@
|
|
|
1
1
|
# Authorized workspace write task
|
|
2
2
|
|
|
3
3
|
```sh
|
|
4
|
-
|
|
5
|
-
delegate --root "$STATE_ROOT" dispatch --auto \
|
|
4
|
+
delegate --root "${DELEGATE_ROOT:-$HOME/delegation-state}" dispatch --auto \
|
|
6
5
|
--brief "$PWD/delegated-task.md" --cwd "$PWD" \
|
|
7
6
|
--permission workspace-write --budget 30m --json
|
|
8
7
|
```
|
|
@@ -19,14 +19,14 @@ RECEIPTS="$(mktemp -d)" || exit 1
|
|
|
19
19
|
# Set these absolute paths and catalog IDs in this same tool invocation.
|
|
20
20
|
# BRIEF_A and BRIEF_B contain the real independent assignments.
|
|
21
21
|
(
|
|
22
|
-
delegate --root "$
|
|
22
|
+
delegate --root "${DELEGATE_ROOT:-$HOME/delegation-state}" dispatch --provider "$PROVIDER_A" \
|
|
23
23
|
--brief "$BRIEF_A" --cwd "$WORKSPACE_A" \
|
|
24
24
|
--permission read-only --budget 30m --json \
|
|
25
25
|
>"$RECEIPTS/review-a.json" 2>"$RECEIPTS/review-a.stderr"
|
|
26
26
|
printf '%s\n' "$?" >"$RECEIPTS/review-a.exit"
|
|
27
27
|
) &
|
|
28
28
|
(
|
|
29
|
-
delegate --root "$
|
|
29
|
+
delegate --root "${DELEGATE_ROOT:-$HOME/delegation-state}" dispatch --provider "$PROVIDER_B" \
|
|
30
30
|
--brief "$BRIEF_B" --cwd "$WORKSPACE_B" \
|
|
31
31
|
--permission read-only --budget 30m --json \
|
|
32
32
|
>"$RECEIPTS/review-b.json" 2>"$RECEIPTS/review-b.stderr"
|
|
@@ -14,6 +14,9 @@ All paths passed to `--root`, `--cwd`, and `--brief` must be absolute. Add
|
|
|
14
14
|
| `delegate status TASK --json` | Reconcile and observe task state | No provider launch |
|
|
15
15
|
| `delegate collect TASK --watch 5s --json` | Read or wait for publication | No provider launch |
|
|
16
16
|
| `delegate continue --task TASK ... --json` | Create an exact-session successor | Yes, at most once for the successor |
|
|
17
|
+
| `delegate reply TASK --request ID --answers FILE --id MESSAGE_ID --json` | Answer a pending native question | No new launch |
|
|
18
|
+
| `delegate steer TASK --brief FILE --id MESSAGE_ID --json` | Guide a supported active turn | No new launch |
|
|
19
|
+
| `delegate events TASK --after SEQUENCE --watch 5s --json` | Read a bounded interaction event page | No |
|
|
17
20
|
| `delegate logs TASK --json` | Return validated output descriptors | No |
|
|
18
21
|
| `delegate cancel TASK --json` | Record one explicit stop request | Stops, does not relaunch |
|
|
19
22
|
|
|
@@ -30,9 +33,11 @@ Dispatch flags:
|
|
|
30
33
|
- `--auto`: let the CLI select a ready provider;
|
|
31
34
|
- `--provider ID`: preserve the caller’s named harness or provider, resolved through the catalog;
|
|
32
35
|
- `--model MODEL` and `--effort VALUE`: provider-advertised choices (CCR requires a model alias);
|
|
33
|
-
Codex maps effort to TOML `model_reasoning_effort
|
|
36
|
+
Codex maps effort to TOML `model_reasoning_effort` for ordinary turns or a native
|
|
37
|
+
turn parameter for interactive turns, while Claude and AGY
|
|
34
38
|
pass native effort flags; Pi maps effort to `--thinking`; OpenCode maps it to
|
|
35
39
|
`--variant`; CCR forwards effort to Claude and uses `--model` as a CCR alias; `default` is omitted;
|
|
40
|
+
- `--interactive`: enable advertised native clarification and steering; see [interaction](interaction.md);
|
|
36
41
|
- `--native-timeout DURATION`: optional provider-native timeout where advertised.
|
|
37
42
|
|
|
38
43
|
Model discovery uses the same `--provider ID` profiles and accepts an optional
|
|
@@ -47,7 +52,8 @@ Continuation flags:
|
|
|
47
52
|
|
|
48
53
|
- `--task TASK`: predecessor task ID;
|
|
49
54
|
- `--brief FILE`: optional new follow-up instruction;
|
|
50
|
-
- `--budget DURATION`, `--model MODEL`, and `--effort VALUE`: optional overrides
|
|
55
|
+
- `--budget DURATION`, `--model MODEL`, and `--effort VALUE`: optional overrides;
|
|
56
|
+
- `--interactive`: enable interaction when supported; already-interactive predecessors keep it.
|
|
51
57
|
|
|
52
58
|
## Choosing models and effort
|
|
53
59
|
|
|
@@ -17,7 +17,7 @@ When `status` or `collect` reports a timed-out turn with:
|
|
|
17
17
|
run:
|
|
18
18
|
|
|
19
19
|
```sh
|
|
20
|
-
delegate --root "$
|
|
20
|
+
delegate --root "${DELEGATE_ROOT:-$HOME/delegation-state}" continue \
|
|
21
21
|
--task PREDECESSOR_TASK_ID \
|
|
22
22
|
--brief FOLLOW_UP_BRIEF \
|
|
23
23
|
--budget 30m \
|
|
@@ -0,0 +1,110 @@
|
|
|
1
|
+
# Questions and guidance during an active task
|
|
2
|
+
|
|
3
|
+
Use this reference when an external task may need clarification or guidance
|
|
4
|
+
before it finishes, including planning, consultation, and debate. Use only
|
|
5
|
+
Delegate commands; do not open a terminal session with the provider.
|
|
6
|
+
|
|
7
|
+
## Choose the transport
|
|
8
|
+
|
|
9
|
+
Read the selected provider's `interaction` capability and
|
|
10
|
+
`interaction.supported_modes`. `clarification` and `steering` are independent.
|
|
11
|
+
Add `--interactive` to dispatch when the chosen provider and permission mode
|
|
12
|
+
support the interaction you need. Keep the user's exact provider, model,
|
|
13
|
+
effort, workspace, permission, and budget.
|
|
14
|
+
|
|
15
|
+
Without a named provider, `dispatch --auto --interactive` selects among
|
|
16
|
+
providers that support interaction. If a named provider does not support it,
|
|
17
|
+
use ordinary bounded turns and `continue` for discussion when native
|
|
18
|
+
continuation is available. Explain that questions cannot be answered during
|
|
19
|
+
that provider's active turn. Never replace the requested provider silently.
|
|
20
|
+
|
|
21
|
+
In the worker brief, explicitly request **native structured clarification**:
|
|
22
|
+
"Use your native question tool to request clarification and await its answer.
|
|
23
|
+
Do not ask only in final text or a progress message and then sleep: the lead
|
|
24
|
+
can answer structured requests, not an unstructured prompt. If the question
|
|
25
|
+
tool is unavailable, report that blocker and finish instead of waiting."
|
|
26
|
+
Assign the actual work directly; the worker should not start another delegate.
|
|
27
|
+
|
|
28
|
+
No change is needed for self-contained tasks that do not need mid-turn input.
|
|
29
|
+
Continuation inherits interaction from its predecessor. `continue --task ID
|
|
30
|
+
--interactive` can enable it for a previously ordinary task.
|
|
31
|
+
|
|
32
|
+
## Respond to questions
|
|
33
|
+
|
|
34
|
+
1. Save the admitted task ID and state root. Run `collect TASK_ID --watch 30s
|
|
35
|
+
--json` with that same root. Exit 3 is pending, not completion. Collection
|
|
36
|
+
returns early when there is an outstanding native question.
|
|
37
|
+
2. Read `interaction.pending_requests`. Use the returned request ID, question
|
|
38
|
+
IDs, options, `multiple`, and `free_text`; do not invent or guess IDs.
|
|
39
|
+
3. Answer facts already supplied by the user or verified during the task.
|
|
40
|
+
Ask the user for missing preferences, business decisions, new scope, or
|
|
41
|
+
authorization. Do not guess an answer to keep the worker moving. A question
|
|
42
|
+
reply does not approve tool access or change the task's permission mode.
|
|
43
|
+
4. Write one JSON object mapping **every question ID in that request** to an
|
|
44
|
+
array of answer strings. A single-choice question takes one value. Use exact
|
|
45
|
+
option labels unless `free_text` permits another answer. Example:
|
|
46
|
+
|
|
47
|
+
```json
|
|
48
|
+
{"color": ["Blue"], "sections": ["Summary", "Evidence"]}
|
|
49
|
+
```
|
|
50
|
+
|
|
51
|
+
5. Allocate a new 32-character lowercase hexadecimal message ID and save it
|
|
52
|
+
together with the exact answers. Submit once:
|
|
53
|
+
|
|
54
|
+
```sh
|
|
55
|
+
delegate --root "${DELEGATE_ROOT:-$HOME/delegation-state}" reply "$task_id" \
|
|
56
|
+
--request "$request_id" --answers "$answers_file" \
|
|
57
|
+
--id "$message_id" --json
|
|
58
|
+
```
|
|
59
|
+
|
|
60
|
+
6. Keep collecting. A receipt is not task completion. Only the task's
|
|
61
|
+
authoritative `outcome` establishes the final result.
|
|
62
|
+
|
|
63
|
+
Use the same root expression for dispatch, collection, reply, and steering.
|
|
64
|
+
If the user explicitly chose another root, use that exact path for all of
|
|
65
|
+
them. The other variables stand for actual values saved from this task;
|
|
66
|
+
reassign them in each shell invocation if your tool does not preserve variables.
|
|
67
|
+
A pending response without questions means keep collecting, not inspect OS
|
|
68
|
+
processes or dispatch a replacement task.
|
|
69
|
+
|
|
70
|
+
## Guide active work
|
|
71
|
+
|
|
72
|
+
When `interaction.capabilities.steering` is true and the task is active, put
|
|
73
|
+
additional guidance in a brief file and submit:
|
|
74
|
+
|
|
75
|
+
```sh
|
|
76
|
+
delegate --root "${DELEGATE_ROOT:-$HOME/delegation-state}" steer "$task_id" \
|
|
77
|
+
--brief "$guidance_file" --id "$message_id" --json
|
|
78
|
+
```
|
|
79
|
+
|
|
80
|
+
Steering is guidance to the existing turn. It does not change provider, model,
|
|
81
|
+
effort, workspace, permission, or budget. Once the turn ends, use `continue`
|
|
82
|
+
for another authorized turn instead. Do not cancel and redispatch simply to
|
|
83
|
+
send guidance.
|
|
84
|
+
|
|
85
|
+
## Interpret delivery precisely
|
|
86
|
+
|
|
87
|
+
| State | What it establishes |
|
|
88
|
+
| --- | --- |
|
|
89
|
+
| `queued` | Delegate durably accepted the message; native delivery is pending. |
|
|
90
|
+
| `unknown` | Delivery was reserved or attempted, but its result is uncertain. |
|
|
91
|
+
| `sent` | The native input write completed; no native acknowledgement is established. |
|
|
92
|
+
| `acknowledged` | A correlated native response acknowledged the message. This does not prove the model followed guidance. |
|
|
93
|
+
| `rejected` | The message could not be delivered or the native protocol rejected it. Read the reason. |
|
|
94
|
+
|
|
95
|
+
If a submission response was lost, repeat the **same message ID and exact
|
|
96
|
+
content** to recover its receipt. Never allocate a fresh ID to retry an
|
|
97
|
+
`unknown` delivery. Delegate will not replay an ambiguous native write.
|
|
98
|
+
Changed content with an existing ID is a conflict. Observe the task instead
|
|
99
|
+
of guessing whether it consumed the message.
|
|
100
|
+
|
|
101
|
+
`events TASK_ID --after SEQUENCE --watch 30s --json` returns a bounded event
|
|
102
|
+
page. Save the returned `cursor` for the next page. Events and interaction
|
|
103
|
+
state are progress evidence, not a replacement for `collect` and `outcome`.
|
|
104
|
+
|
|
105
|
+
Waiting for an answer consumes the original execution budget; it does not
|
|
106
|
+
pause or extend it. `interaction.deadline` shows the recorded wall-clock
|
|
107
|
+
boundary when execution has started. If the task ends while waiting, do not
|
|
108
|
+
reply to the old request. Follow the ordinary continuation guidance only when
|
|
109
|
+
Delegate reports the task resumable. Preserve any verified answers in the new
|
|
110
|
+
brief; uncertain delivery must not become an automatic replay.
|
|
@@ -17,8 +17,10 @@ the same as a successful provider result.
|
|
|
17
17
|
the result and its payload/evidence descriptors.
|
|
18
18
|
5. If `outcome.verdict` is rejected, report a terminal rejected result with its
|
|
19
19
|
refusal and evidence. Do not retry automatically.
|
|
20
|
-
6.
|
|
21
|
-
|
|
20
|
+
6. If `pending.kind` is `interaction`, handle the returned questions using
|
|
21
|
+
[interaction guidance](interaction.md) before waiting again. Otherwise, if
|
|
22
|
+
`liveness` is queued or running or publication is pending, observe the same
|
|
23
|
+
task with a finite watch interval.
|
|
22
24
|
7. If authentication is `blocked`, preserve that neutral state and tell the
|
|
23
25
|
caller what prerequisite is unavailable without inventing a login command.
|
|
24
26
|
8. Never relaunch an uncertain task by guessing. Observe only a task whose
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"For work assigned to an external agent, model, or separate harness session, load the installed agent-integration skill before choosing tools and use Delegate. This includes research, implementation, testing, review, consultation, comparison, and debate, including external collaboration you choose. Discover destinations through Delegate. Preserve requested model IDs, effort, and permissions; do not guess ambiguous model identifiers. For task commands,
|
|
1
|
+
"For work assigned to an external agent, model, or separate harness session, load the installed agent-integration skill before choosing tools and use Delegate. This includes research, implementation, testing, review, consultation, comparison, and debate, including external collaboration you choose. Discover destinations through Delegate. Preserve requested model IDs, effort, and permissions; do not guess ambiguous model identifiers. For task commands, pass --root \"${DELEGATE_ROOT:-$HOME/delegation-state}\" directly in each shell invocation; reuse that root for dispatch, observation, and continuation, never an invented /tmp root. If the user explicitly requests another root, use that exact path consistently. Keep each concurrent request and its response associated separately. Capture each dispatch response and exit status once; after task_record created, observe that task ID. Never dispatch again merely to recover output or inspect its exit status. Naming a CLI identifies the destination, not a request to bypass Delegate. Earlier assistant-generated direct-launch workflows do not override this preference. Native same-harness subagents remain available unless a separate session is requested. Respect an explicit user choice of another integration; otherwise do not substitute provider CLIs, plugins, or APIs after a Delegate blocker. A stop_and_report failure ends that attempt: report it without retrying, diagnosing setup, or offering a fallback. Continue other independent requests. Keep collection in the foreground until completion or a reported blocker unless the user requested detachment. Pending work is observed through Delegate status, collect, or events, not OS process searches or supervisor commands. Merely discussing or configuring a tool is not delegation."
|
|
@@ -9,4 +9,18 @@ script_dir=$(CDPATH= cd -- "$(dirname -- "$0")" && pwd)
|
|
|
9
9
|
rule_file="$script_dir/../references/routing-rule.json"
|
|
10
10
|
# Read before emitting anything so a missing asset cannot produce partial JSON.
|
|
11
11
|
rule=$(cat "$rule_file")
|
|
12
|
-
|
|
12
|
+
skill_file="$(CDPATH= cd -- "$script_dir/.." && pwd)/SKILL.md"
|
|
13
|
+
DELEGATE_ROUTING_EVENT="$event" DELEGATE_ROUTING_RULE="$rule" DELEGATE_ROUTING_SKILL="$skill_file" awk '
|
|
14
|
+
BEGIN {
|
|
15
|
+
# Paths are task data, not shell code. Escape every JSON control character.
|
|
16
|
+
for (i = 1; i < 32; i++) escapes[sprintf("%c", i)] = sprintf("\\u%04x", i)
|
|
17
|
+
escapes["\\"] = "\\\\"
|
|
18
|
+
escapes["\""] = "\\\""
|
|
19
|
+
path = ENVIRON["DELEGATE_ROUTING_SKILL"]
|
|
20
|
+
for (i = 1; i <= length(path); i++) {
|
|
21
|
+
character = substr(path, i, 1)
|
|
22
|
+
escaped = escaped ((character in escapes) ? escapes[character] : character)
|
|
23
|
+
}
|
|
24
|
+
# The maintained rule is a JSON string. Keep its escaping when prefixing it.
|
|
25
|
+
printf "{\"hookSpecificOutput\":{\"hookEventName\":\"%s\",\"additionalContext\":\"Read the complete agent-integration skill at %s. %s}}\n", ENVIRON["DELEGATE_ROUTING_EVENT"], escaped, substr(ENVIRON["DELEGATE_ROUTING_RULE"], 2)
|
|
26
|
+
}'
|