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
Let me search for cron-related code and isolated sessions.
- Assistant
rg is not available, I'll use grep instead.
- Assistant
Let me look at session patterns and engine related to cron.
- Assistant
Let me look at more specific mentions of cron isolation
- Assistant
There's something about
contextMode: isolatedin the engine and bridge — I'll inspect those next. - Assistant
There's already a stale-session rotation helper — I'll dig into isolated context mode and session-key rollover next.
- Assistant
Let me look at the subagent/cron handling around line 9275 and conversation creation around archival.
- Assistant
I'll inspect conversation lookup by session key and how bootstrap attaches context for reused cron sessions.
- Assistant
Looking at the issue more carefully: "Different isolated cron runtime sessions that reuse a stable session key must not share active LCM context."
- Assistant
Let me search for how session start / assemble works with context and look at related tests for session end and reset. Also check the openclaw bridge for how cron runs are handled.
- Assistant
I'll dig into session-end handling and how bootstrap behaves when a session starts.
- Assistant
I'll focus on bootstrap and conversation get-or-create next, and skim the lifecycle-related tests.
- Assistant
Looking for cron-specific session identity and any existing incomplete fix around isolated runs.
- Assistant
I'll inspect
getOrCreateConversationnext to see what happens whensessionIdchanges butsessionKeystays the same. - Assistant
I'll check AGENTS.md and recent tests/changesets for the intended isolated-cron behavior.
- Assistant
There's a recent "avoid archived conversation reattachment" commit that may be related — checking that and assemble-on-session-file-change behavior.
- Assistant
Let me look at the audit folder and also search for any failing tests or TODOs related to this issue. Maybe there's something in the git stash or uncommitted files. Also check git branches.
- Assistant
I'll look for session-kind metadata and how cron lifecycle events are handled.
- Assistant
Let me look at the SessionEndLifecycleEvent type and how session keys for cron are structured. Also look at assembly when sessionId differs.
- Assistant
I'll search for isolation/continuity comments and inspect how assemble behaves when the runtime session id changes.
- Assistant
I'll search OpenClaw types in node_modules for how cron isolation and session keys are modeled.
- Assistant
I'll read the continuity and cron-related engine tests to pin down expected behavior.
- Assistant
I'll inspect afterTurn handling when sessionIds change under a stable sessionKey.
- Assistant
I'll check how conversation continuity interacts with delivery-only rotation, and skim related helpers.
- Assistant
Checking how ingest creates conversations.
- Assistant
I've identified the bug: stable cron session keys reattach new runtime session IDs to the prior active conversation. Next I'll reproduce it and implement a rotation for isolated cron runs.
- Assistant
I'll write a quick reproduction script to confirm the leak.
- Assistant
Need to run from the repo with proper paths.
- Assistant
Reproduced the leak. Implementing rotation when a cron session key is reused with a new runtime session id.
- Assistant
There's a weird duplication in the file content when ls-ing - the open command might have shown and cat appended. Let me check the actual file.
- Assistant
Adding the cron session helper and wiring it into the engine lifecycle.
- Assistant
Updating the engine import and adding the rotation method next.
- Assistant
I'll insert the rotation method just above the existing stale-session helper.
- Assistant
I'll insert the new method before rotateStale...
- Assistant
Wiring the new rotation into bootstrap, assemble, and afterTurn.
- Assistant
There areworldwide 3 call sites at 6418, 7181, 8810. Let me look at each.
- Assistant
I'll add the cron rotation call before each stale rotation call.
- Assistant
I’ll jump to that call site and apply the edit there.
- Assistant
Now try replace again.
- Assistant
Now bootstrap and assemble.
- Assistant
Replace bootstrap call site.
- Assistant
Now assemble.
- Assistant
Assemble is at 8821.
- Assistant
For assemble, if we use createReplacement: false, after archive there is no active conversation which is fine - safe fallback. But we might want createReplacement true so empty conversation is ready.....
- Assistant
Re-running the reproduction script and verifying compaction within a run.
- Assistant
Leak is fixed. Next I'll verify compaction within a run and non-cron continuity, then add a changeset.
- Assistant
Compaction failed only because tokenBudget was missing. I'll retry with it se and full within-run continuity check.
- Assistant
Compaction and non-cron continuity look good. Next I'll run the related engine tests and add a changeset.
- Assistant
Need to run vitest properly.
- Assistant
All tests passed. Creating the changeset and cleaning up.
- Assistant
I'll use
git add -Nso the changeset shows up ingit difffor submit.
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.