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
Searching the codebase for isolated cron session and LCM context handling.
- Assistant
Let me search for cron-related code using grep since rg is not available.
- Assistant
Looking at conversation management and how active session keys are handled.
- Assistant
Let me look at the conversation store more carefully, especially getOrCreateConversation and how session keys work with cron. Also let me check CHANGELOG and git history for related fix attempts.
- Assistant
I'll dig into how the engine handles session continuity for cron and reset flows.
- Assistant
Let me look at the engine throughout the lifecycle methods and how after_turn / bootstrap works with session continuity. Also look for any existing tests related to this issue.
- Assistant
There's already something about session key rollover. Let me look at:
- Assistant
Looking at more of the engine for isolated/stateless session handling and related tests.
- Assistant
Let me look at the assemble path more carefully and how cron sessions might re-use session keys. Also check session-patterns and default config for treat isolation...
- Assistant
Inspecting assemble logic and how cron/isolated sessions are treated in the bridge.
- Assistant
Checking how the plugin hooks handle sessions and whether isolation flags are passed through.
- Assistant
Searching tests and git history for this specific isolated-cron behavior.
- Assistant
Let me look at handleSessionEnd and how cron sessions might not properly archive. Also look at assemble method completely.
- Assistant
Given the issue description more carefully: I need to carefully analyze the issue and determine how to implement the fix. Let me think through this systematically.
The core problem is that isolated cron runs that reuse a stable session key should not share active LCM context between runs.
- Assistant
Checking documentation and defaults for cron session handling.
- Assistant
Let me look at GitHub issues or PRs in the audit folder, and also search for any TODOs related to this.
- Assistant
Let me examine the test cases around rotating stale session keys more carefully - especially at line 3716. And I'll look at how OpenClaw names cron sessions.
- Assistant
Checking OpenClaw types for how isolated cron sessions are represented.
- Assistant
Searching recent changelog and git history for related context-continuity work.
- Assistant
Looking at bridge types and how runtime context might indicate isolated sessions.
- Assistant
Checking how subagent and cron session keys are detected.
- Assistant
Checking how conversations are created during ingest and afterTurn when none exists.
- Assistant
Let me look at line 8105 for getOrCreate in ingestSingle.
- Assistant
Implementing a cron-specific runtime rollover that archives the prior active conversation when the session ID changes, and verifying the current leak with a temporary script.
- Assistant
Writing a temporary script to reproduce the isolated-cron context leak, then implementing the fixed.
- Assistant
Reproduced the leak. Implementing the isolated-cron runtime rollover fix.
- Assistant
I'll add isCronSessionKey to session-patterns.ts and then update engine.ts.
- Assistant
Fixing the comment typo, then updating the engine.
- Assistant
Updating the engine import and adding the isolated-cron rollover logic.
- Assistant
I'll update the import and add the method next to rotateStaleSessionKeyConversationIfTrackedTranscriptMissing.
- Assistant
Inserting the isolated-cron rollover method and wiring it into the three call sites.
- Assistant
Wiring the three call sites.
- Assistant
I need to open each call site and add the cron rotate before it.
- Assistant
I used wrong sed syntax.
- Assistant
I'll use replace for each of the three call sites.
- Assistant
Navigating to the relevant lines before applying the replacementasist.
- Assistant
Now replace should work.
- Assistant
Good. Now bootstrap and assemble.
- Assistant
I'll replace bootstrap call site.
- Assistant
Now assemble site.
- Assistant
Replace assemble call site.
- Assistant
There's also the issue that when assemble runs with createReplacement: false forGreenhouse cron stats, the old is archived but no new is created - good for no leak. When bootstrap runs with createRepl...I understand the issue you're describing: isolated cron runs that reuse a stable session key must not share active LCM context, while still allowing prior runs to remain archived and compaction to work within the current run.
- Assistant
The fix works for the main cases. Fixing the scriptypo and re-running.
- Assistant
Verified the fix. Adding a changeset and running related tests.
- Assistant
session-patterns tests were skipped due to -t filter. Running them without it, andveillancees double-checking isCronSessionKey.
- Assistant
Typo in my test case only. Cleaning up and verifying the full diff.
- Assistant
Making the changeset visible to
git diffvia intent-to-add. - Assistant
Running a quick typecheck to ensure everything compiles.
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.
Identical first prompt
claude-sonnet-5Compare side by side →
claude-sonnet-5Compare side by side →
claude-sonnet-5Compare side by side →
claude-sonnet-5Compare side by side →
claude-sonnet-5Compare side by side →
Qwen/Qwen3.6-35B-A3BCompare side by side →
Qwen/Qwen3.6-35B-A3BCompare side by side →
Qwen/Qwen3.6-35B-A3BCompare side by side →
Qwen/Qwen3.6-35B-A3BCompare side by side →
Qwen/Qwen3.6-35B-A3BCompare side by side →
Qwen/Qwen3.6-27BCompare side by side →
Qwen/Qwen3.6-27BCompare side by side →