Skip to content

Commit b9aa9b1

Browse files
Merge pull request #1398 from corbitsdev/cl-10511-compactor-dead-code
refactor(session): drop dead compactor config, branch, and aliases
2 parents ebf0f8f + a88fb05 commit b9aa9b1

4 files changed

Lines changed: 5 additions & 35 deletions

File tree

‎src/context-compactor.test.ts‎

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -191,7 +191,6 @@ describe("createPruningCompactor — initiating task preservation", () => {
191191

192192
test("keeps alternating roles when a tool_result user turn abuts a plain user turn", async () => {
193193
const compactor = smallCompactor({
194-
maxAnchorTurns: 3,
195194
summaryMaxChars: 500,
196195
});
197196
const turns: ConversationTurn[] = [
@@ -255,7 +254,6 @@ describe("createPruningCompactor — image aging", () => {
255254

256255
test("strips image bytes from an anchored (aged) turn but keeps its text", async () => {
257256
const compactor = smallCompactor({
258-
maxAnchorTurns: 1,
259257
summaryMaxChars: 500,
260258
});
261259
const turns: ConversationTurn[] = [
@@ -421,7 +419,6 @@ describe("createPruningCompactor — error anchoring (CL-6906)", () => {
421419
...padding(8, "after"),
422420
];
423421
const compactor = smallCompactor({
424-
maxAnchorTurns: 8,
425422
summaryMaxChars: 2000,
426423
});
427424
const { output } = await compactor.apply(turns, mockStrategyCtx);
@@ -467,7 +464,6 @@ describe("createPruningCompactor — error anchoring (CL-6906)", () => {
467464
...padding(8, "after"),
468465
];
469466
const compactor = smallCompactor({
470-
maxAnchorTurns: 8,
471467
summaryMaxChars: 2000,
472468
});
473469
const { output, blobs } = await compactor.apply(turns, mockStrategyCtx);
@@ -527,7 +523,6 @@ describe("createPruningCompactor — error anchoring (CL-6906)", () => {
527523
...padding(8, "after"),
528524
];
529525
const compactor = smallCompactor({
530-
maxAnchorTurns: 8,
531526
summaryMaxChars: 2000,
532527
});
533528
const { output, record } = await compactor.apply(turns, mockStrategyCtx);
@@ -654,7 +649,6 @@ describe("createPruningCompactor — consolidated handoff (CL-7521)", () => {
654649

655650
test("second apply keeps the initiating task in the handoff, not as a live user turn", async () => {
656651
const compactor = smallCompactor({
657-
maxAnchorTurns: 1,
658652
summaryMaxChars: 500,
659653
});
660654
const goal = "GOAL: migrate the auth module to opaque tokens";
@@ -759,7 +753,6 @@ describe("createPruningCompactor — consolidated handoff (CL-7521)", () => {
759753
test("empty-fold keep-set returns the input unchanged", async () => {
760754
const compactor = smallCompactor({
761755
tailBudgetTokens: 500,
762-
maxAnchorTurns: 8,
763756
summaryMaxChars: 500,
764757
});
765758
const turns: ConversationTurn[] = [

‎src/session/compaction-archive.test.ts‎

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -806,7 +806,6 @@ describe("wrapCompactorWithCompletenessGate", () => {
806806
payload: "working",
807807
});
808808
const inner = createPruningCompactor({
809-
maxAnchorTurns: 0,
810809
summaryMaxChars: 500,
811810
// Pin a tiny tail budget so the fold covers the same older region the
812811
// old keepRecentTurns cut folded.

‎src/session/compactor-pairing.test.ts‎

Lines changed: 1 addition & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,6 @@ describe("pruning compactor preserves tool_call/tool_result pairing", () => {
6161
// Pin a tiny tail budget so the fold covers the older region the old
6262
// keepRecentTurns cut.
6363
compactionShape: { tailBudgetTokens: 120 },
64-
maxAnchorTurns: 2,
6564
});
6665
const { output } = await compactor.apply(turns, {} as never);
6766
expect(() => assertWellFormedToolSequence(output)).not.toThrow();
@@ -84,7 +83,6 @@ describe("pruning compactor preserves tool_call/tool_result pairing", () => {
8483
// Pin a tiny tail budget so the fold covers the older region the old
8584
// keepRecentTurns cut.
8685
compactionShape: { tailBudgetTokens: 120 },
87-
maxAnchorTurns: 2,
8886
});
8987
const { output } = await compactor.apply(turns, {} as never);
9088
expect(() => assertWellFormedToolSequence(output)).not.toThrow();
@@ -129,7 +127,6 @@ describe("pruning compactor preserves tool_call/tool_result pairing", () => {
129127
// Pin a tiny tail budget so the fold covers the older region the old
130128
// keepRecentTurns cut.
131129
compactionShape: { tailBudgetTokens: 120 },
132-
maxAnchorTurns: 2,
133130
});
134131
const { output } = await compactor.apply(turns, {} as never);
135132
const kept = output.find((t) =>
@@ -182,7 +179,6 @@ describe("pruning compactor preserves tool_call/tool_result pairing", () => {
182179
// Pin a tiny tail budget so the fold covers the older region the old
183180
// keepRecentTurns cut.
184181
compactionShape: { tailBudgetTokens: 120 },
185-
maxAnchorTurns: 2,
186182
});
187183
const { output } = await compactor.apply(turns, {} as never);
188184
const kept = output.find((t) =>
@@ -208,7 +204,7 @@ describe("pruning compactor preserves tool_call/tool_result pairing", () => {
208204
],
209205
timestamp: 1,
210206
};
211-
const summary = buildTurnSummary([big], 2000, 0);
207+
const summary = buildTurnSummary([big], 2000);
212208
const tokens = Number(summary.match(/Estimated tokens: ~(\d+)/)?.[1] ?? -1);
213209
// A 100KB text result is ~25000 tokens; the old String(content) bug yielded ~4.
214210
expect(tokens).toBeGreaterThan(20000);
@@ -285,7 +281,6 @@ describe("pruning compactor stubs superseded file reads (CL-4374)", () => {
285281
const compactor = createPruningCompactor({
286282
// Whole transcript is the tail so stubbing still runs with no summarized region.
287283
compactionShape: TAIL_SWALLOWS_TRANSCRIPT,
288-
maxAnchorTurns: 2,
289284
});
290285
const { output } = await compactor.apply(turns, {} as never);
291286

@@ -317,7 +312,6 @@ describe("pruning compactor stubs superseded file reads (CL-4374)", () => {
317312
];
318313
const compactor = createPruningCompactor({
319314
compactionShape: TAIL_SWALLOWS_TRANSCRIPT,
320-
maxAnchorTurns: 2,
321315
});
322316
const { output } = await compactor.apply(turns, {} as never);
323317

@@ -345,7 +339,6 @@ describe("pruning compactor stubs superseded file reads (CL-4374)", () => {
345339
// Newest pair + end fit the token budget; the older pair is summarized.
346340
const compactor = createPruningCompactor({
347341
compactionShape: { tailBudgetTokens: 80 },
348-
maxAnchorTurns: 0,
349342
});
350343
const { output } = await compactor.apply(turns, {} as never);
351344
expect(resultText(output, "old")).toBeUndefined();
@@ -391,7 +384,6 @@ describe("pruning compactor stubs superseded file reads (CL-4374)", () => {
391384
];
392385
const compactor = createPruningCompactor({
393386
compactionShape: TAIL_SWALLOWS_TRANSCRIPT,
394-
maxAnchorTurns: 2,
395387
});
396388
const { output } = await compactor.apply(turns, {} as never);
397389
expect(resultText(output, "r1")).toBe(body1);
@@ -438,7 +430,6 @@ describe("pruning compactor stubs superseded file reads (CL-4374)", () => {
438430
];
439431
const compactor = createPruningCompactor({
440432
compactionShape: TAIL_SWALLOWS_TRANSCRIPT,
441-
maxAnchorTurns: 2,
442433
});
443434
const { output } = await compactor.apply(turns, {} as never);
444435
const older = resultText(output, "r1");
@@ -504,7 +495,6 @@ describe("pruning compactor extends superseded-result stubbing to query tools (C
504495
];
505496
const compactor = createPruningCompactor({
506497
compactionShape: TAIL_SWALLOWS_TRANSCRIPT,
507-
maxAnchorTurns: 2,
508498
});
509499
const { output } = await compactor.apply(turns, {} as never);
510500
const older = resultText(output, "q1");
@@ -531,7 +521,6 @@ describe("pruning compactor extends superseded-result stubbing to query tools (C
531521
];
532522
const compactor = createPruningCompactor({
533523
compactionShape: TAIL_SWALLOWS_TRANSCRIPT,
534-
maxAnchorTurns: 2,
535524
});
536525
const { output } = await compactor.apply(turns, {} as never);
537526
expect(resultText(output, "g1")).toBe(body1);
@@ -558,7 +547,6 @@ describe("pruning compactor extends superseded-result stubbing to query tools (C
558547
];
559548
const compactor = createPruningCompactor({
560549
compactionShape: TAIL_SWALLOWS_TRANSCRIPT,
561-
maxAnchorTurns: 2,
562550
});
563551
const { output } = await compactor.apply(turns, {} as never);
564552
expect(resultText(output, "sh1")).toBe(oldBody);
@@ -591,7 +579,6 @@ describe("CL-9489 budgeted tail does not ingest gap turns", () => {
591579
turns[turns.length - 1] = fatResult;
592580

593581
const { output, record } = await createPruningCompactor({
594-
maxAnchorTurns: 0,
595582
compactionShape: { tailBudgetTokens: 400 },
596583
}).apply(turns, {} as never);
597584

‎src/session/compactor.ts‎

Lines changed: 4 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -49,8 +49,6 @@ export interface CompactorConfig {
4949
/** Previous fat handoff body: the next fold unions its files/commands and
5050
* full goal text rather than spine cuts. */
5151
readPriorHandoff?: () => Promise<string | undefined>;
52-
// Kept for compatibility; the live fold keeps spine + token-capped tail.
53-
maxAnchorTurns: number;
5452
/** Budgeted-tail shape (token budget, not turn-count floor). Missing
5553
* fields resolve against DEFAULT_TAIL_COMPACTION_SHAPE. */
5654
compactionShape?: Partial<CompactionShape>;
@@ -103,7 +101,6 @@ export const HARNESS_COMPACT_SPACER_MODEL = "harness";
103101

104102
const DEFAULT_COMPACTOR_CONFIG: CompactorConfig = {
105103
summaryMaxChars: 2000,
106-
maxAnchorTurns: 8,
107104
};
108105

109106
function extraInstructionParameter(
@@ -393,7 +390,7 @@ function buildPartnerIndex(
393390
}
394391

395392
function isFoldableHandoffTurn(turn: ConversationTurn): boolean {
396-
return isCompactedSummaryTurn(turn) || isCompactSpacerTurn(turn);
393+
return isCompactedSummaryTurn(turn) || isHarnessCompactSpacer(turn);
397394
}
398395

399396
function resultContentSize(
@@ -528,8 +525,8 @@ function coalesceAdjacentTextTurns(
528525
isPlainTextTurn(turn) &&
529526
!isCompactedSummaryTurn(prev) &&
530527
!isCompactedSummaryTurn(turn) &&
531-
!isCompactSpacerTurn(prev) &&
532-
!isCompactSpacerTurn(turn)
528+
!isHarnessCompactSpacer(prev) &&
529+
!isHarnessCompactSpacer(turn)
533530
) {
534531
out[out.length - 1] = {
535532
...prev,
@@ -604,10 +601,6 @@ export function isHarnessCompactSpacer(turn: ConversationTurn): boolean {
604601
return turn.model === undefined && text === LEGACY_COMPACT_SPACER_TEXT;
605602
}
606603

607-
function isCompactSpacerTurn(turn: ConversationTurn): boolean {
608-
return isHarnessCompactSpacer(turn);
609-
}
610-
611604
function compactSpacerTurn(timestamp: number): ConversationTurn {
612605
return {
613606
role: "assistant",
@@ -1131,7 +1124,6 @@ export function createPruningCompactor(
11311124
version: this.version,
11321125
parameters: {
11331126
summaryMaxChars: cfg.summaryMaxChars,
1134-
maxAnchorTurns: cfg.maxAnchorTurns,
11351127
compactionShape: shape,
11361128
...extraInstructionParameter(cfg),
11371129
},
@@ -1173,7 +1165,6 @@ export function createPruningCompactor(
11731165
export function buildTurnSummary(
11741166
turns: ConversationTurn[],
11751167
maxChars: number,
1176-
anchorCount = 0,
11771168
): string {
11781169
const toolNames = new Set<string>();
11791170
let totalTokens = 0;
@@ -1202,7 +1193,7 @@ export function buildTurnSummary(
12021193
}
12031194

12041195
const lines: string[] = [
1205-
`Turns compacted: ${turns.length}${anchorCount > 0 ? ` (${anchorCount} anchor turns preserved separately)` : ""}`,
1196+
`Turns compacted: ${turns.length}`,
12061197
`Estimated tokens: ~${totalTokens}`,
12071198
`Tools called: ${[...toolNames].sort().join(", ")}`,
12081199
`Total tool calls: ${toolCallCount}`,

0 commit comments

Comments
 (0)