Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 0 additions & 7 deletions src/context-compactor.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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[] = [
Expand Down Expand Up @@ -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[] = [
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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";
Expand Down Expand Up @@ -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[] = [
Expand Down
1 change: 0 additions & 1 deletion src/session/compaction-archive.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
15 changes: 1 addition & 14 deletions src/session/compactor-pairing.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand All @@ -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();
Expand Down Expand Up @@ -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) =>
Expand Down Expand Up @@ -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) =>
Expand All @@ -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);
Expand Down Expand Up @@ -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);

Expand Down Expand Up @@ -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);

Expand Down Expand Up @@ -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();
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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");
Expand Down Expand Up @@ -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");
Expand All @@ -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);
Expand All @@ -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);
Expand Down Expand Up @@ -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);

Expand Down
17 changes: 4 additions & 13 deletions src/session/compactor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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<string | undefined>;
// 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<CompactionShape>;
Expand Down Expand Up @@ -103,7 +101,6 @@ export const HARNESS_COMPACT_SPACER_MODEL = "harness";

const DEFAULT_COMPACTOR_CONFIG: CompactorConfig = {
summaryMaxChars: 2000,
maxAnchorTurns: 8,
};

function extraInstructionParameter(
Expand Down Expand Up @@ -393,7 +390,7 @@ function buildPartnerIndex(
}

function isFoldableHandoffTurn(turn: ConversationTurn): boolean {
return isCompactedSummaryTurn(turn) || isCompactSpacerTurn(turn);
return isCompactedSummaryTurn(turn) || isHarnessCompactSpacer(turn);
}

function resultContentSize(
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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",
Expand Down Expand Up @@ -1131,7 +1124,6 @@ export function createPruningCompactor(
version: this.version,
parameters: {
summaryMaxChars: cfg.summaryMaxChars,
maxAnchorTurns: cfg.maxAnchorTurns,
compactionShape: shape,
...extraInstructionParameter(cfg),
},
Expand Down Expand Up @@ -1173,7 +1165,6 @@ export function createPruningCompactor(
export function buildTurnSummary(
turns: ConversationTurn[],
maxChars: number,
anchorCount = 0,
): string {
const toolNames = new Set<string>();
let totalTokens = 0;
Expand Down Expand Up @@ -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}`,
Expand Down
Loading