Run environment:none codex Sessions in their private home - #304
Merged
Merged
Conversation
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.
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.
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:
prepareSessionPlansetplan.Cwdonly for LocalEnvironment requests. For environment:none,configureMCPfilled 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 reachedthread/list, and codex ran in whatever directory the daemon started from.Fix (codex adapter only):
prepareSessionPlansetsplan.Cwdto the Session's private CODEX_HOME for environment:none. Existing none+MCP threads already recorded that same cwd, so their recovery still matches.configureMCP.nativeHomeFromPlan. It returns the last entry, which is the value os/exec actually passes. Before, one reader took the first entry.Checks
TestPreparedRecoveryCannotStartWithoutExistingHistorynow hasnoneandlocalsubtests. On main,nonefails withcwd = "".go build ./...,go vet ./apps/daemon/...,go test ./apps/daemon/...: all pass.Need help on this PR? Tag
@codesmith-botwith what you need. Autofix is disabled.