@0perator/operator 0.1.325 → 0.1.326
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/dist/cli.js +3 -1
- package/dist/config/persona.js +3 -1
- package/dist/engine/agent.js +2 -2
- package/dist/engine/loop-guard.js +14 -9
- package/dist/session.js +2 -1
- package/package.json +1 -1
package/dist/cli.js
CHANGED
|
@@ -667,7 +667,9 @@ function Root() {
|
|
|
667
667
|
return `spawned background sub-agent ${id}. Its result auto-posts to THIS conversation when done — ` +
|
|
668
668
|
`keep working, do not poll it. Do NOT call bash_output/bash_kill on ${id} (that's for shell_background ` +
|
|
669
669
|
`jobs only and will just error). Use agent_status to check on it, or message_agent to nudge it. ` +
|
|
670
|
-
`Never re-spawn ${id}'s task assuming it was lost — it wasn't
|
|
670
|
+
`Never re-spawn ${id}'s task assuming it was lost — it wasn't. When nothing else is independent of ${id}, ` +
|
|
671
|
+
`give a one-line status and END YOUR TURN — its report resumes this conversation; a turn that keeps ` +
|
|
672
|
+
`polling holds the model slot and starves it.`;
|
|
671
673
|
},
|
|
672
674
|
// The reverse channel: message a RUNNING sub-agent mid-flight (steer it / answer its question).
|
|
673
675
|
messageAgent: (id, text) => {
|
package/dist/config/persona.js
CHANGED
|
@@ -402,7 +402,9 @@ export function basePersona(cwd = process.cwd(), opts = {}) {
|
|
|
402
402
|
`"let me delegate" without making that call in the same round. For independent, parallelizable subtasks ` +
|
|
403
403
|
`(research per area, search a large tree, draft a file, a long build) give each a fully self-contained ` +
|
|
404
404
|
`instruction — it runs on another ` +
|
|
405
|
-
`session in parallel and posts its result back here
|
|
405
|
+
`session in parallel and posts its result back here. Do only the work that does NOT depend on it, then give ` +
|
|
406
|
+
`a one-line status and END YOUR TURN — the result resumes the conversation; a turn that keeps polling holds ` +
|
|
407
|
+
`the model slot and starves the sub-agents. The user watches each ` +
|
|
406
408
|
`sub-agent's live tokens + time in the background panel. Don't delegate trivial work you can do inline, ` +
|
|
407
409
|
`and don't spawn many at once — they all share this one model.\n` +
|
|
408
410
|
`WRITE THE BRIEF LIKE A SPEC, not a run-on paragraph — the child has NO memory of this chat, so a wall ` +
|
package/dist/engine/agent.js
CHANGED
|
@@ -1160,7 +1160,7 @@ export async function runTurn(userInput, conversation, opts) {
|
|
|
1160
1160
|
// turn — pollers are exempt from the loop guard above, so this catches them. Nudge once, then end the
|
|
1161
1161
|
// turn so the auto-posted sub-agent results resume it (rather than burning the budget re-checking).
|
|
1162
1162
|
if (pollSpin) {
|
|
1163
|
-
const ps = pollSpin.observe(response.toolCalls.map((c) => c.function.name), toolMsgs.map((m) => m.content ?? ""));
|
|
1163
|
+
const ps = pollSpin.observe(response.toolCalls.map((c) => c.function.name), toolMsgs.map((m) => m.content ?? ""), response.toolCalls.some((c) => MUTATING_TOOLS.has(c.function?.name ?? "")));
|
|
1164
1164
|
if (ps.action === "halt")
|
|
1165
1165
|
return stopTurn(ps.message, rounds + 1);
|
|
1166
1166
|
if (ps.action === "nudge") {
|
|
@@ -1208,7 +1208,7 @@ export async function runTurn(userInput, conversation, opts) {
|
|
|
1208
1208
|
noEditStreak = recovered.calls.some((c) => MUTATING_TOOLS.has(c.function?.name ?? "")) ? 0 : noEditStreak + 1;
|
|
1209
1209
|
trackTouchedFiles(recovered.calls, touchedFiles);
|
|
1210
1210
|
if (pollSpin) {
|
|
1211
|
-
const ps = pollSpin.observe(recovered.calls.map((c) => c.function.name), toolMsgs.map((m) => m.content ?? ""));
|
|
1211
|
+
const ps = pollSpin.observe(recovered.calls.map((c) => c.function.name), toolMsgs.map((m) => m.content ?? ""), recovered.calls.some((c) => MUTATING_TOOLS.has(c.function?.name ?? "")));
|
|
1212
1212
|
if (ps.action === "halt")
|
|
1213
1213
|
return stopTurn(ps.message, rounds + 1);
|
|
1214
1214
|
if (ps.action === "nudge") {
|
|
@@ -351,9 +351,10 @@ export class LoopGuard {
|
|
|
351
351
|
export const AUTOPOST_POLLERS = new Set(["agent_status"]);
|
|
352
352
|
export const POLL_SPIN_DEFAULTS = { nudgeAfter: 2, stopAfter: 3 };
|
|
353
353
|
export const POLL_SPIN_NUDGE = "Sub-agent results auto-post to this conversation the moment they finish — you do not need to poll " +
|
|
354
|
-
"agent_status to learn that.
|
|
355
|
-
"
|
|
356
|
-
|
|
354
|
+
"agent_status to learn that. Reads and status checks while they run are not progress: finish only what does " +
|
|
355
|
+
"NOT depend on them, give a one-line status, and END YOUR TURN — the results resume this conversation on their " +
|
|
356
|
+
"own, and a turn that keeps polling holds the model slot and starves the sub-agents.";
|
|
357
|
+
export const POLL_SPIN_STOP = "[stopped — waiting on sub-agents: agent_status was polled repeatedly with no mutating work and no change in status. Sub-agent results " +
|
|
357
358
|
"auto-post when they finish and will resume this turn, so polling only burns time and tokens. Nothing was " +
|
|
358
359
|
"lost — the results arrive on their own.]";
|
|
359
360
|
/** Watches settled tool rounds for an auto-post-poller spin. Fed one round at a time via observe(); a
|
|
@@ -370,18 +371,22 @@ export class PollSpinGuard {
|
|
|
370
371
|
this.stopAfter = stopAfter;
|
|
371
372
|
}
|
|
372
373
|
reset() { this.streak = 0; this.nudged = false; this.lastHash = ""; }
|
|
373
|
-
/** One settled round: the tools it ran (names)
|
|
374
|
-
|
|
374
|
+
/** One settled round: the tools it ran (names), their results (index-aligned), and whether any call in the round
|
|
375
|
+
* CHANGED the workspace. Read-only work beside a poll is not progress — a parent that alternates agent_status
|
|
376
|
+
* with greps, reads and status bash while its sub-agents run is still waiting on them (the 2026-10-28 32-minute
|
|
377
|
+
* turn), and should end the turn so the auto-posted results resume it and the sub-agents get the model slot. */
|
|
378
|
+
observe(names, results, mutating = false) {
|
|
375
379
|
const pollers = names.filter((n) => AUTOPOST_POLLERS.has(n));
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
if (pollers.length === 0 || hasOther) {
|
|
380
|
+
// No auto-post poller, or a MUTATING call alongside it ⇒ progress, never a spin.
|
|
381
|
+
if (pollers.length === 0 || mutating) {
|
|
379
382
|
this.reset();
|
|
380
383
|
return { action: "allow", streak: 0 };
|
|
381
384
|
}
|
|
382
385
|
// A pure poll round. A changed poll result means a sub-agent's state moved (one finished / was added) —
|
|
383
386
|
// that IS new information, so the streak resets.
|
|
384
|
-
|
|
387
|
+
// Only the POLLERS' results count as "the status": a read-only tool's output changes every round (a
|
|
388
|
+
// different grep, a longer log) and must not look like a sub-agent moving.
|
|
389
|
+
const h = hash(pollers.join("\0") + "\u0001" + results.filter((_, i) => AUTOPOST_POLLERS.has(names[i])).join("\0"));
|
|
385
390
|
if (this.streak > 0 && h !== this.lastHash) {
|
|
386
391
|
this.reset();
|
|
387
392
|
this.lastHash = h;
|
package/dist/session.js
CHANGED
|
@@ -84,7 +84,8 @@ function makeSpawnTool(handler) {
|
|
|
84
84
|
"\"I'll spawn sub-agents\" without calling spawn_agent. Keep working meanwhile: NEVER sleep, poll or wait for a " +
|
|
85
85
|
"result (agent_status checks state, message_agent steers, stop_agent halts; a sub-agent id is NOT a shell job id — " +
|
|
86
86
|
"bash_output/bash_kill will just error). NEVER re-spawn a task because its result hasn't arrived — it is still " +
|
|
87
|
-
"working
|
|
87
|
+
"working. Then finish only what does NOT depend on them, give a one-line status and END YOUR TURN — reports " +
|
|
88
|
+
"re-enter as new messages; a turn that keeps polling holds the model slot and starves the sub-agents.\n" +
|
|
88
89
|
"USE FOR: reasoning-heavy subtasks, work that would flood your context, or independent parallel workstreams " +
|
|
89
90
|
"(research per area, review per module, search per tree, drafting a file).\n" +
|
|
90
91
|
"DO NOT USE FOR: a single tool call; mechanical steps with no reasoning; anything that needs the user (sub-agents " +
|