fix(coding-agent): avoid retrying successful overflow compaction

closes #5720
This commit is contained in:
Armin Ronacher
2026-06-18 19:30:14 +02:00
parent 788a044483
commit 6b9f3f492f
3 changed files with 46 additions and 2 deletions

View File

@@ -248,6 +248,37 @@ describe("AgentSession compaction characterization", () => {
);
});
it("compacts successful overflow responses without retrying", async () => {
const harness = await createHarness({
settings: { compaction: { enabled: true, keepRecentTokens: 1, reserveTokens: 0 } },
models: [{ id: "faux-1", contextWindow: 1, maxTokens: 100 }],
extensionFactories: [
(pi) => {
pi.on("session_before_compact", async (event) => ({
compaction: {
summary: "successful overflow compacted",
firstKeptEntryId: event.preparation.firstKeptEntryId,
tokensBefore: event.preparation.tokensBefore,
details: {},
},
}));
},
],
});
harnesses.push(harness);
harness.setResponses([fauxAssistantMessage("completed answer")]);
await expect(harness.session.prompt("hello")).resolves.toBeUndefined();
const compactionEnd = harness.eventsOfType("compaction_end").at(-1);
expect(compactionEnd).toMatchObject({
reason: "overflow",
aborted: false,
willRetry: false,
});
expect(harness.faux.state.callCount).toBe(1);
});
it("ignores stale pre-compaction assistant usage on pre-prompt checks", async () => {
const harness = await createHarness();
harnesses.push(harness);