fix(coding-agent): stabilize auto-compaction threshold test

This commit is contained in:
Armin Ronacher
2026-07-05 23:14:10 +02:00
parent 604ac652d0
commit 75ac0cb0e6
@@ -248,7 +248,10 @@ describe("AgentSession auto-compaction queue resume", () => {
it("should trigger threshold compaction for error messages using last successful usage", async () => { it("should trigger threshold compaction for error messages using last successful usage", async () => {
const model = session.model!; const model = session.model!;
// A successful assistant message with high token usage (near context limit) // A successful assistant message with token usage just over the compaction threshold.
// Compute this from the selected model so generated catalog context-window changes do not break the test.
const compactionSettings = settingsManager.getCompactionSettings();
const thresholdTokens = (model.contextWindow ?? 200_000) - compactionSettings.reserveTokens + 1;
const successfulAssistant: AssistantMessage = { const successfulAssistant: AssistantMessage = {
role: "assistant", role: "assistant",
content: [{ type: "text", text: "large successful response" }], content: [{ type: "text", text: "large successful response" }],
@@ -256,11 +259,11 @@ describe("AgentSession auto-compaction queue resume", () => {
provider: model.provider, provider: model.provider,
model: model.id, model: model.id,
usage: { usage: {
input: 180_000, input: thresholdTokens - 10_000,
output: 10_000, output: 10_000,
cacheRead: 0, cacheRead: 0,
cacheWrite: 0, cacheWrite: 0,
totalTokens: 190_000, totalTokens: thresholdTokens,
cost: { input: 0, output: 0, cacheRead: 0, cacheWrite: 0, total: 0 }, cost: { input: 0, output: 0, cacheRead: 0, cacheWrite: 0, total: 0 },
}, },
stopReason: "stop", stopReason: "stop",