Skip to content

Commit 65b9ffc

Browse files
committed
refactor(session): drop excerpt-cache narration
1 parent ea7a9f4 commit 65b9ffc

2 files changed

Lines changed: 1 addition & 17 deletions

File tree

‎src/session/compactor-excerpt-once.test.ts‎

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ function liveResultText(turns: ConversationTurn[]): string {
6666
.join("\n");
6767
}
6868

69-
describe("CL-10535 single excerpt per tail turn", () => {
69+
describe("excerpt once per tail turn", () => {
7070
test("compactor excerpts each tail turn exactly once with identical values", async () => {
7171
const dump = "z".repeat(12_000);
7272
const turns: ConversationTurn[] = [
@@ -80,8 +80,6 @@ describe("CL-10535 single excerpt per tail turn", () => {
8080

8181
const before = excerptTailTurnCallCount();
8282
const result = await createPruningCompactor({
83-
// Generous budget: every tail turn is a candidate, so a full pass
84-
// must excerpt each turn exactly once.
8583
compactionShape: { tailBudgetTokens: 1_000_000 },
8684
summarize: async () => {
8785
throw new Error("must not invent a summary: nothing excluded");
@@ -90,13 +88,8 @@ describe("CL-10535 single excerpt per tail turn", () => {
9088

9189
const calls = excerptTailTurnCallCount() - before;
9290

93-
// One excerptTailTurn call per tail turn — never the same turn twice
94-
// (the closure estimate, turnCost, and emitted live copies share the
95-
// first excerpt).
9691
expect(calls).toBe(turns.length);
9792

98-
// Values stay identical to the pre-fix behavior: the oversized outputs
99-
// are still head+tail excerpted in the live tail.
10093
const live = liveResultText(result.output);
10194
expect(live.match(/\[tail-shortened \d+→/g)?.length ?? 0).toBe(3);
10295
expect(live).not.toContain(dump);

‎src/session/compactor.ts‎

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -647,10 +647,6 @@ function excerptTailText(
647647
};
648648
}
649649

650-
// Test seam (CL-10535): total excerptTailTurn invocations since module load.
651-
// selectTail reuses the first excerpt per tail turn (closure estimates,
652-
// turnCost, and the emitted live copies share one cache), so a pass over N
653-
// tail turns adds exactly N to this counter.
654650
let excerptTailTurnCallCountValue = 0;
655651
export function excerptTailTurnCallCount(): number {
656652
return excerptTailTurnCallCountValue;
@@ -726,8 +722,6 @@ function lastAssistantToolCallIndex(
726722
return undefined;
727723
}
728724

729-
// Token estimate over an already-excerpted live turn. Does not re-excerpt:
730-
// callers reuse the first excerptTailTurn result (CL-10535).
731725
function liveTurnTokens(live: ConversationTurn): number {
732726
let tokens = 0;
733727
for (const block of live.content) {
@@ -776,9 +770,6 @@ function selectTail(
776770
const budgetTokens = shape.tailBudgetTokens;
777771
const keepThinkingAt = lastAssistantToolCallIndex(turns);
778772

779-
// Excerpt results are cached per tail turn so each turn is excerpted at most
780-
// once per pass: the closure token estimate, turnCost, and the emitted live
781-
// copies all reuse the first excerpt (CL-10535).
782773
type ExcerptResult = ReturnType<typeof excerptTailTurn>;
783774
const excerptCache = new Map<number, ExcerptResult>();
784775
const excerptFor = (idx: number, turn: ConversationTurn): ExcerptResult => {

0 commit comments

Comments
 (0)