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.
This commit is contained in:
Cursor Agent committed 2026-04-11 01:10:53 +00:00
1 parent 84b54f7284
commit d4c9511f80
2 files changed
+2 -6

No files matched your search

@@ -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);
}
+1 -5
View File
@@ -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: {