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 look at the AGENTS.md and search for cron-related code and LCM context.
- Assistant
Let me search more specifically for isolated cron and session key related code.
- Assistant
rg is not available, let me use grep instead.
- Assistant
Hmm the grep returned empty. Let me try without the -g flag and check properly.
- Assistant
Let me dig deeper into engine, sessions and related tests for context leakage with cron.
- Assistant
There's mention of archiveConversation and lifecycle. Let me look at the engine around lifecycle, isolated context mode, and return/creation of conversations when session keys are reused.
- Assistant
There's
isStatelessSessionwhich seems important. Also archive lifecycle. Let me read those functions more carefully. - Assistant
Let me look at CHANGELOG and recent commits related to isolated cron. Also conversation store getOrCreateConversation.
- Assistant
There's a changeset about "Fail closed when a stable session key resumes under a new runtime session and transcript while the prior tracked transcript still exists." and stale-session-key-rollover. The issue is about isolated cron runs that reuse a stable session key leaking context.
Let me look for how isolate cron works and the assemble path when sessions restart.
- Assistant
Looking at the issue more carefully:
- Assistant
Let me look at git history for more breadcrumbs and also look for how session end / start words for cron. Also look at session-end handlers.
- Assistant
Let me look at the session-file rollover logic more carefully - specifically
maybeRotateStaleSessionKeyConversationaround line 6912. The issue is that isolated cron runs might reuse the same sessio... - Assistant
Let me look at git log for related PRs and also search for any TODOs or issue references about isolated cron.
- Assistant
Let me look at how session keys for cron are structured and how assemble gets conversation. The issue says "isolated cron runs" - possibly when cron runs with session key like
agent:main:cron:job-id(stable for t... - Assistant
Let me examine how conversations are resolved during assemble and getOrCreate.
- Assistant
Let me look for any pending tests or comments about this specific issue.
- Assistant
I'll check how agent session keys are parsed and where rollover is invoked so I can implement cron-specific rotation.
- Assistant
I'll inspect the bootstrap rotation call sites and how session keys for subagents are classified.
- Assistant
Looking at isSubagentSessionKey check - they use
sessionKey.includes(":subagent:"). Forcron,sessionKey.includes(":cron:")` would work similarly. - Assistant
I'll implement cron runtime-change rotation and verify it with a temporary reproduction script. First, inspecting test helpers.
- Assistant
Checking the compact path and other session lookup entry points that need the same guard.
- Assistant
Implementing isolated-cron runtime rotation in the engine.
- Assistant
Inserting the new helper methods and wiring them into bootstrap, assemble, and afterTurn.
- Assistant
Now wiring the new method into the three lifecycle call sites.
- Assistant
Let me read each call site and update them.
- Assistant
Oops, sed uses commas not colons.
- Assistant
I'll update all three sites to call the cron rotation before the stale rotation.
- Assistant
Good. Now bootstrap and assemble.
- Assistant
The bootstrap edit looks broken — checking and fixing it.
- Assistant
Yes, the ambiguousRollover assignment was partially deleted. I need to fix it.
- Assistant
Bootstrap looks good. Updating assemble next.
- Assistant
The assemble section got mangled — restoring the full lifecycle guard block.
- Assistant
I need to replace lines 8827-8852 with the correct block.
- Assistant
Writing a temporary verification script and a changeset, then running related tests.
- Assistant
I'll use a temporary script outside the repo so I don't add repository tests.
- Assistant
Need to run from the repo so node_modules resolves.
- Assistant
The issue is that the script is in /tmp so node resolves modules from /tmp. Let me put the script in the repo root as a temp file and delete later.
- Assistant
Verification passed. Cleaning up the temp script, adding a changeset, and running related tests.
- Assistant
All relevant tests passed. Running typecheck and a broader engine test subset next.
- Assistant
Hardening ingest so a direct write path can't rebind a prior cron conversation when runtime changes.
- Assistant
The line numbers got confused because maintain is above ingestSingle. Let me find the exact ingestSingle getOrCreate line.
- Assistant
I'll add the rotate call before getOrCreate in ingestSingle. ingest is always queued by session key so it's fine.
- Assistant
Using a clearer phase label for the ingest path.
- Assistant
Need to open the file at that line first or use sed.
- Assistant
Let me replace the phase type and the ingest call phase.
- Assistant
Update ingest phase to "ingest"
- Assistant
Also guarding compact against rebinding prior cron context.
- Assistant
I'll add "compact" phase and rotate before get conversation in compact.
- Assistant
Add rotate inside compact queue callback.
- Assistant
Re-running verification and the related tests.
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.