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 LCM context / session key handling.
- Assistant
Let me use grep instead of rg.
- Assistant
Let me look at session-patterns and engine related to cron, and CHANGELOG for related context.
- Assistant
Let me search for more specific terms related to isolated cron runs and session keys in the changelog and relevant source files.
- Assistant
Let me look for how session creation identity works with cron, and specifically anything about isolated crons.
- Assistant
Let me look at more of the engine around isolated sessions, and look for "isStatelessSession" which seemed interesting.
- Assistant
Let me search for related tests or changelog entries that might hint at expected behavior.
- Assistant
Let me look at git history or any recent related fixes, and also look for "isolated cron" more carefully. Also check AGENTS.md and architecture docs.
- Assistant
Let me look at the skill about session lifecycle and any related tests about rotation when sessionId changes but sessionKey stays the same.
- Assistant
Let me dig into bootstrap and conversation creation for session ID/key mismatches.
- Assistant
There's already handling for when session files go missing. But the issue is specifically about isolated cron runs that reuse a stable session key - perhaps the session files don't get deleted between...
- Assistant
Let me look at git log for recent related commits and also look at conversation-scope which might have session family logic. Also look at openclaw-bridge for hooks related to cron.
- Assistant
Let me look at openclaw.plugin.json and the plugin hooks, and also search for any incomplete work or TODOs related to this issue. Also check if there's a failing te...
- Assistant
Looking at getOrCreateConversation where sessionId gets updated on the existing row — that may be the leak.
- Assistant
Let me look at how OpenClaw presents isolated cron sessions - maybe there's something in node_modules/openclaw.
- Assistant
No openclaw package. Let me look at CHANGELOG more carefully and any incomplete mentions. Also check git stash and branches.
- Assistant
There's a relevantchangeset; let me read the assemble path and the stale session key rollover related code more carefully.
- Assistant
Looking atenterprise the ambiguous rollover case: when old transcript still exists and sessionId changes under same sessionKey, it fails closed. For isolated cron that reuses a stable session key, eac...
- Assistant
Let me check how afterTurn and ingest handle the conversation lookup path more carefully.
- Assistant
Looking at the afterTurn flow around line 6696 - when there's ambiguous rollover...
- Assistant
Let me check default ignore patterns and any existing helpers that identify cron session keys.
- Assistant
Let me look at doctor cleaners for cron and also search for any relevant unfinished code or TODO about isolated sessions. Also look at openclaw bridge.
- Assistant
Let me look at git show of recent related PR and README for more about cron. Also check if there's something in the AGENTS.md about this task.
- Assistant
Let me also look at session patterns and engine for any comment about isolated runs. Maybe search git history more carefully for stuff that was attempted.
- Assistant
Let me try searching GitHub issues via git notes or any patch files. Or maybe look at test file names more carefully for something about cron isolation. I need to understand the current codebase structure to implement this fix properly. Let me explore the repository to find relevant files. I'll start by listing the directory contents to see what's available.
Let me check what files are in the root directory: bash-$ ls -la
I should look for files related to sessions, LCM (Long Context Memory), cron handling, and conversation management. Let me search for session-related code.
Let me try to find files containing "session" or "cron": bash-$ find . -name ".ts" -o -name ".js" | head -20
Let me check the package.
- Assistant
Let me check getOrCreateConversation call sites and the beginning of engine.ts for helpers.
- Assistant
I'll implement rotation for isolated cron session keys when the runtime sessionId changes, so prior runs are archived and don't share active LCM context.
- Assistant
I'll add the isCronSessionKey helper to session-patterns.ts
- Assistant
Now I'm updating engine.ts to import
isCronSessionKeyand add rotation logic. - Assistant
Next I'll add the rotate method next to the existing stale session-key handler.
- Assistant
I'll insert the new method after rotateStaleSessionKeyConversationIfTrackedTranscriptMissing and before findAmbiguousSessionKeyRuntimeRollover.
- Assistant
The edit introduced duplicates — I'll clean those up.
- Assistant
I'll restore the
phaseparameter onfindAmbiguousSessionKeyRuntimeRolloverthat was dropped. - Assistant
Wiring the new rotator into bootstrap, assemble, afterTurn, and ingest next.
- Assistant
Let me look at each call site and add the cron rotation right after.
- Assistant
Oops, I used the wrong syntax for sed - need commas not colons.
- Assistant
I'll add the rotation call after each rotateStale call and before getOrCreate in ingest.
- Assistant
I need to goto the location first.
- Assistant
Now I'll do the replace.
- Assistant
Good. Now bootstrap.
- Assistant
I'll add the cron rotate after stale rotate in bootstrap.
- Assistant
Now assemble path.
- Assistant
Add cron rotation to assemble.
- Assistant
Now ingestSingle - before getOrCreateConversation.
- Assistant
I'll add rotate before getOrCreate in ingestSingle.
- Assistant
Fixing ingest: keep getOrCreate after rotation so ordinary session continuity still updates sessionId.
- Assistant
Checking whether
compactneeds the same guard when called before bootstrap. - Assistant
Guarding compact so isolated cron can't compact a prior run's conversation.
- Assistant
I'll update compact to rotate first.
- Assistant
Reverting the sessionId match check in compact — it would break ordinary session continuity.
- Assistant
I'll extend the phase type to include "compact" for the compact path.
- Assistant
Need to goto first.
- Assistant
Update phase type and compact call.
- Assistant
Update compact to use phase: "compact"
- Assistant
update phase to compact
- Assistant
Next I'll write a temporary verification script based on the engine test helpers, and add a changeset.
- Assistant
I'll create a temporary script that verifies the behavior.
- Assistant
The create command seems to have created an empty file outside the repo. Let me put the script inside the repo temp folder or write it correctly.
- Assistant
Verification passed. Running related existing tests next.
- Assistant
The filtered tests passed. Let me run a broader set of engine tests related to bootstrap/rotation more carefully too. And session-patterns test - one was s...
- Assistant
All related tests pass. I'll add a changeset and clean up the temp script.
- Assistant
Checking typecheck exit code and running more of the engine test suite.
- Assistant
All 317 engine tests pass. Reviewing the final diff for quality.
- Assistant
Moving
isCronSessionKeyto a non-exported helper so we don't introduce a new public interface. - Assistant
Now I'll add a module-level private function in engine.ts and remove the import.
- Assistant
Need to open engine.ts first.
- Assistant
Restore import and add local helper.
- Assistant
Add isCronSessionKey as a module-private function near the constants.
- Assistant
session-patterns.ts should be back to original. Let me verify and re-run the verification script quickly plus key engine tests.
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 →