From d4c9511f80a3df3191a64698212099ebf588e7da Mon Sep 17 00:00:00 2001 From: Cursor Agent Date: Sat, 11 Apr 2026 01:10:53 +0000 Subject: [PATCH] Fix unguarded cache clear on provider exit and overly broad compaction item heuristic - Guard clearTurnStateForSession with shouldApplyThreadLifecycle so a replaced provider's session.exited event does not wipe turn caches belonging to the new provider's in-progress turn. - Remove the overly broad 'summary' fallback from looksLikeCompactionItem; only compact_summary and compactSummary are specific enough to identify compaction items without false positives. --- .../src/orchestration/Layers/ProviderRuntimeIngestion.ts | 2 +- apps/server/src/provider/handoffSummary.ts | 6 +----- 2 files changed, 2 insertions(+), 6 deletions(-) diff --git a/apps/server/src/orchestration/Layers/ProviderRuntimeIngestion.ts b/apps/server/src/orchestration/Layers/ProviderRuntimeIngestion.ts index 2661011f3c..5a10494078 100644 --- a/apps/server/src/orchestration/Layers/ProviderRuntimeIngestion.ts +++ b/apps/server/src/orchestration/Layers/ProviderRuntimeIngestion.ts @@ -1147,7 +1147,7 @@ const make = Effect.fn("make")(function* () { } } - if (event.type === "session.exited") { + if (event.type === "session.exited" && shouldApplyThreadLifecycle) { yield* clearTurnStateForSession(thread.id); } diff --git a/apps/server/src/provider/handoffSummary.ts b/apps/server/src/provider/handoffSummary.ts index 38fe8f4f95..38586e7e1b 100644 --- a/apps/server/src/provider/handoffSummary.ts +++ b/apps/server/src/provider/handoffSummary.ts @@ -72,11 +72,7 @@ function looksLikeCompactionItem(value: unknown): boolean { if (COMPACTION_TYPE_SNIPPETS.some((snippet) => type.includes(snippet))) { return true; } - return ( - typeof record.compact_summary === "string" || - typeof record.compactSummary === "string" || - typeof record.summary === "string" - ); + return typeof record.compact_summary === "string" || typeof record.compactSummary === "string"; } export function extractCompactionSummaryFromSnapshot(snapshot: {