@polygraph/opencode-plugin 0.5.2 → 0.5.4
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.
|
@@ -55,10 +55,8 @@ Child agent <id> is done.
|
|
|
55
55
|
**Repo:** <repoFullName>
|
|
56
56
|
**Delegation id:** <id>
|
|
57
57
|
**Status:** <status>
|
|
58
|
-
|
|
59
|
-
Read the result with show_agent (id: "<id>").
|
|
60
58
|
```
|
|
61
59
|
|
|
62
60
|
For `input-required` or `permission-required`, replace "is done." with "needs attention." and keep everything else identical.
|
|
63
61
|
|
|
64
|
-
Do not summarize, quote, or describe the child's work. Do not include log lines. The main agent reads the result itself via `show_agent
|
|
62
|
+
Do not summarize, quote, or describe the child's work. Do not include log lines. The main agent reads the result itself via `show_agent`, and chooses how to read it. Never tell it which call to make.
|
package/package.json
CHANGED
|
@@ -309,6 +309,7 @@ If the session has a description timeline, also display:
|
|
|
309
309
|
|
|
310
310
|
1. **Read each result once** — when a poller exits, read that child with a single unwaited `show_agent(sessionId, id)`; `result.text` is the child's final message. Only reach for an explicit `tail` if that is not enough.
|
|
311
311
|
1. **State the output in every brief** — children are told to be concise, so the instruction must say what to return: the shape, a cap where one makes sense, and the exact token for "nothing to report". See [`reference/delegation.md`](reference/delegation.md).
|
|
312
|
+
1. **Batch the spawn and the read** — send several repos in one spawn call and collect their results in one read. Identical work rides a single instruction; differing work goes in a spec file with an entry per repo, sharing only what is genuinely shared. See [`reference/delegation.md`](reference/delegation.md).
|
|
312
313
|
1. **Poll child status before proceeding** — Always verify child agents have reached a terminal `child.status` (`'completed'`, `'failed'`, or `'cancelled'`) before pushing branches or creating PRs
|
|
313
314
|
1. **Link PRs in descriptions** - Reference related PRs in each PR body
|
|
314
315
|
1. **Keep PRs as drafts** until all repos are ready
|
|
@@ -30,7 +30,29 @@ spawn_agent(
|
|
|
30
30
|
|
|
31
31
|
Write the instruction as if to a competent engineer who cannot see your conversation: state the goal, the constraints, what "done" looks like, and what to report back. The child has its own repo and its own context; it inherits nothing from yours.
|
|
32
32
|
|
|
33
|
-
Delegate to several repos in parallel
|
|
33
|
+
Delegate to several repos in parallel before waiting on any of them, and prefer one call over N. There are three shapes, the same three `polygraph agent spawn` takes:
|
|
34
|
+
|
|
35
|
+
- **One repo** — `repo` with an `instruction`.
|
|
36
|
+
- **Several repos, one task** — `repos` with one `instruction`, run verbatim in each.
|
|
37
|
+
- **Several repos, different tasks** — `specFile`, a JSON file you write, whose path you pass.
|
|
38
|
+
|
|
39
|
+
Batching pays because the shared text is transmitted once rather than once per repo, and every sibling starts from a byte-identical prompt prefix that can be served from cache. Each id still gets its own poller.
|
|
40
|
+
|
|
41
|
+
The spec file is the many-to-many form. Each entry names a repo and carries its own `instruction`, and optionally its own `context`, `role`, `agent`, and `model`. Whatever the entries share goes in `sharedInstruction` / `sharedContext`, which are prepended to each entry's own text with a blank line between — so the common brief stays one identical prefix and only the per-repo part varies. An entry may carry no `instruction` of its own and rely entirely on the shared one. Being a file, it also carries a brief too large to pass as an argument, and it is straightforward to generate programmatically.
|
|
42
|
+
|
|
43
|
+
```jsonc
|
|
44
|
+
{
|
|
45
|
+
"sharedInstruction": "Brief every child gets, verbatim.",
|
|
46
|
+
"sharedContext": "Optional background every child gets.",
|
|
47
|
+
"agents": [
|
|
48
|
+
{ "repo": "api", "instruction": "Add the expand parameter to the endpoint." },
|
|
49
|
+
{ "repo": "people", "instruction": "Consume it in the client.", "context": "This repo still pins the old SDK." },
|
|
50
|
+
{ "repo": "planets", "role": "reviewer", "agent": "codex", "instruction": "Review the change against the shared brief." }
|
|
51
|
+
]
|
|
52
|
+
}
|
|
53
|
+
```
|
|
54
|
+
|
|
55
|
+
One qualifier is load-bearing: share only what is genuinely shared. Flattening several different tasks into one `sharedInstruction` to look efficient produces worse work, and the round trips to repair it cost more than the batch saved. Work that differs belongs in each entry's own `instruction`, which is what the file is for.
|
|
34
56
|
|
|
35
57
|
**Own-repo rule.** With the default role, `repo` must be a repository other than the one you are working in — never delegate into your own repo with the default role; work on it directly (ordinary local subagents are fine for that). Delegating into your own repo IS allowed with an explicit non-default `role`, because each (repo, role) pair is a separate agent slot and the child then runs alongside your own default-role work without colliding with it.
|
|
36
58
|
|
|
@@ -75,6 +97,8 @@ show_agent(sessionId: "<sessionId>", id: "<id>")
|
|
|
75
97
|
|
|
76
98
|
One-off unwaited reads like this are cheap and expected inline. It is the *waiting* that belongs in a subagent, not the reading.
|
|
77
99
|
|
|
100
|
+
When several pollers have exited, a **batch read** collects their results in one unwaited call: pass the list of ids and correlate each result by its delegation id. Batch when you spawned children together and have nothing to do until they all finish. Read one at a time when you act on each result as it lands, or only one child is in flight.
|
|
101
|
+
|
|
78
102
|
## When the result is not enough
|
|
79
103
|
|
|
80
104
|
Only if `result.text` is missing, truncated, or the child failed in a way you cannot explain from it:
|