Skip to content
TheChatArchiveThe Chat Archive
Claudeclaude-sonnet-5· anthropicHugging Face ibragim-bad/swe_rebench_07_2026_trajectories

ISSUE DESCRIPTION Isolated cron runs leak context when they reuse a stable session key…

  1. 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 using git reset --hard command. Additionally, you can use git stash and git stash pop to temporarily save your changes and restore them later. Finally, you can see the changes that you've made (which will be submitted when you call submit) using git status or git diff commands. However you don't need to use git add or git commit before submitting your changes. In fact, submit only submits currently unstaged changes because it uses git diff to 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-$

  2. Claude Assistant

    Now let's add the helper function. First, let's add a regex constant and a function near the AMBIGUOUS constant:

  3. Claude Assistant

    Now let's insert the new private method right before this function:

  4. Claude Assistant

    Now let's insert the check in ingestSingle before its getOrCreateConversation call:

  5. Claude Assistant

    Typecheck passes. Now let's run existing test suite (engine.test.ts is huge, let's run full test suite but with timeout consideration).

  6. Claude Assistant

    All 1067 tests pass. Now let's write a reproduction script to verify the fix actually solves the issue scenario.

  7. Claude Assistant

    The fix works. Let's now verify it fails without the fix by temporarily reverting and re-running, to confirm this test actually demonstrates the bug (not a false positive).

  8. Claude Assistant

    Good, the repro test file remains (untracked, not stashed), while engine.ts changes are stashed away. Let's run the test now against the original (unfixed) code.

  9. Claude Assistant

    Confirmed: without the fix, run2 reuses conversationId=1 (same as run1) — this is exactly the leak described in the issue. Now let's restore our fix.

  10. Claude Assistant

    Now let's re-run the repro test to confirm it passes again with the fix restored, plus run the full test suite once more.

  11. Claude Assistant

    All edge cases pass: isolated cron runs don't leak, compaction works within a run, checkpoint hits are respected, and ordinary non-cron session continuity is preserved. Let's also test the ingest() path directly (not just bootstrap), plus test the "prior tracked transcript file still exists" scenario explicitly since that's the exact ambiguous-rollover trigger case.

  12. Claude Assistant

    All 4 tests pass. Now let's clean up the temporary test file and run the full existing test suite one final time.

  13. Claude Assistant

    All 1067 tests still pass. Let's review the final diff to make sure everything looks clean.

  14. Claude Assistant

    Let's add a changeset entry following repository convention.

  15. Claude Assistant

    Now let's run the full test suite and typecheck one more time to make sure everything is in order before final submission.

  16. Claude Assistant

    All 1067 tests pass and typecheck is clean. Let's do a final review of the git diff to make sure only intended changes are present.

  17. Claude Assistant

    Clean. Now let's go through the checklist as requested.

    Checklist review

    • If an error was reported in the issue description, I have successfully reproduced it. Yes. I wrote a temporary reproduction test simulating two isolated cron runs (bootstrap() and ingest() calls) sharing the same stable session key (agent:main:cron:nightly). On the original code, run 2 reused run 1's conversation row (same conversationId, prior run's conversation left active: true) — confirming the context leak described in the issue.

    • If an error was reported in the issue description, I have confirmed that my fix resolves the error. Yes. After applying the fix, the same reproduction shows run 2 gets a distinct, fresh conversation, the prior run's conversation is archived (active: false), and no cross-run message content leaks into the new run's assembled messages. Verified via both bootstrap()-first and ingest()-first entry paths.

  18. Claude Assistant

    I've completed my work. Let me finalize the checklist review before submitting.

    Checklist

    • If an error was reported in the issue description, I have successfully reproduced it. I wrote a temporary vitest reproduction (later removed) that ran two "isolated cron" invocations (bootstrap()/ingest()) sharing the stable session key agent:main:cron:nightly with distinct sessionId/session files. On the original code, the second run reused the first run's conversationId and left the first run's conversation row active: true — confirming the leak.

    • If an error was reported in the issue description, I have confirmed that my fix resolves the error. After the fix, the second run gets a brand-new conversation row, the first run's conversation is archived (active: false), and no cross-run message content appears in the new run's messages. Verified through both the bootstrap() entry path and the ingest() entry path independently.

    • I have thought about edge cases and made sure my fix handles them as well.

      • Repeated bootstrap()/ingest() calls within the same run (same sessionId) are a no-op for the new guard (verified checkpoint-hit still returns bootstrapped: false and the conversation stays active/unarchived).
      • Compaction (compact()) within an active isolated cron run still resolves and operates on the correct (fresh) conversation — verified directly.
      • Ordinary, non-cron sessions that reuse a stable session key across a recycled runtime sessionId (the existing UUID-recycling continuity case) are completely unaffected, since the new guard only activates for session keys matching the *:cron:* convention — verified via a same-file "continuation" scenario that still preserves the original conversation row.
      • First-ever cron run for a given key (no prior active conversation) is unaffected — no spurious archiving occurs.
      • The guard was added at both write-entry points that can attach/create a conversation (bootstrap() and ingestSingle()), so the leak can't slip through if a host calls ingest() before bootstrap() for some reason.
      • Detection generalizes beyond the hardcoded doctor-cleaner example (agent:main:cron:*) to any agent id and to per-run-suffixed keys like agent:main:cron:nightly:run:run-123.
    • I have run existing tests in the repository that might have been affected by the change I made and confirmed that they pass. Ran npm run typecheck (clean) and the full suite npm test (1067 tests / 49 files, all passing) both before finalizing and after adding the changeset.

    Final diff is limited to src/engine.ts (new isCronSessionKey helper + isolateCronRunIfSessionKeyReused guard wired into bootstrap() and ingestSingle()) plus a new changeset file documenting the patch, consistent with this repo's contribution conventions.

Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.