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 start by exploring the repository structure and searching for code related to isolated cron runs and session keys.
- Assistant
I'll dig into cron-related session handling and LCM context isolation next.
- Assistant
Switching to grep for cron and session-key references across the codebase.
- Assistant
Hmm that didn't work well. Let me try differently.
- Assistant
Looking for isolated session runtime and context-leakage behavior next.
- Assistant
There's something about stable sessionKey rotating when transcript changes. The issue is about isolated cron runs reusing a stable session key and leaking context. Let me search for more specific test...
- Assistant
I'll inspect engine session continuity/archive tests and recent related commits.
- Assistant
Those changesets look relevant — I'll read them and the isolated contextMode path in the engine.
- Assistant
I'll search for how isolate/cron session keys are treated during assemble and afterTurn.
- Assistant
Let me look at the dimensions of session key rollover for stable keys - especially when sessionId changes. There might be tests or incomplete code about cron isolation.
- Assistant
Let me read the code around line 6914 which seems to handle session key rollover.
- Assistant
I'll also check AGENTS.md and the OpenClaw plugin path for how isolated cron sessions are set up.
- Assistant
I'll search the plugin and engine for how cron runs are detected and whether isolation is handled on rollover.
- Assistant
Let me look at git stash or any uncommitted work, and also look at recent test files for hints about what was expected. Maybe there's a failing test already.
- Assistant
Let me look at CHANGELOG for anything about cron isolated context, and also look at .local directory and audit for clues about the issue.
- Assistant
Let me look at conversation store session key lookup and what's called getConversationForSession. The issue is about isolated cron runs reusing a stable session key.
- Assistant
Let me search for how git history might hint at the issue, and look at conversation-store for how sessions thickening is keyed. Also look at bootstrap for when it merges by sessionKey.
- Assistant
I'll read getOrCreateConversation and related session-key reuse logic carefully.
- Assistant
Searching docs and local notes for how isolated cron sessions are supposed to work.
- Assistant
I'll inspect the failed-closed ambiguous rollover path and any cron-related tests for the intended behavior.
- Assistant
Let me understand more. For cron, users might remove them from ignoreSessionPatterns so they get compaction during a run (the issue says "compaction within the current run still works"). Between isola...
- Assistant
Checking how OpenClaw names isolated cron session keys in the installed packages.
- Assistant
Hmm no openclaw package maybe. Let me check package.json
- Assistant
I'll look through recent commits and
.githubfor any notes on this cron isolation issue. - Assistant
I'll inspect how assemble and afterTurn resolve conversations onambiguous session-key rollover.
- Assistant
I'll check afterTurn conversation resolution and the rebinding path when session IDs change.
- Assistant
Let me read afterTurn from the start around 8286 for how garment cascade works
- Assistant
I'll inspect reconcileTranscriptTailForAfterTurn, which is likely where inactive conversation rebinding starts.
- Assistant
I'll inspect delivery-only rotation and sessionId-change continuity so the cron fix doesn't break those paths.
- Assistant
Checking conversation uniqueness constraints so archived cron rows can share a session key.
- Assistant
I'll write a temporary script that reproduces the cron context leak:
- Assistant
Creating and running a temporary reproduction script next.
- Assistant
I'll put a temporary vitest file under
test/and run it. - Assistant
I'll mirror the existing test helper exactly when constructing the engine.
- Assistant
The constructor is
new LcmContextEngine(deps, db)- db is second arg. - Assistant
There's a typo in the file (
typecology); I'll fix that next. - Assistant
The sed didn't work. Let mecheck the file.
- Assistant
python3 not found, use node to fix
- Assistant
Confirmed the bug: cron runs fail closed, leave the prior conversation active, and block current-run compaction. Implementing rotation at isolated cron run boundaries.
- Assistant
Implementing the helper and wiring it into engine lifecycle paths.
- Assistant
I'll edit session-patterns.ts and engine.ts
- Assistant
Now update engine.ts imports and add the method. Let me find the import line for session-patterns.
- Assistant
I'll update the import and insert the rotation helper plus its call sites carefully.
- Assistant
I'll use replace for the import and then addthe method after rotateStaleSessionKey iso...
- Assistant
I'm inserting the new rotation method right after the stale-session-key handler.
- Assistant
I'll insert the new method between rotateStale and findAmbiguous.
- Assistant
Cleaning up duplicate lines introduced by the edit.
- Assistant
I accidentally dropped the
phasefield fromfindAmbiguousSessionKeyRuntimeRollover; restoring it now. - Assistant
There's still a duplicate line 7024. Fix it.
- Assistant
Wiring the cron rotation into bootstrap, assemble, afterTurn, and ingest next.
- Assistant
I need to add calls after each of these call sites (not the definition).
- Assistant
I'll use replace to add the cron rotate calls at each site.
- Assistant
Need to navigate to the lines first perhaps, or use goto before replace.
- Assistant
Now replace should work.
- Assistant
Good. Now bootstrap andassemble and ingest.
- Assistant
For bootstrap, toast call cron rotate BEFORE ambiguous check so ambiguous won't fire forne cron.
- Assistant
Now assemble radio and ingestSingle.
- Assistant
goto assemble and ingest
- Assistant
For assemble with createReplacement: false, after rotation conversation is null and safeFallback - good, no old context.
- Assistant
Now ingestSingle - need to rotate before getOrCreate so direct ingestšte doesn't rebind.
- Assistant
I'll add the rotate before getOrCreate in ingestSingle.
- Assistant
Adding a changeset and rechecking the fix with the temporary repro.
- Assistant
Fix confirmed. Cleaning up the temp test and running the related suite.
- Assistant
I'll typecheck and run a few more targeted engine tests.
- Assistant
Verifying the final diff is clean before submit.
- Assistant
Making the changeset show up in
git diffwith intent-to-add so submit picks it up.
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.