diff --git a/src/context-compactor.test.ts b/src/context-compactor.test.ts index 9491ce8e1..fb83d951e 100644 --- a/src/context-compactor.test.ts +++ b/src/context-compactor.test.ts @@ -191,7 +191,6 @@ describe("createPruningCompactor — initiating task preservation", () => { test("keeps alternating roles when a tool_result user turn abuts a plain user turn", async () => { const compactor = smallCompactor({ - maxAnchorTurns: 3, summaryMaxChars: 500, }); const turns: ConversationTurn[] = [ @@ -255,7 +254,6 @@ describe("createPruningCompactor — image aging", () => { test("strips image bytes from an anchored (aged) turn but keeps its text", async () => { const compactor = smallCompactor({ - maxAnchorTurns: 1, summaryMaxChars: 500, }); const turns: ConversationTurn[] = [ @@ -421,7 +419,6 @@ describe("createPruningCompactor — error anchoring (CL-6906)", () => { ...padding(8, "after"), ]; const compactor = smallCompactor({ - maxAnchorTurns: 8, summaryMaxChars: 2000, }); const { output } = await compactor.apply(turns, mockStrategyCtx); @@ -467,7 +464,6 @@ describe("createPruningCompactor — error anchoring (CL-6906)", () => { ...padding(8, "after"), ]; const compactor = smallCompactor({ - maxAnchorTurns: 8, summaryMaxChars: 2000, }); const { output, blobs } = await compactor.apply(turns, mockStrategyCtx); @@ -527,7 +523,6 @@ describe("createPruningCompactor — error anchoring (CL-6906)", () => { ...padding(8, "after"), ]; const compactor = smallCompactor({ - maxAnchorTurns: 8, summaryMaxChars: 2000, }); const { output, record } = await compactor.apply(turns, mockStrategyCtx); @@ -654,7 +649,6 @@ describe("createPruningCompactor — consolidated handoff (CL-7521)", () => { test("second apply keeps the initiating task in the handoff, not as a live user turn", async () => { const compactor = smallCompactor({ - maxAnchorTurns: 1, summaryMaxChars: 500, }); const goal = "GOAL: migrate the auth module to opaque tokens"; @@ -759,7 +753,6 @@ describe("createPruningCompactor — consolidated handoff (CL-7521)", () => { test("empty-fold keep-set returns the input unchanged", async () => { const compactor = smallCompactor({ tailBudgetTokens: 500, - maxAnchorTurns: 8, summaryMaxChars: 500, }); const turns: ConversationTurn[] = [ diff --git a/src/session/compaction-archive.test.ts b/src/session/compaction-archive.test.ts index 6dc2873d7..18aa44012 100644 --- a/src/session/compaction-archive.test.ts +++ b/src/session/compaction-archive.test.ts @@ -806,7 +806,6 @@ describe("wrapCompactorWithCompletenessGate", () => { payload: "working", }); const inner = createPruningCompactor({ - maxAnchorTurns: 0, summaryMaxChars: 500, // Pin a tiny tail budget so the fold covers the same older region the // old keepRecentTurns cut folded. diff --git a/src/session/compactor-pairing.test.ts b/src/session/compactor-pairing.test.ts index fcb4f97b2..920ab7a3e 100644 --- a/src/session/compactor-pairing.test.ts +++ b/src/session/compactor-pairing.test.ts @@ -61,7 +61,6 @@ describe("pruning compactor preserves tool_call/tool_result pairing", () => { // Pin a tiny tail budget so the fold covers the older region the old // keepRecentTurns cut. compactionShape: { tailBudgetTokens: 120 }, - maxAnchorTurns: 2, }); const { output } = await compactor.apply(turns, {} as never); expect(() => assertWellFormedToolSequence(output)).not.toThrow(); @@ -84,7 +83,6 @@ describe("pruning compactor preserves tool_call/tool_result pairing", () => { // Pin a tiny tail budget so the fold covers the older region the old // keepRecentTurns cut. compactionShape: { tailBudgetTokens: 120 }, - maxAnchorTurns: 2, }); const { output } = await compactor.apply(turns, {} as never); expect(() => assertWellFormedToolSequence(output)).not.toThrow(); @@ -129,7 +127,6 @@ describe("pruning compactor preserves tool_call/tool_result pairing", () => { // Pin a tiny tail budget so the fold covers the older region the old // keepRecentTurns cut. compactionShape: { tailBudgetTokens: 120 }, - maxAnchorTurns: 2, }); const { output } = await compactor.apply(turns, {} as never); const kept = output.find((t) => @@ -182,7 +179,6 @@ describe("pruning compactor preserves tool_call/tool_result pairing", () => { // Pin a tiny tail budget so the fold covers the older region the old // keepRecentTurns cut. compactionShape: { tailBudgetTokens: 120 }, - maxAnchorTurns: 2, }); const { output } = await compactor.apply(turns, {} as never); const kept = output.find((t) => @@ -208,7 +204,7 @@ describe("pruning compactor preserves tool_call/tool_result pairing", () => { ], timestamp: 1, }; - const summary = buildTurnSummary([big], 2000, 0); + const summary = buildTurnSummary([big], 2000); const tokens = Number(summary.match(/Estimated tokens: ~(\d+)/)?.[1] ?? -1); // A 100KB text result is ~25000 tokens; the old String(content) bug yielded ~4. expect(tokens).toBeGreaterThan(20000); @@ -285,7 +281,6 @@ describe("pruning compactor stubs superseded file reads (CL-4374)", () => { const compactor = createPruningCompactor({ // Whole transcript is the tail so stubbing still runs with no summarized region. compactionShape: TAIL_SWALLOWS_TRANSCRIPT, - maxAnchorTurns: 2, }); const { output } = await compactor.apply(turns, {} as never); @@ -317,7 +312,6 @@ describe("pruning compactor stubs superseded file reads (CL-4374)", () => { ]; const compactor = createPruningCompactor({ compactionShape: TAIL_SWALLOWS_TRANSCRIPT, - maxAnchorTurns: 2, }); const { output } = await compactor.apply(turns, {} as never); @@ -345,7 +339,6 @@ describe("pruning compactor stubs superseded file reads (CL-4374)", () => { // Newest pair + end fit the token budget; the older pair is summarized. const compactor = createPruningCompactor({ compactionShape: { tailBudgetTokens: 80 }, - maxAnchorTurns: 0, }); const { output } = await compactor.apply(turns, {} as never); expect(resultText(output, "old")).toBeUndefined(); @@ -391,7 +384,6 @@ describe("pruning compactor stubs superseded file reads (CL-4374)", () => { ]; const compactor = createPruningCompactor({ compactionShape: TAIL_SWALLOWS_TRANSCRIPT, - maxAnchorTurns: 2, }); const { output } = await compactor.apply(turns, {} as never); expect(resultText(output, "r1")).toBe(body1); @@ -438,7 +430,6 @@ describe("pruning compactor stubs superseded file reads (CL-4374)", () => { ]; const compactor = createPruningCompactor({ compactionShape: TAIL_SWALLOWS_TRANSCRIPT, - maxAnchorTurns: 2, }); const { output } = await compactor.apply(turns, {} as never); const older = resultText(output, "r1"); @@ -504,7 +495,6 @@ describe("pruning compactor extends superseded-result stubbing to query tools (C ]; const compactor = createPruningCompactor({ compactionShape: TAIL_SWALLOWS_TRANSCRIPT, - maxAnchorTurns: 2, }); const { output } = await compactor.apply(turns, {} as never); const older = resultText(output, "q1"); @@ -531,7 +521,6 @@ describe("pruning compactor extends superseded-result stubbing to query tools (C ]; const compactor = createPruningCompactor({ compactionShape: TAIL_SWALLOWS_TRANSCRIPT, - maxAnchorTurns: 2, }); const { output } = await compactor.apply(turns, {} as never); expect(resultText(output, "g1")).toBe(body1); @@ -558,7 +547,6 @@ describe("pruning compactor extends superseded-result stubbing to query tools (C ]; const compactor = createPruningCompactor({ compactionShape: TAIL_SWALLOWS_TRANSCRIPT, - maxAnchorTurns: 2, }); const { output } = await compactor.apply(turns, {} as never); expect(resultText(output, "sh1")).toBe(oldBody); @@ -591,7 +579,6 @@ describe("CL-9489 budgeted tail does not ingest gap turns", () => { turns[turns.length - 1] = fatResult; const { output, record } = await createPruningCompactor({ - maxAnchorTurns: 0, compactionShape: { tailBudgetTokens: 400 }, }).apply(turns, {} as never); diff --git a/src/session/compactor.ts b/src/session/compactor.ts index 455a832fe..991454dbe 100644 --- a/src/session/compactor.ts +++ b/src/session/compactor.ts @@ -49,8 +49,6 @@ export interface CompactorConfig { /** Previous fat handoff body: the next fold unions its files/commands and * full goal text rather than spine cuts. */ readPriorHandoff?: () => Promise; - // Kept for compatibility; the live fold keeps spine + token-capped tail. - maxAnchorTurns: number; /** Budgeted-tail shape (token budget, not turn-count floor). Missing * fields resolve against DEFAULT_TAIL_COMPACTION_SHAPE. */ compactionShape?: Partial; @@ -103,7 +101,6 @@ export const HARNESS_COMPACT_SPACER_MODEL = "harness"; const DEFAULT_COMPACTOR_CONFIG: CompactorConfig = { summaryMaxChars: 2000, - maxAnchorTurns: 8, }; function extraInstructionParameter( @@ -393,7 +390,7 @@ function buildPartnerIndex( } function isFoldableHandoffTurn(turn: ConversationTurn): boolean { - return isCompactedSummaryTurn(turn) || isCompactSpacerTurn(turn); + return isCompactedSummaryTurn(turn) || isHarnessCompactSpacer(turn); } function resultContentSize( @@ -528,8 +525,8 @@ function coalesceAdjacentTextTurns( isPlainTextTurn(turn) && !isCompactedSummaryTurn(prev) && !isCompactedSummaryTurn(turn) && - !isCompactSpacerTurn(prev) && - !isCompactSpacerTurn(turn) + !isHarnessCompactSpacer(prev) && + !isHarnessCompactSpacer(turn) ) { out[out.length - 1] = { ...prev, @@ -604,10 +601,6 @@ export function isHarnessCompactSpacer(turn: ConversationTurn): boolean { return turn.model === undefined && text === LEGACY_COMPACT_SPACER_TEXT; } -function isCompactSpacerTurn(turn: ConversationTurn): boolean { - return isHarnessCompactSpacer(turn); -} - function compactSpacerTurn(timestamp: number): ConversationTurn { return { role: "assistant", @@ -1131,7 +1124,6 @@ export function createPruningCompactor( version: this.version, parameters: { summaryMaxChars: cfg.summaryMaxChars, - maxAnchorTurns: cfg.maxAnchorTurns, compactionShape: shape, ...extraInstructionParameter(cfg), }, @@ -1173,7 +1165,6 @@ export function createPruningCompactor( export function buildTurnSummary( turns: ConversationTurn[], maxChars: number, - anchorCount = 0, ): string { const toolNames = new Set(); let totalTokens = 0; @@ -1202,7 +1193,7 @@ export function buildTurnSummary( } const lines: string[] = [ - `Turns compacted: ${turns.length}${anchorCount > 0 ? ` (${anchorCount} anchor turns preserved separately)` : ""}`, + `Turns compacted: ${turns.length}`, `Estimated tokens: ~${totalTokens}`, `Tools called: ${[...toolNames].sort().join(", ")}`, `Total tool calls: ${toolCallCount}`,