diff --git a/apps/backend/internal/agent/agents/codex_acp.go b/apps/backend/internal/agent/agents/codex_acp.go index c10081c139..a373cf39b4 100644 --- a/apps/backend/internal/agent/agents/codex_acp.go +++ b/apps/backend/internal/agent/agents/codex_acp.go @@ -88,13 +88,19 @@ func (a *CodexACP) Runtime() *RuntimeConfig { Env: map[string]string{}, Mounts: []MountTemplate{ {Source: "{workspace}", Target: "/workspace"}, - {Source: "{home}/.codex", Target: "/root/.codex"}, }, ResourceLimits: ResourceLimits{MemoryMB: 4096, CPUCores: 2.0, Timeout: time.Hour}, Protocol: agent.ProtocolACP, SessionConfig: SessionConfig{ NativeSessionResume: true, CanRecover: &canRecover, + // Use the same SessionDirTemplate pattern every other ACP agent + // uses; the docker container manager wires this into a kandev-owned + // per-container session dir, isolated from the host's ~/.codex + // (which carries host-absolute rollout paths in state.db that + // don't resolve inside the container). + SessionDirTemplate: "{home}/.codex", + SessionDirTarget: "/root/.codex", }, } } diff --git a/apps/backend/internal/agent/agents/codex_acp_test.go b/apps/backend/internal/agent/agents/codex_acp_test.go new file mode 100644 index 0000000000..1ea17754f0 --- /dev/null +++ b/apps/backend/internal/agent/agents/codex_acp_test.go @@ -0,0 +1,29 @@ +package agents + +import ( + "strings" + "testing" +) + +func TestCodexACPRuntimeNoLongerBindMountsHostHome(t *testing.T) { + a := NewCodexACP() + rt := a.Runtime() + + for _, m := range rt.Mounts { + if strings.Contains(m.Source, "{home}") { + t.Fatalf("codex Mounts unexpectedly references {home}: %+v", m) + } + } +} + +func TestCodexACPSessionDirTemplate(t *testing.T) { + a := NewCodexACP() + cfg := a.Runtime().SessionConfig + + if cfg.SessionDirTemplate != "{home}/.codex" { + t.Fatalf("SessionDirTemplate = %q, want %q", cfg.SessionDirTemplate, "{home}/.codex") + } + if cfg.SessionDirTarget != "/root/.codex" { + t.Fatalf("SessionDirTarget = %q, want %q", cfg.SessionDirTarget, "/root/.codex") + } +}