@moxxy/mode-goal 0.27.0 → 0.28.1

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/goal-loop.js CHANGED
@@ -1,41 +1,39 @@
1
- import { buildSystemPromptWithSkills, collectProviderStream, createStuckLoopDetector, emitRequestsAndDetectStuck, executeToolUses, isContextOverflowError, nextBackoffMs, projectMessages, runCompactionIfNeeded, runElisionIfNeeded, sleepWithAbort, usageEventFields, } from '@moxxy/sdk';
1
+ import { runReactLoop, } from '@moxxy/sdk';
2
2
  import { detectGoalTerminal } from './completion.js';
3
- import { CONTINUE_NUDGE, GOAL_ABANDON_TOOL, GOAL_COMPLETE_TOOL, GOAL_MAX_ITERATIONS, GOAL_MAX_NOOP_ITERATIONS, GOAL_MODE_NAME, GOAL_PLUGIN_ID, GOAL_SYSTEM_PROMPT, GOAL_TOKEN_BUDGET, MAX_CONSECUTIVE_RETRIES, STALL_NUDGE, } from './constants.js';
4
- /** Exponential back-off base/cap for the retry schedule (attempt is 1-based). */
5
- const RETRY_BACKOFF_BASE_MS = 500;
6
- const RETRY_BACKOFF_CAP_MS = 30_000;
7
- // Abort-aware sleep, injectable for tests so the back-off path runs instantly
8
- // and deterministically. Production delegates to the SDK's sleepWithAbort: a
9
- // real timer that clears (and drops its abort listener) when the signal fires,
10
- // so a pending back-off never outlives a cancelled goal run.
11
- let sleepImpl = (ms, signal) => sleepWithAbort(ms, signal);
12
- /**
13
- * Override the retry back-off sleep (test seam). Returns a restore fn that
14
- * callers MUST invoke (in a `finally`) — `sleepImpl` is a module-scoped
15
- * singleton shared process-wide, so a leaked override bleeds the fake sleep
16
- * into every other turn/test running in the same worker. Test-only.
17
- */
18
- export function __setRetrySleepForTests(fn) {
19
- const prev = sleepImpl;
20
- sleepImpl = fn;
21
- return () => {
22
- sleepImpl = prev;
23
- };
24
- }
3
+ import { CONTINUE_NUDGE, GOAL_ABANDON_TOOL, GOAL_COMPLETE_TOOL, GOAL_MAX_NOOP_ITERATIONS, GOAL_MODE_NAME, GOAL_PLUGIN_ID, GOAL_SYSTEM_PROMPT, STALL_NUDGE, STUCK_NUDGE_SUFFIX, } from './constants.js';
4
+ // The retry back-off (and its test seam) lives in the SDK's shared ReAct
5
+ // core now — re-export so existing importers/tests keep working.
6
+ export { __setRetrySleepForTests } from '@moxxy/sdk';
25
7
  /**
26
8
  * Goal mode driver.
27
9
  *
28
- * Unlike tool-use (which returns the instant the model stops emitting tools),
29
- * goal mode treats "stopped emitting tools" as a cue to re-prompt: it keeps
30
- * the model working autonomously across iterations until the model explicitly
31
- * calls `goal_complete` (success) or `goal_abandon` (blocked). Every iteration
32
- * is guarded so the loop always terminates:
10
+ * Unlike the default mode (which returns the instant the model stops emitting
11
+ * tools), goal mode treats "stopped emitting tools" as a cue to re-prompt: it
12
+ * keeps the model working autonomously across iterations until the model
13
+ * explicitly calls `goal_complete` (success) or `goal_abandon` (blocked).
33
14
  *
34
- * - hard iteration cap (`maxIterations`)
35
- * - cumulative token budget
36
- * - stuck-loop detector (same identical-call detection as tool-use)
37
- * - no-progress detection (repeated idle iterations stall stop)
38
- * - `ctx.signal.aborted` checked every iteration and mid tool batch
15
+ * Goal mode is deliberately GUARDRAIL-FREE: the user asked for an outcome and
16
+ * opted into full autonomy, so nothing heuristic may kill the run mid-delivery.
17
+ * There is no iteration cap (unless the embedder set an explicit
18
+ * `ctx.maxIterations`), no token budget, and a stuck-loop trip steers the model
19
+ * instead of aborting. The ONLY ways a run ends:
20
+ *
21
+ * - the model calls `goal_complete` (verified success) or `goal_abandon`
22
+ * (blocked, needs the user),
23
+ * - the model goes idle {@link GOAL_MAX_NOOP_ITERATIONS} rounds in a row
24
+ * despite nudges — it has decided it's done without saying so, so the run
25
+ * ends cleanly as a soft completion,
26
+ * - the user aborts (Esc / stop), or
27
+ * - a genuinely fatal condition (un-compactable context overflow, provider
28
+ * giving up after bounded retries).
29
+ *
30
+ * Goal mode is also ONE-SHOT (`transient: true` on the ModeDef): it arms for a
31
+ * single objective. When the run concludes as DONE — `goal_complete` or the
32
+ * idle soft-completion — the session hands back to the mode that was active
33
+ * before goal mode (via `ctx.requestModeSwitch`), so the user's next message is
34
+ * normal chat again. While the goal is UNFINISHED — `goal_abandon` (the model
35
+ * needs an answer to continue), a fatal error, or a user abort — the mode stays
36
+ * armed so the user's reply resumes the autonomous run.
39
37
  *
40
38
  * Tool calls are auto-approved for the whole run (the user opted into full
41
39
  * autonomy) by swapping in a resolver that replaces only the PROMPT path:
@@ -60,10 +58,9 @@ export async function* runGoalMode(ctx) {
60
58
  // Auto-approve for the duration of the run — the user chose to let goal
61
59
  // mode run unattended, so nothing may ever block on an interactive prompt.
62
60
  // But ONLY the prompt is skipped: the session resolver's prompt-free
63
- // `policyCheck` (deny/allow rules from ~/.moxxy/permissions.json, then the
64
- // tool's own declared rule) is consulted first, so a user deny rule still
65
- // denies in goal mode. Anything the policy doesn't decide is allowed.
66
- // Scoped to goalCtx so it never leaks past this loop.
61
+ // `policyCheck` is consulted first, so a user deny rule still denies in
62
+ // goal mode. Anything the policy doesn't decide is allowed. Scoped to
63
+ // goalCtx so it never leaks past this loop.
67
64
  const sessionResolver = ctx.permissions;
68
65
  const autoApprove = {
69
66
  name: 'goal-auto-approve',
@@ -79,6 +76,16 @@ export async function* runGoalMode(ctx) {
79
76
  systemPrompt: composeSystemPrompts(ctx.systemPrompt, GOAL_SYSTEM_PROMPT),
80
77
  permissions: autoApprove,
81
78
  };
79
+ // Hand the session back to whatever the user was in before arming goal mode
80
+ // — applied by the runner AFTER the turn drains, and only on clean
81
+ // completion. Called on the DONE terminals only (complete / idle
82
+ // soft-completion): an unfinished goal (abandon / fatal / abort) keeps the
83
+ // mode armed so the user's reply resumes the run.
84
+ const disarm = () => {
85
+ const previous = ctx.previousModeName;
86
+ const target = previous && previous !== GOAL_MODE_NAME ? previous : 'default';
87
+ ctx.requestModeSwitch?.(target);
88
+ };
82
89
  yield await ctx.emit({
83
90
  type: 'plugin_event',
84
91
  sessionId: ctx.sessionId,
@@ -86,238 +93,70 @@ export async function* runGoalMode(ctx) {
86
93
  source: 'plugin',
87
94
  pluginId: GOAL_PLUGIN_ID,
88
95
  subtype: 'goal_started',
89
- payload: { autoApprove: true, maxIterations: ctx.maxIterations ?? GOAL_MAX_ITERATIONS },
96
+ payload: { autoApprove: true, maxIterations: ctx.maxIterations ?? null },
90
97
  });
91
- const detector = createStuckLoopDetector(ctx.loopGuard);
92
- // Coerce a caller/config-supplied bound to a positive integer. A degenerate
93
- // value (0, negative, NaN, fractional) would otherwise make the for-loop
94
- // never run and fall straight to the "iteration cap reached" fatal work was
95
- // never done, yet the message blames the model. The config schema validates
96
- // this as a positive int, but programmatic callers (subagents/workflows)
97
- // bypass that schema. Un-coercible (NaN) falls back to the default.
98
- const requestedMaxIterations = ctx.maxIterations;
99
- const maxIterations = typeof requestedMaxIterations === 'number' && Number.isFinite(requestedMaxIterations)
100
- ? Math.max(1, Math.floor(requestedMaxIterations))
101
- : GOAL_MAX_ITERATIONS;
102
- let noop = 0; // consecutive idle (no-tool) iterations
103
- let totalTokens = 0;
104
- let reactiveCompactions = 0;
105
- const MAX_REACTIVE_COMPACTIONS = 2;
106
- // Consecutive retryable-error count; reset on any clean provider call. Caps
107
- // the busy-loop a sustained retryable condition (429 / overloaded / transient
108
- // 5xx / ECONNRESET) would otherwise create — goal mode runs unattended with
109
- // auto-approval, so a tight retry loop hammers the provider with nobody
110
- // watching. The token budget can't backstop this: a request that errors
111
- // before message_end reports no usage, so totalTokens never advances.
112
- let consecutiveRetries = 0;
113
- for (let iteration = 1; iteration <= maxIterations; iteration++) {
114
- if (ctx.signal.aborted) {
115
- yield await ctx.emit({
116
- type: 'abort',
117
- sessionId: ctx.sessionId,
118
- turnId: ctx.turnId,
119
- source: 'system',
120
- reason: 'signal aborted',
121
- });
122
- return;
123
- }
124
- yield await ctx.emit({
125
- type: 'mode_iteration',
126
- sessionId: ctx.sessionId,
127
- turnId: ctx.turnId,
128
- source: 'system',
129
- strategy: GOAL_MODE_NAME,
130
- iteration,
131
- });
132
- await runCompactionIfNeeded(goalCtx);
133
- await runElisionIfNeeded(goalCtx);
134
- // Nudge only when the model went idle last iteration (no tool calls and no
135
- // completion). After a productive iteration the tool results carry the
136
- // model forward on their own — no nudge needed.
137
- const nudge = noop === 0 ? undefined : noop >= GOAL_MAX_NOOP_ITERATIONS - 1 ? STALL_NUDGE : CONTINUE_NUDGE;
138
- const baseSystem = buildSystemPromptWithSkills(goalCtx.systemPrompt, goalCtx.skills.list()) ?? '';
139
- const { messages, stablePrefixIndex } = projectMessages(goalCtx, {
140
- ...(baseSystem ? { systemPrompt: baseSystem } : {}),
141
- ...(nudge ? { trailingUserText: nudge } : {}),
142
- });
143
- yield await ctx.emit({
144
- type: 'provider_request',
145
- sessionId: ctx.sessionId,
146
- turnId: ctx.turnId,
147
- source: 'system',
148
- provider: goalCtx.provider.name,
149
- model: goalCtx.model,
150
- });
151
- const { text, toolUses, stopReason, error, usage, reasoning } = await collectProviderStream(goalCtx, messages, {
152
- iteration,
153
- stablePrefixIndex,
154
- // The nudge is volatile — injected for this call only, never appended
155
- // to the log — so the cache strategy must keep its rolling tail
156
- // breakpoint BEFORE it. Otherwise every idle iteration caches a
157
- // prefix ending in a message that won't exist at that position next
158
- // call: a guaranteed-wasted cache write.
159
- ...(nudge ? { volatileTailCount: 1 } : {}),
160
- });
161
- yield await ctx.emit({
162
- type: 'provider_response',
163
- sessionId: ctx.sessionId,
164
- turnId: ctx.turnId,
165
- source: 'system',
166
- provider: goalCtx.provider.name,
167
- model: goalCtx.model,
168
- ...usageEventFields(usage),
169
- });
170
- // Tally the FULL prompt of each call. Anthropic reports the cached portion
171
- // separately (`inputTokens` is only the non-cached prefix), so on a long
172
- // goal run — where the rolling cache breakpoint serves most of the prompt
173
- // as cacheRead — counting input+output alone undercounts by a large factor
174
- // and the runaway-budget backstop could be exceeded many times over before
175
- // it trips. Include both cache fields so the budget reflects real usage.
176
- if (usage)
177
- totalTokens +=
178
- (usage.inputTokens ?? 0) +
179
- (usage.cacheReadTokens ?? 0) +
180
- (usage.cacheCreationTokens ?? 0) +
181
- (usage.outputTokens ?? 0);
182
- if (error) {
183
- const overflow = isContextOverflowError(error.message);
184
- if (overflow && reactiveCompactions < MAX_REACTIVE_COMPACTIONS) {
185
- const compacted = await runCompactionIfNeeded(goalCtx, { force: true });
186
- if (compacted) {
187
- // Only count an attempt that actually compacted — a no-op (overflow
188
- // lives in the un-compactable recent tail) must not deny a later,
189
- // genuinely compactable overflow its retry.
190
- reactiveCompactions += 1;
191
- yield await ctx.emit({
192
- type: 'error',
193
- sessionId: ctx.sessionId,
194
- turnId: ctx.turnId,
195
- source: 'system',
196
- kind: 'retryable',
197
- message: 'context window exceeded — compacted older turns, retrying',
198
- });
199
- continue;
200
- }
201
- }
202
- // A context overflow that can't be compacted further is fatal regardless
203
- // of the provider's `retryable` flag: some providers mark "reduce the
204
- // length" errors retryable, but the prompt cannot shrink, so a retry just
205
- // re-sends the identical over-budget request and overflows again — a tight
206
- // loop bounded only by maxIterations (the request errors before usage is
207
- // reported, so the token budget never advances to stop it).
208
- const fatal = !error.retryable || overflow;
209
- if (fatal) {
210
- yield await ctx.emit({
211
- type: 'error',
212
- sessionId: ctx.sessionId,
213
- turnId: ctx.turnId,
214
- source: 'system',
215
- kind: 'fatal',
216
- message: `goal: ${error.message}`,
217
- });
218
- return;
219
- }
220
- // Retryable: surface it, then back off before retrying. A persistent
221
- // retryable condition (sustained 429 / outage) must NOT busy-loop the
222
- // provider — give up with a fatal error after the bounded retry count.
223
- // The counter resets on any clean provider call, so a long run can still
224
- // recover from transient blips.
225
- consecutiveRetries += 1;
226
- yield await ctx.emit({
227
- type: 'error',
228
- sessionId: ctx.sessionId,
229
- turnId: ctx.turnId,
230
- source: 'system',
231
- kind: 'retryable',
232
- message: `goal: ${error.message}`,
233
- });
234
- if (consecutiveRetries >= MAX_CONSECUTIVE_RETRIES) {
235
- yield await ctx.emit({
236
- type: 'error',
237
- sessionId: ctx.sessionId,
238
- turnId: ctx.turnId,
239
- source: 'system',
240
- kind: 'fatal',
241
- message: `goal: provider kept returning a retryable error ${consecutiveRetries} times in a row ` +
242
- `(last: ${error.message}); giving up rather than hammering the provider.`,
243
- });
244
- return;
245
- }
246
- await sleepImpl(nextBackoffMs(consecutiveRetries, RETRY_BACKOFF_BASE_MS, RETRY_BACKOFF_CAP_MS), ctx.signal);
247
- if (ctx.signal.aborted) {
248
- yield await ctx.emit({
249
- type: 'abort',
98
+ // The model idled without calling goal_complete: nudge it back to work with
99
+ // a volatile trailing prompt (this call only never appended to the log).
100
+ // After GOAL_MAX_NOOP_ITERATIONS consecutive idle rounds the model has
101
+ // clearly decided it's done without declaring it end the run cleanly as a
102
+ // soft completion (and disarm) rather than spin forever.
103
+ const idleNudge = {
104
+ name: 'goal-idle',
105
+ gateOn: 'idle',
106
+ run: async (check) => {
107
+ if (check.consecutiveIdle >= GOAL_MAX_NOOP_ITERATIONS) {
108
+ await goalCtx.emit({
109
+ type: 'plugin_event',
250
110
  sessionId: ctx.sessionId,
251
111
  turnId: ctx.turnId,
252
- source: 'system',
253
- reason: 'signal aborted during retry back-off',
112
+ source: 'plugin',
113
+ pluginId: GOAL_PLUGIN_ID,
114
+ subtype: 'goal_stalled',
115
+ payload: { idleIterations: check.consecutiveIdle, iteration: check.iteration },
254
116
  });
255
- return;
256
- }
257
- continue;
258
- }
259
- // Clean provider call — reset the overflow-recovery + retry budgets.
260
- reactiveCompactions = 0;
261
- consecutiveRetries = 0;
262
- // Finalize the reasoning summary for THIS call before any exit decision or
263
- // tool/assistant emit, so the log order is reasoning → tool_use → text
264
- // (projection attaches the signed thinking block as content[0] of the same
265
- // turn). Emitting it ahead of the budget backstop keeps every exit path
266
- // consistent — the budget-exhausting call's reasoning is logged just like
267
- // any other call's, rather than being silently dropped at this exit.
268
- if (reasoning) {
269
- yield await ctx.emit({
270
- type: 'reasoning_message',
271
- sessionId: ctx.sessionId,
272
- turnId: ctx.turnId,
273
- source: 'model',
274
- content: reasoning.text,
275
- ...(reasoning.signature ? { signature: reasoning.signature } : {}),
276
- ...(reasoning.redacted ? { redacted: true } : {}),
277
- ...(reasoning.encrypted ? { encrypted: reasoning.encrypted } : {}),
278
- });
279
- }
280
- // Token budget backstop (alongside the iteration cap).
281
- if (totalTokens > GOAL_TOKEN_BUDGET) {
282
- // Persist the budget-exhausting call's assistant text before exiting,
283
- // just like every productive iteration does (the assistant emit below
284
- // this block is skipped by the `return`). Otherwise the model's last
285
- // words vanish from the log, so a resume ("continue from here") loses
286
- // that context. We do NOT execute its tool calls — the run is stopping.
287
- if (text || stopReason === 'end_turn' || toolUses.length === 0) {
288
- yield await ctx.emit({
117
+ await goalCtx.emit({
289
118
  type: 'assistant_message',
290
119
  sessionId: ctx.sessionId,
291
120
  turnId: ctx.turnId,
292
- source: 'model',
293
- content: text,
294
- stopReason,
121
+ source: 'system',
122
+ content: 'Goal run ended: the model stopped working without calling `goal_complete` — ' +
123
+ 'it likely considers the goal done. Review the work above; if something is ' +
124
+ 'missing, describe it in your next message.',
125
+ stopReason: 'end_turn',
295
126
  });
127
+ disarm();
128
+ return { action: 'stop' };
296
129
  }
297
- yield await ctx.emit({
298
- type: 'plugin_event',
299
- sessionId: ctx.sessionId,
300
- turnId: ctx.turnId,
301
- source: 'plugin',
302
- pluginId: GOAL_PLUGIN_ID,
303
- subtype: 'goal_budget_exhausted',
304
- payload: { totalTokens, budget: GOAL_TOKEN_BUDGET, iteration },
305
- });
306
- yield await ctx.emit({
307
- type: 'assistant_message',
308
- sessionId: ctx.sessionId,
309
- turnId: ctx.turnId,
310
- source: 'system',
311
- content: `Goal mode stopped: token budget exhausted (${totalTokens.toLocaleString()} > ` +
312
- `${GOAL_TOKEN_BUDGET.toLocaleString()}) before the goal was completed. ` +
313
- `Send another message to continue from here.`,
314
- stopReason: 'end_turn',
315
- });
316
- return;
317
- }
318
- const stuck = yield* emitRequestsAndDetectStuck(ctx, toolUses, detector, {
319
- abortedResultMessage: 'goal mode aborted (stuck pattern) before this call ran',
130
+ return {
131
+ action: 'inject',
132
+ volatile: true,
133
+ text: check.consecutiveIdle >= GOAL_MAX_NOOP_ITERATIONS - 1 ? STALL_NUDGE : CONTINUE_NUDGE,
134
+ };
135
+ },
136
+ };
137
+ yield* runReactLoop(goalCtx, {
138
+ strategyName: GOAL_MODE_NAME,
139
+ // No iteration cap: a goal run ends via its terminals, never because a
140
+ // counter ran out mid-delivery. An explicit ctx.maxIterations (set by a
141
+ // programmatic embedder) still takes precedence inside runReactLoop.
142
+ defaultMaxIterations: Number.POSITIVE_INFINITY,
143
+ errorPrefix: 'goal: ',
144
+ checkpoints: [idleNudge],
145
+ // The idle checkpoint stops itself at GOAL_MAX_NOOP_ITERATIONS consecutive
146
+ // idles, before this backstop can trip — it exists so a future checkpoint
147
+ // bug degrades loudly instead of looping. (The core resets the budget
148
+ // whenever the model does tool work, so spread-out idle rounds across a
149
+ // long run never exhaust it.)
150
+ maxInjections: GOAL_MAX_NOOP_ITERATIONS,
151
+ stuck: {
152
+ // Never abort an unattended run on a repetition heuristic — the repeats
153
+ // are often legitimate (re-running a failing build between edits).
154
+ // Steer instead: visible warning + a volatile nudge on the next call.
155
+ action: 'nudge',
320
156
  nearHint: 'against the same target (only volatile args varied)',
157
+ nudgeText: ({ toolName, count, how }) => `You have called the tool \`${toolName}\` ${count} times ${how}. Repeating the same ` +
158
+ `call will not produce a different result. Step back, reassess, and take a DIFFERENT ` +
159
+ `next action toward the goal. ${STUCK_NUDGE_SUFFIX}`,
321
160
  extraOnStuck: ({ toolName, count, kind }) => [
322
161
  {
323
162
  type: 'plugin_event',
@@ -329,121 +168,95 @@ export async function* runGoalMode(ctx) {
329
168
  payload: { tool: toolName, count, kind },
330
169
  },
331
170
  ],
332
- fatalMessage: ({ toolName, count, how }) => `goal mode aborted — stuck pattern: tool "${toolName}" called ${count} times ${how}. ` +
333
- `The model is looping on the same call; send another message to redirect it.`,
334
- });
335
- if (stuck)
336
- return;
337
- if (text || stopReason === 'end_turn' || toolUses.length === 0) {
338
- yield await ctx.emit({
339
- type: 'assistant_message',
340
- sessionId: ctx.sessionId,
341
- turnId: ctx.turnId,
342
- source: 'model',
343
- content: text,
344
- stopReason,
345
- });
346
- }
347
- if (toolUses.length === 0) {
348
- // The model idled without calling goal_complete. Count it; nudge next
349
- // iteration. After enough idle rounds, stop rather than spin forever.
350
- noop += 1;
351
- if (noop >= GOAL_MAX_NOOP_ITERATIONS) {
352
- yield await ctx.emit({
171
+ },
172
+ onToolBatchEnd: async (loopCtx, { toolUses, iteration }) => {
173
+ // Did this batch end the run? (goal_complete / goal_abandon, confirmed
174
+ // via a successful tool_result in the log.) Only materialise the log
175
+ // (an O(n) copy of the ever-growing append-only log) when the batch
176
+ // actually used a goal tool otherwise this ran on every productive
177
+ // iteration, O(n²) per run.
178
+ const hasGoalTool = toolUses.some((t) => t.name === GOAL_COMPLETE_TOOL || t.name === GOAL_ABANDON_TOOL);
179
+ const terminal = hasGoalTool ? detectGoalTerminal(loopCtx.log.slice(), toolUses) : null;
180
+ if (terminal?.kind === 'complete') {
181
+ await loopCtx.emit({
353
182
  type: 'plugin_event',
354
183
  sessionId: ctx.sessionId,
355
184
  turnId: ctx.turnId,
356
185
  source: 'plugin',
357
186
  pluginId: GOAL_PLUGIN_ID,
358
- subtype: 'goal_stalled',
359
- payload: { idleIterations: noop, iteration },
187
+ subtype: 'goal_completed',
188
+ payload: {
189
+ summary: terminal.summary,
190
+ evidenceCount: terminal.evidence.length,
191
+ iterations: iteration,
192
+ },
360
193
  });
361
- yield await ctx.emit({
194
+ const evidenceBlock = terminal.evidence.length > 0
195
+ ? `\n\n${terminal.evidence.map((e) => `- ${e}`).join('\n')}`
196
+ : '';
197
+ await loopCtx.emit({
362
198
  type: 'assistant_message',
363
199
  sessionId: ctx.sessionId,
364
200
  turnId: ctx.turnId,
365
201
  source: 'system',
366
- content: 'Goal mode stopped: the model went idle without calling `goal_complete`. ' +
367
- 'It may believe the goal is done — review the work above, and send another message to continue if not.',
202
+ content: `✓ Goal complete ${terminal.summary}${evidenceBlock}`,
368
203
  stopReason: 'end_turn',
369
204
  });
370
- return;
205
+ disarm();
206
+ return { action: 'stop' };
371
207
  }
372
- continue;
373
- }
374
- noop = 0;
375
- const exited = yield* executeToolUses(goalCtx, toolUses, iteration);
376
- if (exited)
377
- return;
378
- // Did this batch end the run? (goal_complete / goal_abandon, confirmed via
379
- // a successful tool_result in the log.) Only materialise the log (an O(n)
380
- // copy of the ever-growing append-only log) when the batch actually used a
381
- // goal tool — otherwise this ran on every productive iteration, O(n²) per
382
- // run. detectGoalTerminal itself early-returns null on an empty batch, so a
383
- // batch with no goal tools needs no log at all.
384
- const hasGoalTool = toolUses.some((t) => t.name === GOAL_COMPLETE_TOOL || t.name === GOAL_ABANDON_TOOL);
385
- const terminal = hasGoalTool ? detectGoalTerminal(ctx.log.slice(), toolUses) : null;
386
- if (terminal?.kind === 'complete') {
387
- yield await ctx.emit({
388
- type: 'plugin_event',
389
- sessionId: ctx.sessionId,
390
- turnId: ctx.turnId,
391
- source: 'plugin',
392
- pluginId: GOAL_PLUGIN_ID,
393
- subtype: 'goal_completed',
394
- payload: { summary: terminal.summary, evidenceCount: terminal.evidence.length, iterations: iteration },
395
- });
396
- const evidenceBlock = terminal.evidence.length > 0 ? `\n\n${terminal.evidence.map((e) => `- ${e}`).join('\n')}` : '';
397
- yield await ctx.emit({
398
- type: 'assistant_message',
399
- sessionId: ctx.sessionId,
400
- turnId: ctx.turnId,
401
- source: 'system',
402
- content: `✓ Goal complete ${terminal.summary}${evidenceBlock}`,
403
- stopReason: 'end_turn',
404
- });
405
- return;
406
- }
407
- if (terminal?.kind === 'abandon') {
408
- yield await ctx.emit({
208
+ if (terminal?.kind === 'abandon') {
209
+ await loopCtx.emit({
210
+ type: 'plugin_event',
211
+ sessionId: ctx.sessionId,
212
+ turnId: ctx.turnId,
213
+ source: 'plugin',
214
+ pluginId: GOAL_PLUGIN_ID,
215
+ subtype: 'goal_abandoned',
216
+ payload: {
217
+ reason: terminal.reason,
218
+ ...(terminal.needsFromUser ? { needsFromUser: terminal.needsFromUser } : {}),
219
+ iterations: iteration,
220
+ },
221
+ });
222
+ const needs = terminal.needsFromUser ? `\n\nNeeds from you: ${terminal.needsFromUser}` : '';
223
+ await loopCtx.emit({
224
+ type: 'assistant_message',
225
+ sessionId: ctx.sessionId,
226
+ turnId: ctx.turnId,
227
+ source: 'system',
228
+ content: `Goal abandoned — ${terminal.reason}${needs}\n\n` +
229
+ `Goal mode stays armed: your reply resumes the autonomous run.`,
230
+ stopReason: 'end_turn',
231
+ });
232
+ // Deliberately NOT disarming: the model needs something from the user
233
+ // and their reply should resume the autonomous run.
234
+ return { action: 'stop' };
235
+ }
236
+ return undefined;
237
+ },
238
+ onMaxIterations: async (loopCtx, maxIterations) => {
239
+ // Only reachable when an embedder set an explicit ctx.maxIterations —
240
+ // goal mode itself is uncapped.
241
+ await loopCtx.emit({
409
242
  type: 'plugin_event',
410
243
  sessionId: ctx.sessionId,
411
244
  turnId: ctx.turnId,
412
245
  source: 'plugin',
413
246
  pluginId: GOAL_PLUGIN_ID,
414
- subtype: 'goal_abandoned',
415
- payload: { reason: terminal.reason, ...(terminal.needsFromUser ? { needsFromUser: terminal.needsFromUser } : {}), iterations: iteration },
247
+ subtype: 'goal_max_iterations',
248
+ payload: { maxIterations },
416
249
  });
417
- const needs = terminal.needsFromUser ? `\n\nNeeds from you: ${terminal.needsFromUser}` : '';
418
- yield await ctx.emit({
419
- type: 'assistant_message',
250
+ await loopCtx.emit({
251
+ type: 'error',
420
252
  sessionId: ctx.sessionId,
421
253
  turnId: ctx.turnId,
422
254
  source: 'system',
423
- content: `Goal abandoned — ${terminal.reason}${needs}`,
424
- stopReason: 'end_turn',
255
+ kind: 'fatal',
256
+ message: `goal mode reached the configured iteration cap (${maxIterations}) without calling ` +
257
+ `goal_complete. Send another message to continue.`,
425
258
  });
426
- return;
427
- }
428
- }
429
- // Iteration cap hit without the model declaring done.
430
- yield await ctx.emit({
431
- type: 'plugin_event',
432
- sessionId: ctx.sessionId,
433
- turnId: ctx.turnId,
434
- source: 'plugin',
435
- pluginId: GOAL_PLUGIN_ID,
436
- subtype: 'goal_max_iterations',
437
- payload: { maxIterations },
438
- });
439
- yield await ctx.emit({
440
- type: 'error',
441
- sessionId: ctx.sessionId,
442
- turnId: ctx.turnId,
443
- source: 'system',
444
- kind: 'fatal',
445
- message: `goal mode reached the iteration cap (${maxIterations}) without calling goal_complete. ` +
446
- `Stopping to avoid an unbounded run; send another message to continue.`,
259
+ },
447
260
  });
448
261
  }
449
262
  function composeSystemPrompts(user, layer) {
@@ -1 +1 @@
1
- {"version":3,"file":"goal-loop.js","sourceRoot":"","sources":["../src/goal-loop.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,2BAA2B,EAC3B,qBAAqB,EACrB,uBAAuB,EACvB,0BAA0B,EAC1B,eAAe,EACf,sBAAsB,EACtB,aAAa,EACb,eAAe,EACf,qBAAqB,EACrB,kBAAkB,EAClB,cAAc,EACd,gBAAgB,GAIjB,MAAM,YAAY,CAAC;AAEpB,OAAO,EAAE,kBAAkB,EAAE,MAAM,iBAAiB,CAAC;AACrD,OAAO,EACL,cAAc,EACd,iBAAiB,EACjB,kBAAkB,EAClB,mBAAmB,EACnB,wBAAwB,EACxB,cAAc,EACd,cAAc,EACd,kBAAkB,EAClB,iBAAiB,EACjB,uBAAuB,EACvB,WAAW,GACZ,MAAM,gBAAgB,CAAC;AAExB,iFAAiF;AACjF,MAAM,qBAAqB,GAAG,GAAG,CAAC;AAClC,MAAM,oBAAoB,GAAG,MAAM,CAAC;AAEpC,8EAA8E;AAC9E,6EAA6E;AAC7E,+EAA+E;AAC/E,6DAA6D;AAC7D,IAAI,SAAS,GAAG,CAAC,EAAU,EAAE,MAAmB,EAAiB,EAAE,CAAC,cAAc,CAAC,EAAE,EAAE,MAAM,CAAC,CAAC;AAE/F;;;;;GAKG;AACH,MAAM,UAAU,uBAAuB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