feat(codex): read the profile from a nominated CODEX_HOME - #9
Merged
Conversation
A caller could point claudecode at its own configuration directory and had no way to say the same thing to codex, so a run authenticated as whoever the ambient environment happened to point at. CODEX_HOME redirects the whole Codex profile rather than settings alone: the credential lives in $CODEX_HOME/auth.json, which is why --ignore-user-config still honours the variable. Two consequences shape this. HOME is left alone. The claudecode dialect overrides it because a Node program writes its cache beside its config; codex resolves everything from CODEX_HOME, so overriding HOME would redirect nothing extra and would silently defeat Driver.WithHome. CODEX_HOME is denied only when the dialect does not set it. buildEnv scrubs the assembled environment, dialect variables included, so an unconditional entry would strip the caller's own nomination and leave the option inert under exactly the credentials mode that most needs it — the claudecode dialect omits CLAUDE_CONFIG_DIR for the same reason. With no directory nominated there is nothing to protect and the backstop applies. A profile holding a session outranks the token Isolated injects: codex uses the session and never attempts OPENAI_API_KEY. Recorded in CONTEXT.md as an ambiguity between the two providers rather than left for a caller to discover through a run billed to the wrong account.
|
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.
claudecodehasWithConfigDir;codexhad no equivalent, so a caller could not say which account a run should authenticate as. Inagtk, wherememory.agentaccepts either provider, curation on codex used whatever profile the ambient environment happened to point at.codex.WithConfigDir(dir)now exportsCODEX_HOME, from bothNewandNewOnPath.Three decisions, settled against codex-cli 0.153.4 rather than by symmetry
HOME is not overridden.
claudecodeoverrides it because a Node program writes its cache beside its config. Codex resolves its whole profile fromCODEX_HOMEalone, so overridingHOMEwould redirect nothing extra and would silently defeatDriver.WithHome.codex exec --helpdocuments--ignore-user-configas "Do not load$CODEX_HOME/config.toml; auth still usesCODEX_HOME".CODEX_HOMEis denied only when the dialect does not set it. Adding it unconditionally — the obvious reading — breaks the feature:buildEnvscrubs the assembled environment includinginv.Env, so an unconditional entry strips the caller's own nomination and leaves the option inert underIsolated, the mode that most needs it. Verified by making it unconditional, at which pointTestAnIsolatedChildGetsTheNominatedConfigDirfails withCODEX_HOME = "". Theclaudecodedialect omitsCLAUDE_CONFIG_DIRfrom its own list for the same reason. With no directory nominated there is nothing to protect and the backstop applies.A profile session outranks the injected token. With a valid session in
CODEX_HOMEand a deliberately fakeOPENAI_API_KEY, a run succeeds with no401at all — the key is never attempted. So pair a nominated profile holding a session withAmbient, andIsolatedwith one that holds none. Recorded inCONTEXT.mdunder Flagged ambiguities, since the same option redirects a different amount in each provider.Tests
Seven, asserting the environment the child is actually given via
agentictest.Fake.Recorded, not merely whatStreamCommandasks for — the distinction is the scrub.CODEX_HOMEinherited from the parent never reaches an isolated child, while the injectedOPENAI_API_KEYdoesHOMEstays the driver'sCODEX_HOMEFull suite green. A caller that nominates nothing gets exactly the environment it got before.