ISSUE DESCRIPTION Isolated cron runs leak context when they reuse a stable session key…
- User
ISSUE DESCRIPTION
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.
ADDITIONAL ADVICE
Since you are given a git repository, you can use git commands to simplify your work. For example, if you made a mistake and want to revert your changes, you can use
git checkout <file>to restore the file to its original state. You can also reset all changes in the repository usinggit reset --hardcommand. Additionally, you can usegit stashandgit stash popto temporarily save your changes and restore them later. Finally, you can see the changes that you've made (which will be submitted when you callsubmit) usinggit statusorgit diffcommands. However you don't need to usegit addorgit commitbefore submitting your changes. In fact,submitonly submits currently unstaged changes because it usesgit diffto get the changes that need to be submitted.CHECKLIST
Before submitting your solution, please go over the following checklist and make sure you've done everything:
- If an error was reported in the issue description, I have successfully reproduced it.
- If an error was reported in the issue description, I have confirmed that my fix resolves the error.
- I have thought about edge cases and made sure my fix handles them as well.
- I have run existing tests in the repository that might have been affected by the change I made and confirmed that they pass. I want you to list every bullet from this checklist and write your reasoning for why you think you did it or didn't need to.
Repository has been uploaded and your shell is currently at the repository root. Time to solve the issue!
(Current directory: /lossless-claw, current file: none) bash-$
- Assistant
I’ll first map the repository and search for cron/session-key/LCM context handling, then identify the lifecycle boundary that should distinguish isolated cron runs while preserving archival and normal continuity.
- Assistant
rgis unavailable, so I’ll use recursivegrepand inspect the plugin entry points and session-pattern utilities where runtime metadata is likely translated into storage identity. - Assistant
The database deliberately permits only one active conversation per session key, which explains the leak if cron runtime IDs change but keys remain stable. I’ll inspect conversation resolution/rotation and hook metadata to determine how cron isolation is represented and where to archive the prior active row.
- Assistant
I need the exact lookup semantics and context-engine callback contracts. I’ll extract the relevant store methods, engine lifecycle methods, bridge types, and existing integration tests around session rotation to establish the expected behavior before changing code.
- Assistant
The bridge contract currently carries only session ID/key into engine operations, while lifecycle events preserve arbitrary host fields. The likely robust discriminator is the cron key shape (
agent:<id>:cron:*) plus a changed runtimesessionId. I’ll inspect lookup/get-or-create and the stale-transcript rotation logic to avoid conflicting with ordinary stable-key continuity. - Assistant
getOrCreateConversationexplicitly rewrites the existing row’s runtime ID when a stable key is reused—the direct cause. A cron-specific archive-on-ID-change must happen atomically before all reads for a new run, not merely during transcript bootstrap (which may be absent). I’ll trace bootstrap, ingest, assemble, and compact entry paths and their serialization to choose a single shared resolver. - Assistant
All operations serialize by stable key, so an atomic resolver can safely archive once and let same-run calls reuse the new row. I’ll inspect each public operation’s first lookup and the rollover helper that already detects mismatched IDs, then implement cron isolation at the lowest common identity layer without changing public interfaces.
- Assistant
A mutating generic lookup would be unsafe for delayed lifecycle events (an old run could rotate storage backward). Instead, I’ll add a private engine guard used only by active runtime operations: for cron-shaped keys, if the active row belongs to another runtime ID, archive it and create a fresh row under the existing per-key queue/transaction.
getOrCreateConversationwill apply the same rule for bootstrap/ingest. This keeps lifecycle lookups and ordinary sessions unchanged. - Assistant
Cron keys may include both stable job keys and run-suffixed keys, so detection should recognize the structural
agent:<id>:cron:<suffix>lane rather than a single literal. I’ll add one internal predicate and one engine resolver, then route bootstrap, ingest, assemble, maintain, and compact through it. The resolver archives only when both IDs are nonempty and differ, preserving compaction and all continuity within the same run. - Assistant
I’ll now implement the internal cron-lane predicate and resolver. The engine resolver will log archival, retain prior rows, and return the current run’s row; placement before bootstrap ambiguity checks is important because isolated cron runs intentionally do not require transcript-tail continuity proof.
- Assistant
I’ll make the source edits with a small deterministic script, then inspect the diff before compiling.
- Assistant
Python is unavailable; I’ll apply the same deterministic transformations using Node.js, which is native to this project.
- Assistant
The diff has the intended behavior. Before testing, I’ll format the long additions to match project style, then run typecheck and focused engine/session tests.
- Assistant
Typecheck and 319 focused tests pass. I still need directly reproduce the reported scenario and verify the fix: I’ll create a temporary (removed before submission) Vitest file with a minimal engine, ingest two cron runs under one key, and assert archival, no cross-run assembly, same-run continuity, plus an ordinary keyed-session control.
- Assistant
I’ll extract the compact test-engine constructor and use it in the temporary regression test.
- Assistant
To avoid duplicating a large fixture, I’ll temporarily append one focused case to the existing engine test file, run only that case, and restore the file byte-for-byte immediately afterward. No test changes will remain in the submission.
- Assistant
The direct reproduction passes: the second cron run sees none of the first run’s content, the first row remains archived, repeated operations in run two reuse its row, and ordinary stable-key continuity still keeps one conversation. I’ll now run the complete suite and build, then review the final diff for unintended changes.
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.