delegation-layer 0.1.19 → 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 +13 -6
- 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/hooks/hooks.json +18 -0
- package/plugins/delegation-layer/skills/agent-integration/SKILL.md +70 -20
- package/plugins/delegation-layer/skills/agent-integration/evals/evals.json +40 -0
- package/plugins/delegation-layer/skills/agent-integration/evals/routing.json +47 -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 +77 -0
- package/plugins/delegation-layer/skills/agent-integration/references/command-reference.md +15 -4
- 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 -0
- package/plugins/delegation-layer/skills/agent-integration/scripts/delegate-routing-context.sh +26 -0
- package/scripts/install-agent-integration.mjs +212 -5
- package/skills/agent-integration/SKILL.md +70 -20
- package/skills/agent-integration/evals/evals.json +40 -0
- package/skills/agent-integration/evals/routing.json +47 -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 +77 -0
- package/skills/agent-integration/references/command-reference.md +15 -4
- 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 -0
- package/skills/agent-integration/scripts/delegate-routing-context.sh +26 -0
|
@@ -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
|
}
|
|
@@ -198,6 +198,53 @@
|
|
|
198
198
|
"codex:exec"
|
|
199
199
|
],
|
|
200
200
|
"split": "validation"
|
|
201
|
+
},
|
|
202
|
+
{
|
|
203
|
+
"name": "requested-model-effort",
|
|
204
|
+
"prompt": "Ask a separate Codex CLI session to review pricing.py without edits. Use model gpt-5.6-luna and effort max, preserving both choices.",
|
|
205
|
+
"external": true,
|
|
206
|
+
"provider": "codex:exec",
|
|
207
|
+
"model": "gpt-5.6-luna",
|
|
208
|
+
"effort": "max",
|
|
209
|
+
"split": "validation",
|
|
210
|
+
"regression": true
|
|
211
|
+
},
|
|
212
|
+
{
|
|
213
|
+
"name": "ambiguous-model",
|
|
214
|
+
"prompt": "Ask a separate Antigravity CLI session to review pricing.py using the fastest Flash model. I do not know the exact model ID. Do not edit files.",
|
|
215
|
+
"external": true,
|
|
216
|
+
"provider": "antigravity:print",
|
|
217
|
+
"expectation": "Resolve an exact model ID through discovery; clarify if unavailable or ambiguous. Never guess an identifier.",
|
|
218
|
+
"split": "validation",
|
|
219
|
+
"regression": true
|
|
220
|
+
},
|
|
221
|
+
{
|
|
222
|
+
"name": "parallel-receipts",
|
|
223
|
+
"prompt": "Ask separate Codex and Claude CLI sessions to independently review pricing.py against README.md concurrently. Keep the exact provider-to-task-ID mapping for both, including any failed dispatch. No edits.",
|
|
224
|
+
"external": true,
|
|
225
|
+
"provider": [
|
|
226
|
+
"codex:exec",
|
|
227
|
+
"claude:print"
|
|
228
|
+
],
|
|
229
|
+
"split": "validation",
|
|
230
|
+
"regression": true
|
|
231
|
+
},
|
|
232
|
+
{
|
|
233
|
+
"name": "subagent-external",
|
|
234
|
+
"prompt": "Use an ordinary native subagent to coordinate a read-only second opinion from a separate Codex CLI session about pricing.py. Let the subagent choose its tools. Report the external finding or blocker.",
|
|
235
|
+
"external": true,
|
|
236
|
+
"provider": "codex:exec",
|
|
237
|
+
"split": "validation",
|
|
238
|
+
"regression": true
|
|
239
|
+
},
|
|
240
|
+
{
|
|
241
|
+
"name": "explicit-bypass",
|
|
242
|
+
"prompt": "For this request explicitly bypass Delegate and its skill. Run only codex --version directly; do not start a model session or review.",
|
|
243
|
+
"external": false,
|
|
244
|
+
"provider": null,
|
|
245
|
+
"expectation": "Respect the explicit direct integration choice; this bounded test proves bypass permission, not task completion.",
|
|
246
|
+
"split": "validation",
|
|
247
|
+
"regression": true
|
|
201
248
|
}
|
|
202
249
|
]
|
|
203
250
|
}
|
|
@@ -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
|
```
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
# Parallel reviews and debates
|
|
2
|
+
|
|
3
|
+
## Keep each request identifiable
|
|
4
|
+
|
|
5
|
+
Choose the fan-out needed for the user's task. Each participant needs its own
|
|
6
|
+
brief and response association, even when two participants use the same provider.
|
|
7
|
+
Record the request label, provider, exact requested model/effort, workspace,
|
|
8
|
+
permission, state root, and response together. The label identifies the attempt
|
|
9
|
+
before admission; the returned task ID identifies it afterward.
|
|
10
|
+
|
|
11
|
+
Prefer independent tool calls: each tool result belongs to its invocation.
|
|
12
|
+
When a shell must launch requests concurrently, redirect each invocation to its
|
|
13
|
+
own files. Never use `dispatch ... & dispatch ... & wait` with shared stdout.
|
|
14
|
+
|
|
15
|
+
After preparing two independent briefs, a portable capture pattern is:
|
|
16
|
+
|
|
17
|
+
```sh
|
|
18
|
+
RECEIPTS="$(mktemp -d)" || exit 1
|
|
19
|
+
# Set these absolute paths and catalog IDs in this same tool invocation.
|
|
20
|
+
# BRIEF_A and BRIEF_B contain the real independent assignments.
|
|
21
|
+
(
|
|
22
|
+
delegate --root "${DELEGATE_ROOT:-$HOME/delegation-state}" dispatch --provider "$PROVIDER_A" \
|
|
23
|
+
--brief "$BRIEF_A" --cwd "$WORKSPACE_A" \
|
|
24
|
+
--permission read-only --budget 30m --json \
|
|
25
|
+
>"$RECEIPTS/review-a.json" 2>"$RECEIPTS/review-a.stderr"
|
|
26
|
+
printf '%s\n' "$?" >"$RECEIPTS/review-a.exit"
|
|
27
|
+
) &
|
|
28
|
+
(
|
|
29
|
+
delegate --root "${DELEGATE_ROOT:-$HOME/delegation-state}" dispatch --provider "$PROVIDER_B" \
|
|
30
|
+
--brief "$BRIEF_B" --cwd "$WORKSPACE_B" \
|
|
31
|
+
--permission read-only --budget 30m --json \
|
|
32
|
+
>"$RECEIPTS/review-b.json" 2>"$RECEIPTS/review-b.stderr"
|
|
33
|
+
printf '%s\n' "$?" >"$RECEIPTS/review-b.exit"
|
|
34
|
+
) &
|
|
35
|
+
wait
|
|
36
|
+
printf 'Read each response separately in %s\n' "$RECEIPTS"
|
|
37
|
+
```
|
|
38
|
+
|
|
39
|
+
Keep the request-to-label mapping alongside those files. Include any exact
|
|
40
|
+
requested model/effort in its invocation. Read both exit codes, stderr, and JSON
|
|
41
|
+
responses independently; shell `wait` is not proof that either dispatch succeeded.
|
|
42
|
+
Poll only tasks with `task_record: created`. A returned task ID with
|
|
43
|
+
`task_record: not_created` does not identify an observable task.
|
|
44
|
+
|
|
45
|
+
## Wait within the current turn
|
|
46
|
+
|
|
47
|
+
Concurrent dispatch does not require background collection. Collect each task
|
|
48
|
+
in the foreground with a bounded watch; for example, `collect TASK_ID --watch
|
|
49
|
+
30s --json`. Exit 3 means publication is still pending: keep observing that task,
|
|
50
|
+
handling its budget-stop and continuation fields as described in the main skill.
|
|
51
|
+
Do not end a headless turn while a shell background job is meant to finish the
|
|
52
|
+
requested work. The host may close its session at that point and no later
|
|
53
|
+
notification is guaranteed. A user-requested detach is different: report the
|
|
54
|
+
pending task IDs and state root explicitly without claiming completion.
|
|
55
|
+
|
|
56
|
+
## Compare actual results
|
|
57
|
+
|
|
58
|
+
Collect each admitted task to its authoritative terminal outcome. Present each
|
|
59
|
+
participant's findings with its task ID and evidence. Keep a blocked or failed
|
|
60
|
+
participant visible; one successful review does not satisfy a requested pair.
|
|
61
|
+
Do not attribute your own analysis to an unavailable participant.
|
|
62
|
+
|
|
63
|
+
## Challenge and follow up
|
|
64
|
+
|
|
65
|
+
Independent opening reviews may run concurrently. A challenge depends on the
|
|
66
|
+
actual earlier result: collect it first, then include its relevant findings and
|
|
67
|
+
evidence in the other participant's next brief. Never claim a cross-check merely
|
|
68
|
+
because two initial reviews were requested.
|
|
69
|
+
|
|
70
|
+
For an existing participant, use `continue --task TASK_ID` with that participant's
|
|
71
|
+
own predecessor and the follow-up brief. This creates a new task for the same
|
|
72
|
+
provider conversation; save the new ID separately. Use the continuation result
|
|
73
|
+
and [continuation guidance](continuation.md), including advertised resumability
|
|
74
|
+
after a budget stop. Never use another participant's task ID or restart a
|
|
75
|
+
conversation to imitate a follow-up. If the first turn is blocked, report that
|
|
76
|
+
the dependent challenge or follow-up did not run. Other independent assignments
|
|
77
|
+
may still proceed.
|
|
@@ -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,12 +52,14 @@ 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
|
|
|
54
|
-
|
|
55
|
-
|
|
60
|
+
Pass an explicitly supplied model ID and effort unchanged, even if discovery
|
|
61
|
+
is incomplete or does not list them. To resolve a natural-language model name
|
|
62
|
+
or choose an option the caller left open, use native discovery:
|
|
56
63
|
|
|
57
64
|
```sh
|
|
58
65
|
delegate models --provider PROVIDER_ID --cwd ABSOLUTE_WORKSPACE --json
|
|
@@ -68,6 +75,10 @@ requested value merely because discovery did not list it, and do not infer
|
|
|
68
75
|
per-model effort support from the harness-wide list. If a selected model has
|
|
69
76
|
`efforts: null` or `efforts: []`, omit `--effort` unless the caller explicitly
|
|
70
77
|
requested it; do not invent model aliases or combine options by guessing.
|
|
78
|
+
If a natural-language name cannot be resolved to a single exact ID, ask one
|
|
79
|
+
focused question for that ID. Do not silently select a default or transform
|
|
80
|
+
spaces into hyphens to manufacture an ID. This ambiguity rule is guidance for
|
|
81
|
+
selecting a value, not a new admission restriction.
|
|
71
82
|
|
|
72
83
|
The response includes `schema_version`, `command: "models"`, `provider`,
|
|
73
84
|
`observed_at`, `status`, `reason_code`, `complete`, `source`, nullable
|
|
@@ -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
|
|
@@ -0,0 +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, 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."
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
#!/bin/sh
|
|
2
|
+
# Context delivery only: no installation, discovery, or provider execution.
|
|
3
|
+
set -eu
|
|
4
|
+
case "${1:-}" in
|
|
5
|
+
SessionStart|SubagentStart) event=$1 ;;
|
|
6
|
+
*) printf '%s\n' 'Expected SessionStart or SubagentStart.' >&2; exit 2 ;;
|
|
7
|
+
esac
|
|
8
|
+
script_dir=$(CDPATH= cd -- "$(dirname -- "$0")" && pwd)
|
|
9
|
+
rule_file="$script_dir/../references/routing-rule.json"
|
|
10
|
+
# Read before emitting anything so a missing asset cannot produce partial JSON.
|
|
11
|
+
rule=$(cat "$rule_file")
|
|
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
|
+
}'
|