pi-tuck 1.9.0 → 1.10.0
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/CHANGELOG.md +14 -0
- package/README.md +3 -3
- package/dist/src/build-id.d.ts +1 -1
- package/dist/src/build-id.js +1 -1
- package/dist/src/compaction.d.ts +4 -0
- package/dist/src/compaction.js +51 -3
- package/dist/src/diagnostics.d.ts +1 -1
- package/dist/src/run.d.ts +2 -0
- package/dist/src/run.js +2 -0
- package/package.json +1 -1
- package/src/build-id.ts +1 -1
- package/src/compaction.ts +39 -3
- package/src/run.ts +2 -0
package/CHANGELOG.md
CHANGED
|
@@ -3,6 +3,20 @@
|
|
|
3
3
|
All notable changes to pi-tuck. The format follows [Keep a Changelog](https://keepachangelog.com/en/1.1.0/), and versions follow
|
|
4
4
|
[Semantic Versioning](https://semver.org/).
|
|
5
5
|
|
|
6
|
+
## [1.10.0]
|
|
7
|
+
|
|
8
|
+
### Added
|
|
9
|
+
|
|
10
|
+
- Act-now turn: when a reply stops at its output limit while still thinking (no text, no tool call) and pi-tuck does not retry it, pi-tuck
|
|
11
|
+
queues one more user turn asking the model to act now, with the next tool call or the answer. The stopped reply stays saved but leaves
|
|
12
|
+
that request's context, and the request gets the raised reply room. At most two such turns go out in a row, and only when the request
|
|
13
|
+
fits; if the second also stops, the exhaustion notice shows as before. A reply that is not such a stop re-arms it. The act-now turn
|
|
14
|
+
does not re-arm the length retry.
|
|
15
|
+
|
|
16
|
+
### Changed
|
|
17
|
+
|
|
18
|
+
- README: `cacheSensitiveModels` also turns off the lean line (as in 1.9.0); a local server with a strong prompt cache belongs in it.
|
|
19
|
+
|
|
6
20
|
## [1.9.0]
|
|
7
21
|
|
|
8
22
|
### Changed
|
package/README.md
CHANGED
|
@@ -12,7 +12,7 @@ pi install npm:pi-tuck
|
|
|
12
12
|
|
|
13
13
|
Start a new Pi process after installing or updating. pi-tuck handles automatic compaction and `/compact` by default. Run `/tuck` to see the loaded version, cut history, and active cut policy.
|
|
14
14
|
|
|
15
|
-
This README describes pi-tuck 1.
|
|
15
|
+
This README describes pi-tuck 1.10.0. To pin a published release, use a versioned source such as `pi install npm:pi-tuck@1.10.0` or `pi install git:github.com/galyavin/pi-tuck@v1.10.0`. To uninstall, run `pi remove` with the source you installed.
|
|
16
16
|
|
|
17
17
|
## Compaction and recall
|
|
18
18
|
|
|
@@ -58,7 +58,7 @@ Once per Pi start, in the background, pi-tuck reads the server's own model list
|
|
|
58
58
|
Optional settings go in `pi-tuck.json` in Pi's agent directory (`~/.pi/agent` by default, or `PI_CODING_AGENT_DIR`). Restart Pi to apply changes. The input room starts at the model's context window minus Pi's `compaction.reserveTokens`. Invalid JSON uses defaults. An invalid field uses its own default, with a notice when compaction is active.
|
|
59
59
|
|
|
60
60
|
- **`cutAt`** is a fraction above 0 and at most 1. By default pi-tuck cuts at the room, less a 2% margin. An explicit value fixes a fraction of the room, subject to the same margin even at `1`.
|
|
61
|
-
- **`cacheSensitiveModels`** lists exact `provider/model` identifiers. For these models, the cut point is the full room, taking precedence over `cutAt`. This delays early cuts that would discard a reusable prompt prefix.
|
|
61
|
+
- **`cacheSensitiveModels`** lists exact `provider/model` identifiers. For these models, the cut point is the full room, taking precedence over `cutAt`. This delays early cuts that would discard a reusable prompt prefix. It also turns off the lean line for these models; list a local server with a strong prompt cache here, where cached input is nearly free and wall time is the cost.
|
|
62
62
|
- **`footer`** set to `false` keeps Pi's own footer.
|
|
63
63
|
- **`llamaContinuation`** opts one reasoning model into a single extra request after a thinking-only response exhausts the full configured output allowance. In Pi's `models.json`, configure that model on a llama.cpp provider using the `openai-completions` API. Verify that the runtime and template support `continue_final_message: "reasoning_content"` and report reused prompt tokens through `prompt_progress`. Pi-tuck requires the first cache report to match the prefix within 15 seconds. The positive integer `extraTokens` caps the additional allowance within the remaining context. The positive integer `deadlineMs` covers both requests.
|
|
64
64
|
|
|
@@ -75,7 +75,7 @@ Optional settings go in `pi-tuck.json` in Pi's agent directory (`~/.pi/agent` by
|
|
|
75
75
|
|
|
76
76
|
## Output exhaustion and small windows
|
|
77
77
|
|
|
78
|
-
- Pi-tuck preserves thinking-only stops in session history. At the model's full output allowance, it reports exhaustion if the reply remains unfinished. Below that allowance, it retries once, re-armed as Pi's overflow recovery is. After any length stop on the branch, pi-tuck trims so the next reply gets twice that stop's output (at most `maxTokens` and half the window). A stop at the full `maxTokens` while still thinking names the setting and `models.json`; a lower thinking level usually helps more than a bigger cap.
|
|
78
|
+
- Pi-tuck preserves thinking-only stops in session history. At the model's full output allowance, it reports exhaustion if the reply remains unfinished. Below that allowance, it retries once, re-armed as Pi's overflow recovery is. After any length stop on the branch, pi-tuck trims so the next reply gets twice that stop's output (at most `maxTokens` and half the window). When such a stop is not retried, pi-tuck queues one more user turn asking the model to act: "Your last reply used the whole output budget on thinking. Act now: make the next tool call or give the answer, with brief reasoning." The stopped reply stays saved but leaves that request's context. At most two such turns go out in a row, and only when the request fits; if the second also stops, the notice below stands. A stop at the full `maxTokens` while still thinking names the setting and `models.json`; a lower thinking level usually helps more than a bigger cap.
|
|
79
79
|
- Pi-tuck uses the context window declared in Pi's model configuration. A length stop alone does not establish a smaller window. If the server has a smaller effective limit, set that limit in Pi's model configuration.
|
|
80
80
|
- Pi's compaction reserve sets the cut target. For larger requests, pi-tuck estimates reply needs from observed output on the current branch for the active model, bounded by the reserve and model output limit. A cut above the room aims to leave 3,584 reply tokens within those bounds; where no cut can, the request goes out as before. If cuts cannot leave enough room for the protected prompt and a reply, try a shorter prompt, fewer tools, or a larger window. Pi-tuck's checks use estimates. Pi handles recognized provider overflows, and silent truncation can go undetected.
|
|
81
81
|
|
package/dist/src/build-id.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const BUILD_ID = "
|
|
1
|
+
export declare const BUILD_ID = "d6d248d0fe5344d96ce72d313dc9e120007dcff704b4e0a233bb506d927a3309";
|
package/dist/src/build-id.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export const BUILD_ID = "
|
|
1
|
+
export const BUILD_ID = "d6d248d0fe5344d96ce72d313dc9e120007dcff704b4e0a233bb506d927a3309";
|
package/dist/src/compaction.d.ts
CHANGED
|
@@ -10,6 +10,10 @@ export declare const overflowNotice: (contextWindow: number, bound: number, lear
|
|
|
10
10
|
/** Appended to the operator notices at the failure points pi-tuck detects (refusals, length stops), so a report can carry a record. */
|
|
11
11
|
/** The notice for a thinking-only reply that used the model's whole configured maxTokens. */
|
|
12
12
|
export declare const capStopNotice: (model: string, maxTokens: number, file: string) => string;
|
|
13
|
+
/** The follow-up turn sent after a reply that spent its whole output on thinking, with no text or tool call. */
|
|
14
|
+
export declare const ACT_NOW = "Your last reply used the whole output budget on thinking. Act now: make the next tool call or give the answer, with brief reasoning.";
|
|
15
|
+
/** At most this many act-now turns in a row; after that a stall gets the cap-stop notice until a reply is not a stall. */
|
|
16
|
+
export declare const ACT_NOW_LIMIT = 2;
|
|
13
17
|
export declare const INCIDENT_HINT = "\npi-tuck: something went wrong - run /tuck-incident next to record it for a bug report.";
|
|
14
18
|
/** The most a seed or an overflow raise may set the calibration factor to. A paired reply's own ratio is not bounded by it. */
|
|
15
19
|
export declare const CALIBRATION_CEILING = 1.5;
|
package/dist/src/compaction.js
CHANGED
|
@@ -67,6 +67,10 @@ export const overflowNotice = (contextWindow, bound, learned) => `pi-tuck: the p
|
|
|
67
67
|
export const capStopNotice = (model, maxTokens, file) => `pi-tuck: ${model} used its whole reply cap (maxTokens ${maxTokens.toLocaleString("en-US")}) while still thinking, before any answer or tool call. ` +
|
|
68
68
|
`The cap is maxTokens for this model in ${file}. A lower thinking level, or a task that writes to files as it goes, usually helps more than a bigger cap. ` +
|
|
69
69
|
"The unfinished response is saved in the session.";
|
|
70
|
+
/** The follow-up turn sent after a reply that spent its whole output on thinking, with no text or tool call. */
|
|
71
|
+
export const ACT_NOW = "Your last reply used the whole output budget on thinking. Act now: make the next tool call or give the answer, with brief reasoning.";
|
|
72
|
+
/** At most this many act-now turns in a row; after that a stall gets the cap-stop notice until a reply is not a stall. */
|
|
73
|
+
export const ACT_NOW_LIMIT = 2;
|
|
70
74
|
/** Pi's models.json, shown with ~ for the home folder. */
|
|
71
75
|
function modelsPath() {
|
|
72
76
|
try {
|
|
@@ -339,11 +343,16 @@ export async function installCompaction(pi, options = {}) {
|
|
|
339
343
|
if (ctx.model && `${ctx.model.provider}/${ctx.model.id}` !== options.continuationModel)
|
|
340
344
|
run?.rearmLengthRetry();
|
|
341
345
|
};
|
|
342
|
-
pi
|
|
346
|
+
// The act-now turn is pi-tuck's own, not the operator's: it grants no retry.
|
|
347
|
+
pi.on("message_start", (event, ctx) => { if (event.message.role === "user" && textOf(event.message.content) !== ACT_NOW)
|
|
343
348
|
rearmLengthRetry(ctx); });
|
|
349
|
+
// Act-now turns sent since the last reply that was not a stall.
|
|
350
|
+
let actNows = 0;
|
|
344
351
|
pi.on("message_end", (event, ctx) => {
|
|
345
352
|
if (event.message.role !== "assistant")
|
|
346
353
|
return;
|
|
354
|
+
if (event.message.stopReason !== "error" && event.message.stopReason !== "aborted" && !(event.message.content && thinkingOnlyLength(event.message)))
|
|
355
|
+
actNows = 0;
|
|
347
356
|
if (event.message.stopReason !== "error" && event.message.stopReason !== "length")
|
|
348
357
|
rearmLengthRetry(ctx);
|
|
349
358
|
lengthStop = event.message.stopReason === "length" ? {
|
|
@@ -1137,6 +1146,42 @@ export async function installCompaction(pi, options = {}) {
|
|
|
1137
1146
|
const saved = { ...cut, firstKeptEntryId: current.keptFromId };
|
|
1138
1147
|
return { entries: [...event.entries, saved, ...(more?.entries ?? [])] };
|
|
1139
1148
|
};
|
|
1149
|
+
// After a stall that is not retried: leave the stalled reply out of the context (it stays saved, with its output usage, so the next
|
|
1150
|
+
// request keeps the raised reply room) and queue one act-now turn, if that request fits as it stands. Otherwise the notice stands.
|
|
1151
|
+
const actNow = (event, ctx, result) => {
|
|
1152
|
+
if (actNows >= ACT_NOW_LIMIT || !ctx.model)
|
|
1153
|
+
return undefined;
|
|
1154
|
+
const edit = { type: "context_edit", targetId: event.messageEntryId, replacement: null };
|
|
1155
|
+
// The cap path returns before taking a pending cut: preview it in place, and take it only if the turn is queued.
|
|
1156
|
+
const untaken = !result || result.entries === event.entries;
|
|
1157
|
+
const base = result?.entries ?? event.entries;
|
|
1158
|
+
let entries = base.some(entry => entry.type === "context_edit" && entry.targetId === event.messageEntryId) ? [...base] : [...base, edit];
|
|
1159
|
+
const restore = untaken ? run?.cut.hold() : undefined;
|
|
1160
|
+
try {
|
|
1161
|
+
const preview = (untaken ? run?.cut ?? liveCut : liveCut).view(ctx, entries).session;
|
|
1162
|
+
const view = Object.create(ctx, { sessionManager: { value: preview } });
|
|
1163
|
+
const turn = { role: "user", content: [{ type: "text", text: ACT_NOW }], timestamp: 0 };
|
|
1164
|
+
const messages = projectedRequest(preview.buildSessionProjection().messages, view, hostMessages(ctx), [...event.context.pendingMessages, turn], ctx.getSystemPrompt(), pi.getActiveTools(), false);
|
|
1165
|
+
const tokens = requestSystemPart(ctx.getSystemPrompt(), pi.getActiveTools(), messages, ctx.getSystemPrompt()) + conversationTokens(messages);
|
|
1166
|
+
const { room, hardLine } = limits(view);
|
|
1167
|
+
if (!fits(tokens, hardLine, view) || !options.requestReserve && corrected(tokens, view) > room && piClamp && !requestClamp(messages, view).leavesFloor)
|
|
1168
|
+
return undefined;
|
|
1169
|
+
}
|
|
1170
|
+
finally {
|
|
1171
|
+
restore?.();
|
|
1172
|
+
}
|
|
1173
|
+
try {
|
|
1174
|
+
pi.sendUserMessage(ACT_NOW, { deliverAs: "followUp" });
|
|
1175
|
+
}
|
|
1176
|
+
catch {
|
|
1177
|
+
return undefined;
|
|
1178
|
+
}
|
|
1179
|
+
if (untaken)
|
|
1180
|
+
entries = [...(atBoundary(event, ctx, "run-end", false)?.entries ?? event.entries), edit];
|
|
1181
|
+
actNows++;
|
|
1182
|
+
markBoundary(entries);
|
|
1183
|
+
return { entries, continue: false };
|
|
1184
|
+
};
|
|
1140
1185
|
const retryLength = (event, ctx) => {
|
|
1141
1186
|
// Exhausting the full per-request allowance is not evidence that input is too large.
|
|
1142
1187
|
// Preserve the unfinished response; provider-native continuation owns this case.
|
|
@@ -1215,8 +1260,11 @@ export async function installCompaction(pi, options = {}) {
|
|
|
1215
1260
|
return;
|
|
1216
1261
|
if (!active() || run?.phase !== "admitted")
|
|
1217
1262
|
return;
|
|
1218
|
-
if (thinkingOnlyLength(event.message) && !ctx.signal?.aborted && settingsFor().getCompactionSettings(ctx.model).enabled)
|
|
1219
|
-
|
|
1263
|
+
if (thinkingOnlyLength(event.message) && !ctx.signal?.aborted && settingsFor().getCompactionSettings(ctx.model).enabled) {
|
|
1264
|
+
// A stall that is not retried gets one follow-up turn asking the model to act; its reply replaces the cap-stop notice.
|
|
1265
|
+
const result = retryLength(event, ctx);
|
|
1266
|
+
return result?.continue ? result : actNow(event, ctx, result) ?? result;
|
|
1267
|
+
}
|
|
1220
1268
|
run.finishLengthRetry();
|
|
1221
1269
|
const decide = event.outcome === "completed" && !ctx.signal?.aborted && event.context.canContinue && event.toolResults.length > 0 &&
|
|
1222
1270
|
settingsFor().getCompactionSettings(ctx.model).enabled;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { type RecallPolicy } from './recall.js';
|
|
2
2
|
import type { SessionEntry } from '@earendil-works/pi-coding-agent';
|
|
3
|
-
export declare const DIAGNOSTIC_BUILD = "
|
|
3
|
+
export declare const DIAGNOSTIC_BUILD = "d6d248d0fe5344d96ce72d313dc9e120007dcff704b4e0a233bb506d927a3309";
|
|
4
4
|
export interface Receipt {
|
|
5
5
|
id: string;
|
|
6
6
|
build: string;
|
package/dist/src/run.d.ts
CHANGED
|
@@ -20,6 +20,8 @@ export declare class PendingCut {
|
|
|
20
20
|
private preview?;
|
|
21
21
|
plan(cut: CutEntry, ctx: Context): void;
|
|
22
22
|
clear(): void;
|
|
23
|
+
/** Puts the plan back after a check that read a preview session (a read from another session clears it). */
|
|
24
|
+
hold(): () => void;
|
|
23
25
|
take(ctx: Context): CutEntry | undefined;
|
|
24
26
|
view(ctx: Context, entries?: readonly SessionBoundaryDraft[]): CutView;
|
|
25
27
|
}
|
package/dist/src/run.js
CHANGED
|
@@ -14,6 +14,8 @@ export class PendingCut {
|
|
|
14
14
|
this.preview = undefined;
|
|
15
15
|
}
|
|
16
16
|
clear() { this.proposal = undefined; this.preview = undefined; }
|
|
17
|
+
/** Puts the plan back after a check that read a preview session (a read from another session clears it). */
|
|
18
|
+
hold() { const proposal = this.proposal; return () => { this.proposal = proposal; this.preview = undefined; }; }
|
|
17
19
|
take(ctx) {
|
|
18
20
|
if (!this.view(ctx).pending)
|
|
19
21
|
return;
|
package/package.json
CHANGED
package/src/build-id.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export const BUILD_ID = "
|
|
1
|
+
export const BUILD_ID = "d6d248d0fe5344d96ce72d313dc9e120007dcff704b4e0a233bb506d927a3309";
|
package/src/compaction.ts
CHANGED
|
@@ -71,6 +71,10 @@ export const capStopNotice = (model: string, maxTokens: number, file: string) =>
|
|
|
71
71
|
`pi-tuck: ${model} used its whole reply cap (maxTokens ${maxTokens.toLocaleString("en-US")}) while still thinking, before any answer or tool call. ` +
|
|
72
72
|
`The cap is maxTokens for this model in ${file}. A lower thinking level, or a task that writes to files as it goes, usually helps more than a bigger cap. ` +
|
|
73
73
|
"The unfinished response is saved in the session.";
|
|
74
|
+
/** The follow-up turn sent after a reply that spent its whole output on thinking, with no text or tool call. */
|
|
75
|
+
export const ACT_NOW = "Your last reply used the whole output budget on thinking. Act now: make the next tool call or give the answer, with brief reasoning.";
|
|
76
|
+
/** At most this many act-now turns in a row; after that a stall gets the cap-stop notice until a reply is not a stall. */
|
|
77
|
+
export const ACT_NOW_LIMIT = 2;
|
|
74
78
|
/** Pi's models.json, shown with ~ for the home folder. */
|
|
75
79
|
function modelsPath(): string {
|
|
76
80
|
try {
|
|
@@ -319,9 +323,13 @@ export async function installCompaction(pi: ExtensionAPI, options: CompactionOpt
|
|
|
319
323
|
const rearmLengthRetry = (ctx: ExtensionContext) => {
|
|
320
324
|
if (ctx.model && `${ctx.model.provider}/${ctx.model.id}` !== options.continuationModel) run?.rearmLengthRetry();
|
|
321
325
|
};
|
|
322
|
-
pi
|
|
326
|
+
// The act-now turn is pi-tuck's own, not the operator's: it grants no retry.
|
|
327
|
+
pi.on("message_start", (event, ctx) => { if (event.message.role === "user" && textOf(event.message.content) !== ACT_NOW) rearmLengthRetry(ctx); });
|
|
328
|
+
// Act-now turns sent since the last reply that was not a stall.
|
|
329
|
+
let actNows = 0;
|
|
323
330
|
pi.on("message_end", (event, ctx) => {
|
|
324
331
|
if (event.message.role !== "assistant") return;
|
|
332
|
+
if (event.message.stopReason !== "error" && event.message.stopReason !== "aborted" && !(event.message.content && thinkingOnlyLength(event.message))) actNows = 0;
|
|
325
333
|
if (event.message.stopReason !== "error" && event.message.stopReason !== "length") rearmLengthRetry(ctx);
|
|
326
334
|
lengthStop = event.message.stopReason === "length" ? {
|
|
327
335
|
kind: event.message.content && thinkingOnlyLength(event.message) ? "thinking" : "output",
|
|
@@ -1015,6 +1023,31 @@ export async function installCompaction(pi: ExtensionAPI, options: CompactionOpt
|
|
|
1015
1023
|
const saved = { ...cut, firstKeptEntryId: current.keptFromId! };
|
|
1016
1024
|
return { entries: [...event.entries as CutEntry[], saved, ...(more?.entries ?? [])] };
|
|
1017
1025
|
};
|
|
1026
|
+
// After a stall that is not retried: leave the stalled reply out of the context (it stays saved, with its output usage, so the next
|
|
1027
|
+
// request keeps the raised reply room) and queue one act-now turn, if that request fits as it stands. Otherwise the notice stands.
|
|
1028
|
+
const actNow = (event: TurnEndEvent, ctx: ExtensionContext, result: { entries: readonly SessionBoundaryDraft[] } | undefined) => {
|
|
1029
|
+
if (actNows >= ACT_NOW_LIMIT || !ctx.model) return undefined;
|
|
1030
|
+
const edit: SessionBoundaryDraft = { type: "context_edit", targetId: event.messageEntryId, replacement: null };
|
|
1031
|
+
// The cap path returns before taking a pending cut: preview it in place, and take it only if the turn is queued.
|
|
1032
|
+
const untaken = !result || result.entries === event.entries;
|
|
1033
|
+
const base = result?.entries ?? event.entries;
|
|
1034
|
+
let entries: SessionBoundaryDraft[] = base.some(entry => entry.type === "context_edit" && entry.targetId === event.messageEntryId) ? [...base] : [...base, edit];
|
|
1035
|
+
const restore = untaken ? run?.cut.hold() : undefined;
|
|
1036
|
+
try {
|
|
1037
|
+
const preview = (untaken ? run?.cut ?? liveCut : liveCut).view(ctx, entries).session;
|
|
1038
|
+
const view: ExtensionContext = Object.create(ctx, { sessionManager: { value: preview } });
|
|
1039
|
+
const turn = { role: "user" as const, content: [{ type: "text" as const, text: ACT_NOW }], timestamp: 0 };
|
|
1040
|
+
const messages = projectedRequest(preview.buildSessionProjection().messages, view, hostMessages(ctx), [...event.context.pendingMessages, turn], ctx.getSystemPrompt(), pi.getActiveTools(), false);
|
|
1041
|
+
const tokens = requestSystemPart(ctx.getSystemPrompt(), pi.getActiveTools(), messages, ctx.getSystemPrompt()) + conversationTokens(messages);
|
|
1042
|
+
const { room, hardLine } = limits(view);
|
|
1043
|
+
if (!fits(tokens, hardLine, view) || !options.requestReserve && corrected(tokens, view) > room && piClamp && !requestClamp(messages, view).leavesFloor) return undefined;
|
|
1044
|
+
} finally { restore?.(); }
|
|
1045
|
+
try { pi.sendUserMessage(ACT_NOW, { deliverAs: "followUp" }); } catch { return undefined; }
|
|
1046
|
+
if (untaken) entries = [...(atBoundary(event, ctx, "run-end", false)?.entries ?? event.entries), edit];
|
|
1047
|
+
actNows++;
|
|
1048
|
+
markBoundary(entries);
|
|
1049
|
+
return { entries, continue: false };
|
|
1050
|
+
};
|
|
1018
1051
|
const retryLength = (event: TurnEndEvent, ctx: ExtensionContext) => {
|
|
1019
1052
|
// Exhausting the full per-request allowance is not evidence that input is too large.
|
|
1020
1053
|
// Preserve the unfinished response; provider-native continuation owns this case.
|
|
@@ -1084,8 +1117,11 @@ export async function installCompaction(pi: ExtensionAPI, options: CompactionOpt
|
|
|
1084
1117
|
try {
|
|
1085
1118
|
if (standDown(ctx)) return;
|
|
1086
1119
|
if (!active() || run?.phase !== "admitted") return;
|
|
1087
|
-
if (thinkingOnlyLength(event.message) && !ctx.signal?.aborted && settingsFor().getCompactionSettings(ctx.model).enabled)
|
|
1088
|
-
|
|
1120
|
+
if (thinkingOnlyLength(event.message) && !ctx.signal?.aborted && settingsFor().getCompactionSettings(ctx.model).enabled) {
|
|
1121
|
+
// A stall that is not retried gets one follow-up turn asking the model to act; its reply replaces the cap-stop notice.
|
|
1122
|
+
const result = retryLength(event, ctx);
|
|
1123
|
+
return result?.continue ? result : actNow(event, ctx, result) ?? result;
|
|
1124
|
+
}
|
|
1089
1125
|
run.finishLengthRetry();
|
|
1090
1126
|
const decide = event.outcome === "completed" && !ctx.signal?.aborted && event.context.canContinue && event.toolResults.length > 0 &&
|
|
1091
1127
|
settingsFor().getCompactionSettings(ctx.model).enabled;
|
package/src/run.ts
CHANGED
|
@@ -20,6 +20,8 @@ export class PendingCut {
|
|
|
20
20
|
this.preview = undefined;
|
|
21
21
|
}
|
|
22
22
|
clear() { this.proposal = undefined; this.preview = undefined; }
|
|
23
|
+
/** Puts the plan back after a check that read a preview session (a read from another session clears it). */
|
|
24
|
+
hold() { const proposal = this.proposal; return () => { this.proposal = proposal; this.preview = undefined; }; }
|
|
23
25
|
take(ctx: Context) {
|
|
24
26
|
if (!this.view(ctx).pending) return;
|
|
25
27
|
const cut = this.proposal?.cut;
|