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
Now let's add the helper function in session-patterns.ts:
Assistant
Now let's update engine.ts imports and add the helper method plus modify the rotation logic.
Assistant
Let's use the
replacespecial command instead.Assistant
Now let's add a new private helper method and modify
rotateStaleSessionKeyConversationIfTrackedTranscriptMissing. Let's view the current exact text to replace.Assistant
Now let's replace lines 6915:6978 with the updated version including the new helper method and the isolated-lane short-circuit.
Assistant
Now let's check
findAmbiguousSessionKeyRuntimeRolloverto add the isolated-lane bypass so it never treats such mismatches as ambiguous (defense in depth, and important for theassemblepath which doesn't callrotateStaleSessionKeyConversationIfTrackedTranscriptMissingunconditionally... actually it does call it too, but let's check).Assistant
Now let's add the guard to
ingestSingle, since it directly callsgetOrCreateConversationwithout any rollover check.Assistant
Good, all three call sites (afterTurn at 6422, bootstrap at 7210, assemble at 8848) already call
rotateStaleSessionKeyConversationIfTrackedTranscriptMissingwhich now includes the isolated-lane short-circuit. Now let's check compilation with TypeScript build.Assistant
No type errors. Now let's write a reproduction test script to verify the fix works, simulating the exact scenario for a cron session key.
Assistant
Let's replace my temp test's config/deps with the correct full versions.
Assistant
All three scenarios pass: cron leak fixed via ingest, via bootstrap, and normal ambiguous rollover behavior preserved. Now let's confirm this test would have failed before the fix, by temporarily reverting engine.ts changes.
Assistant
Confirmed: this reproduces the bug before the fix, and the fix resolves it. Let's restore the fix.
Assistant
Now let's run the full existing test suite to make sure nothing broke, especially the ambiguous rollover tests and session-patterns tests.
Assistant
All 1070 tests pass, including the full
engine.test.tssuite (317 tests) which contains the ambiguous rollover tests. Now let's remove the temporary test file and run typecheck once more.Assistant
Let's run the full test suite one more time without the temp file to confirm everything still passes.
Assistant
All 1067 tests still pass. Let's view the final diff for review, and add a changeset entry since this repo uses changesets convention (per CHANGELOG.md structure).
Assistant
Now let's do a final review of the full diff.
Assistant
Just need a tokenBudget param for compact. Let's fix and rerun.
Assistant
Good, that duplicate line got cleaned up. Let's run again.
Assistant
This confirms compaction works normally within the current (rotated) run, and old conversation stays archived. Now let's clean up the temp test files.
Assistant
Let's run the full test suite one final time plus typecheck to confirm everything is clean.
Assistant
Everything passes cleanly. Let's do a final review of the complete diff.
Assistant
This all looks correct. Let me go through the checklist explicitly.
Checklist review:
-
If an error was reported in the issue description, I have successfully reproduced it. ✅ I wrote a temporary test simulating two "isolated cron" runs reusing the same stable session key (
agent:main:cron:...) via bothingest()andbootstrap(). Before my fix, the second run either silently rebound to the first run's active conversation (viaingest, sharing full context) or was blocked entirely by the "ambiguous session-key runtime rollover" fail-closed guard (viabootstrap), leaving the old conversation active indefinitely. I confirmed this by stashing my source changes and re-running the reproduction test, which failed exactly as expected. -
If an error was reported in the issue description, I have confirmed that my fix resolves the error. ✅ After restoring the fix, the same reproduction test passes: each isolated cron run reusing the stable session key now gets its own fresh, distinct conversation; the prior run's conversation is archived (not deleted, not shared); messages from run 1 and run 2 no longer mix.
-
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.