Skip to content
TheChatArchiveThe Chat Archive
DeepSeekdeepseek/deepseek-v4-pro· deepseekHugging 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. DeepSeek Assistant

    Let me start by understanding the repository structure and the issue. The issue mentions "isolated cron runs", "stable session key", "LCM context", and "compaction". Let me explore the repository to understand what this is about.

    This seems to be a project related to LLM/agent systems - perhaps related to "LangChain" or similar. Let me look at the structure first.

  3. DeepSeek Assistant

    This is a TypeScript project. Let me look at the source code structure and understand what it's about.

  4. DeepSeek Assistant

    Let me search for relevant terms related to the issue - "cron", "isolated", "LCM", "session key

  5. DeepSeek Assistant

    Let me focus on the relevant source files. Let me search for "isolated" and "LCM" in the source code:

  6. DeepSeek Assistant

    Let me look at the relevant parts of the code. The issue involves "isolated" context mode, "cron", "LCM", and "session key". Let me look at engine.ts and openclaw-bridge.ts

  7. DeepSeek Assistant

    Let me search for "contextMode" in engine.ts and openclaw-bridge.ts more specifically

  8. DeepSeek Assistant

    Let me look at the context around line 9275 in engine.ts, and also at openclaw-bridge.ts

  9. DeepSeek Assistant

    Let me keep reading around this area and see the rest of prepareSubagentSpawn.

  10. DeepSeek Assistant

    Now let me understand how contextMode is used in the broader context. Let me look at resolveConversationIdForSessionKey and the compaction logic more closely

  11. DeepSeek Assistant

    Let me look at resolveConversationIdForSessionKey around line 4752.

  12. DeepSeek Assistant

    Let me look at openclaw-bridge.ts around the contextMode area

  13. DeepSeek Assistant

    Let me search for contextMode usage across the entire source code

  14. DeepSeek Assistant

    Let me look at the bootstrap method in engine.ts

  15. DeepSeek Assistant

    Let me look at the bootstrap method.

  16. DeepSeek Assistant

    Let me continue reading bootstrap method

  17. DeepSeek Assistant

    Let me look at the plugin index.ts for how cron and isolated sessions are handled

  18. DeepSeek Assistant

    Let me look at the plugin/index.ts around line 1528

  19. DeepSeek Assistant

    Let me look at the compaction.ts file to understand the flow

  20. DeepSeek Assistant

    Let me search for "archive" and "replace" in the source code

  21. DeepSeek Assistant

    Let me search for how the issue might manifest - how does the engine decide whether to reuse an existing conversation vs create a fresh one

  22. DeepSeek Assistant

    Let me look at applySessionReplacement and rotateStaleSessionKeyConversationIfTrackedTranscriptMissing

  23. DeepSeek Assistant

    Let me continue reading handleBeforeReset

  24. DeepSeek Assistant

    Let me look at rotateStaleSessionKeyConversationIfTrackedTranscriptMissing

  25. DeepSeek Assistant

    Let me look at the rotate method

  26. DeepSeek Assistant

    Let me look at the assemble method in engine.ts to see how context is assembled

  27. DeepSeek Assistant

    Let me look at the assemble method.

  28. DeepSeek Assistant

    Let me look at the afterTurn method to see how context is persisted

  29. DeepSeek Assistant

    Let me look at afterTurn

  30. DeepSeek Assistant

    Let me look more carefully at how the contextMode parameter flows from the host runtime into the engine. Let me look at the plugin wiring

  31. DeepSeek Assistant

    Let me look at how the plugin wires the engine methods

  32. DeepSeek Assistant

    Let me search for prepareSubagentSpawn in the entire source code

  33. DeepSeek Assistant

    Let me look at the test for prepareSubagentSpawn around line 7012

  34. DeepSeek Assistant

    Let me look at the test for prepareSubagentSpawn around line 645

  35. DeepSeek Assistant

    Let me look at how the host runtime passes the contextMode to the LCM plugin. Let me search for how the runtime might call the LCM engine with context mode

  36. DeepSeek Assistant

    Let me look at the bootstrap interface in openclaw-bridge.ts more carefully

  37. DeepSeek Assistant

    Let me look at the expansion-auth.ts file to understand how grants work

  38. DeepSeek Assistant

    Let me look at the specs directory for more context about the expected

  39. DeepSeek Assistant

    Let me look at the test file related to engine, specifically around the area that tests contextMode or isolated behavior

  40. DeepSeek Assistant

    Let me look at the conversation store to understand getOrCreateConversation and `getConversationForSession

  41. DeepSeek Assistant

    Let me look at conversation-store

  42. DeepSeek Assistant

    Let me look at the conversation store's getOrCreateConversation

  43. DeepSeek Assistant

    Let me look at how the plugin wires the engine to the host runtime

  44. DeepSeek Assistant

    Let me look at line 1464 in plugin/index.ts

  45. DeepSeek Assistant

    Let me look at handleSessionEnd

  46. DeepSeek Assistant

    Let me look at `getConversationBySessionKey

  47. DeepSeek Assistant

    Let me look at the SubagentSpawnPreparation type and how it's

  48. DeepSeek Assistant

    Let me look at the type definition

  49. DeepSeek Assistant

    Let me check how the grant is used for expansion - look at the expansion tool

  50. DeepSeek Assistant

    Let me look at lcm-conversation-scope.ts

  51. DeepSeek Assistant

    Let me search for isSubagentSessionKey

  52. DeepSeek Assistant

    Let me look at the plugin implementation of `isSubagentSessionKey

  53. DeepSeek Assistant

    Let me look at `parseAgentSessionKey

  54. DeepSeek Assistant

    Let me search properly

  55. DeepSeek Assistant

    Let me look at it

  56. DeepSeek Assistant

    Let me look at `shared-init.ts

  57. DeepSeek Assistant

    Let me check the git log for recent changes related to

  58. DeepSeek Assistant

    Let me check for commits related to contextMode or isolated cron

  59. DeepSeek Assistant

    Let me check the changeset directory for hints about

  60. DeepSeek Assistant

    Let me read the changeset files that seem related

  61. DeepSeek Assistant

    Let me look at AGENTS.md for project context

  62. DeepSeek Assistant

    Let me now look at the full prepareSubagentSpawn implementation to understand all the code paths and implement

  63. DeepSeek Assistant

    Let me look at the test for prepareSubagentSpawn more carefully to understand the expected

  64. DeepSeek Assistant

    Let me look at the test cases for prepareSubagentSpawn at lines 645, 1187, 1670, and 7012

  65. DeepSeek Assistant

    Let me look at the test at line 1670

  66. DeepSeek Assistant

    Now I have a clear understanding of the issue. The prepareSubagentSpawn method in engine.ts has a contextMode parameter that is completely ignored in the implementation. When contextMode is "isolated", the method should NOT create a grant that gives the child access to the parent's LCM context. Currently, it always resolves the parent's conversation and creates a grant with allowedConversationIds: [conversationId], leaking the parent's context to isolated cron sessions.

    Let me first create a script to reproduce the issue

  67. DeepSeek Assistant

    Let me fix the script

  68. DeepSeek Assistant

    Let me implement the fix. The issue is clear: prepareSubagentSpawn ignores contextMode. When contextMode is "isolated", the method should not create a grant linking the child to the parent's conversation

  69. DeepSeek Assistant

    Let me use the replace command instead

  70. DeepSeek Assistant

    Let me open the file at the right line first

  71. DeepSeek Assistant

    Let me use sed to make the change

  72. DeepSeek Assistant

    Now let me insert the isolated check after line 9296

  73. DeepSeek Assistant

    Let me use nl or cat -n to see exact line numbers

  74. DeepSeek Assistant

    Line 9290 is this.ensureMigrated(); Lines 9292-9296: child/parent session key trim + check Line 9297 is } Line 9298 is blank Line 9299 is const conversationId = await this.resolveConversationIdForSessionKey(parentSessionKey);

    I need to insert after line 9297 (the closing brace of the if (!childSessionKey || !parentSessionKey) block):

        // Isolated sessions do not inherit the parent's LCM context.
        if (params.contextMode === "isolated") {
          return undefined;
        }
    

    Let me use sed to insert after line 9297.

  75. DeepSeek Assistant

    Let me verify the

  76. DeepSeek Assistant

    The change looks correct. Now let me run the existing tests to make sure nothing breaks

  77. DeepSeek Assistant

    All 317 tests pass. Let me also run the other test files to make sure nothing is broken

  78. DeepSeek Assistant

    All 1067 tests pass. Let me verify the change once more

  79. DeepSeek Assistant

    The fix is clean and correct. Let me verify the logic one more time by checking the complete prepareSubagentSpawn method after the change:

  80. DeepSeek Assistant

    The fix looks correct. Let me also clean up the extra blank line and then submit

  81. DeepSeek Assistant

    Let me verify the final state and run tests one final time

  82. DeepSeek Assistant

    Clean diff. Let me run the tests one final time to confirm

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