fix(execenv): clean stale Codex memories on env reuse (fixes #3130)#3147
Open
kagura-agent wants to merge 1 commit into
Open
fix(execenv): clean stale Codex memories on env reuse (fixes #3130)#3147kagura-agent wants to merge 1 commit into
kagura-agent wants to merge 1 commit into
Conversation
…ai#3130) prepareCodexHomeWithOpts now removes the memories/ directory before seeding the per-task CODEX_HOME. On the Prepare path this is a no-op (the entire envRoot is already wiped). On the Reuse path it prevents a prior task's raw_memories.md from leaking into the new task's Codex context, which caused cross-task and cross-project memory contamination.
|
@kagura-agent is attempting to deploy a commit to the IndexLabs Team on Vercel. A member of the Team first needs to authorize it. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Fixes #3130 — reused
CODEX_HOMEleaks stale memories from a prior task into unrelated issue assignments.Root Cause
prepareCodexHomeWithOpts()seeds a per-taskCODEX_HOMEwith symlinks (auth, sessions) and copied config files, but never clears Codex-generated runtime state. On the Prepare path this doesn't matter becausePrepare()nukes the entireenvRootfirst. On the Reuse path (whentask.PriorWorkDiris set for the same agent+issue pair), the oldcodex-home/memories/directory — containingraw_memories.mdand summaries from a prior task — persists and gets injected into the new task's Codex context.This can cause cross-task and cross-project memory contamination, where a new issue receives stale project-specific instructions, architecture assumptions, and paths from a deleted project.
Changes
server/internal/daemon/execenv/codex_home.go: Addos.RemoveAll(memories/)at the start ofprepareCodexHomeWithOpts(), afterMkdirAlland before symlink/copy seeding. On Prepare this is a harmless no-op; on Reuse it prevents stale memory leakage.server/internal/daemon/execenv/codex_home_memories_test.go: Two new tests:TestPrepareCodexHome_CleansStaleMemories: seeds a stalememories/raw_memories.md, runsprepareCodexHome, verifies the directory is removed.TestPrepareCodexHome_NoMemoriesDir_NoError: verifies no error whenmemories/doesn't exist (fresh task path).Testing