Isolated cron runs leak context when they reuse a stable session key Different isolated…
- User
Isolated cron runs leak context when they reuse a stable session key
Different isolated cron runtime sessions that reuse a stable session key must not share active LCM context. Prior runs remain archived, compaction within the current run still works, and ordinary non-cron session continuity is unchanged.
Interface
No new public interfaces are introduced.
- Assistant
Now the engine. Add the import:
- Assistant
Now wire the call sites. First,
bootstrap: - Assistant
assemble's lifecycle guard: - Assistant
afterTurn's transcript reconcile: - Assistant
ingestSingle, beforegetOrCreateConversation: - Assistant
And
compact, so a compact request from a new run can't operate on the prior run's conversation: - Assistant
Now let me typecheck:
- Assistant
Typecheck passes. Now add tests. First for
isCronSessionKey: - Assistant
Now the engine tests. Insert after the assemble ambiguous rollover test:
- Assistant
All 1073 tests pass. This repo uses changesets for fixes — let me add one:
- Assistant
All changes are in place and verified. Summary of the fix:
Problem
Isolated cron runs reuse a stable session key (
agent:<agentId>:cron:<jobId>) across separate runtime sessions. LCM's session-key continuity (getOrCreateConversation/getConversationForSessionresolve by key first) reattached each new run to the previous run's active conversation, leaking prior-run context into the new run. The existing transcript-file heuristics didn't cover this: the missing-transcript rotation only fires when the old file is gone, the ambiguous-rollover guard fails closed (disabling LCM for the whole run) only when a tracked checkpoint exists, and the path had no guard at all — it reattached unconditionally.
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.