Skip to content

Run environment:none codex Sessions in their private home - #304

Merged
SaladDay merged 1 commit into
mainfrom
fix/codex-environment-none-cwd
Sep 30, 2026
Merged

SaladDay merged 1 commit into
mainfrom
fix/codex-environment-none-cwd

Conversation

@SaladDay

@SaladDay SaladDay commented Sep 30, 2026 •

Copy link
Copy Markdown
Collaborator

When a codex Session with environment:none has no public MCP server, it now runs in its own private CODEX_HOME. Before this change it ran in the daemon process's directory, and native recovery always failed.

Root cause: prepareSessionPlan set plan.Cwd only for LocalEnvironment requests. For environment:none, configureMCP filled the empty cwd with CODEX_HOME, but only when MCP was configured. Without MCP, recoverRoot (which requires an absolute cwd) rejected every recovery before it reached thread/list, and codex ran in whatever directory the daemon started from.

Fix (codex adapter only):

  • prepareSessionPlan sets plan.Cwd to the Session's private CODEX_HOME for environment:none. Existing none+MCP threads already recorded that same cwd, so their recovery still matches.
  • Deleted the empty-cwd fallback in configureMCP.
  • The four CODEX_HOME readers are now one, nativeHomeFromPlan. It returns the last entry, which is the value os/exec actually passes. Before, one reader took the first entry.

Checks

  • TestPreparedRecoveryCannotStartWithoutExistingHistory now has none and local subtests. On main, none fails with cwd = "".
  • go build ./..., go vet ./apps/daemon/..., go test ./apps/daemon/...: all pass.

View with [code]smith Autofix with [code]smith
Need help on this PR? Tag @codesmith-bot with what you need. Autofix is disabled.

@SaladDay
SaladDay merged commit a17d731 into main Sep 30, 2026
@SaladDay
SaladDay deleted the fix/codex-environment-none-cwd branch September 30, 2026 15:55
For environment:none, prepareSessionPlan left SessionPlan.Cwd empty unless
public MCP was configured, where configureMCP filled it with CODEX_HOME. Without
MCP, codex ran in the daemon process's working directory and recoverRoot, which
requires an absolute cwd, failed every existing-history recovery.

prepareSessionPlan now sets the cwd explicitly for environment:none to the
Session's private CODEX_HOME, which the adapter allocates from the Runtime's
AgentStateKey. That matches the cwd existing none+MCP threads recorded. The
configureMCP fallback is deleted, and the four CODEX_HOME readers share
nativeHomeFromPlan, which returns the last entry, the value os/exec passes.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant