Skip to content

fix(codex): Orca-owned Codex homes never start Codex's shared background server - #23924

Closed
brennanb2025 wants to merge 9 commits into
mainfrom
brennanb2025/codex-owned-home-no-shared-server
Closed

brennanb2025 wants to merge 9 commits into
mainfrom
brennanb2025/codex-owned-home-no-shared-server

Conversation

@brennanb2025

@brennanb2025 brennanb2025 commented Sep 29, 2026 •

Copy link
Copy Markdown
Contributor
Files Added Deleted Net
Test 14 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​153 $\color{#cf222e}{\Huge{\mathbf{−}}}$​116 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​37
Prod 10 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​256 $\color{#cf222e}{\Huge{\mathbf{−}}}$​182 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​74

ELI5

Since Codex 0.156, the first codex you start runs one shared background program, and every later Codex quietly plugs into it. That shared program keeps the first tab's identity, dies when the first tab closes, and on Windows opens a new console window for every command or hook it runs. Orca's merged #23900 stops this for Codex started through Orca's shells, but not for Codex started in cmd.exe tabs, scripts or Quick Commands. This PR turns the shared program off in the Codex settings folders Orca itself owns, so no Codex launched there can start it, however it was launched.

What Changed

The problem users see (Windows especially): in an Orca cmd.exe tab running Codex 0.157+, windows pop open every time Codex runs a hook or command, including right after starting Codex or interrupting it. It was recorded on 1.4.217 in cmd.exe; PowerShell and Git Bash were already fixed by #23900. In the same tabs, a second Codex reports as the first one, and closing the first tab ends the others. Scripts and Quick Command wrappers that call Codex directly behave the same way on every platform, for anyone using an Orca-managed Codex account.

Scope: Codex homes Orca owns: the managed runtime home, managed account homes, resume homes and WSL managed homes. On native Windows every local pane uses an Orca-owned home, so there it covers every local pane. Not affected: your own ~/.codex (never written; the config mirror refuses a target whose normalized path is the source home), Codex older than 0.156 (it ignores the setting), and SSH hosts. Not covered: panes that use your own home, namely the default account on macOS and Linux when it runs on your real ~/.codex, and WSL panes with no WSL managed account. There only #23900's shell function applies, so cmd-style and script launches still start the shared program.

Before: Orca wrote features.daemon_auto_start = false into its homes only when the socket path was too long for the OS (the guard from #22878). That's why macOS managed homes mostly escaped and Windows/Linux homes didn't.

After: every Orca-owned home always gets features.daemon_auto_start = false, marked as Orca's line. A true mirrored in from your ~/.codex, for example from Codex 0.156's /experimental menu, is overridden in Orca's homes and logged once per home; ~/.codex itself is untouched. Orca's line keeps the same marker comment earlier builds wrote, so a downgraded Orca still recognizes and strips it. The inline-table warning now tells you to convert features = {...} to a [features] table instead of editing ~/.codex.

Mechanism: the existing guard's condition is widened rather than a second mechanism added. It no longer depends on the socket path's length: every caller already passes a home Orca owns (the parameter is now orcaOwnedHomePath), and the config mirror refuses a target whose normalized path is the source home. The guard is renamed from a socket-path guard to applyCodexDaemonAutoStartOverride / ensureCodexDaemonAutoStartOverride.

Why

Codex will fix the console windows itself. Codex's main branch now opens hooks and git without a console window. It's expected in Codex 0.160/0.161 and isn't in any release up to 0.160.0-alpha.2. So the windows are a side benefit of this PR until users update. The main reason for this PR is the shared-server identity bugs, which Codex's console fix doesn't change: in cmd.exe tabs, scripts and Quick Commands, a second Codex reports as the first one, and closing the first tab ends the others. #23900 fixed these for PowerShell, Git Bash, bash, zsh and fish, but it can't reach those launch paths.

  • One setting reaches every launch path. The shared program is started by Codex itself, so a setting in the Codex home it reads covers cmd.exe tabs, scripts, absolute paths, npx and user command overrides, which a shell function can't. This backs up fix(terminal): run Codex in Orca terminals without the shared background server #23900's --no-daemon; it doesn't replace it.
  • No flag or env var does this. Codex has no environment variable that turns the shared program off, and adding --no-daemon host-side would still miss scripts and hand-typed launches in cmd.exe.
  • Not waiting on Codex. Codex's main branch has since stopped opening console windows for hooks and git, but no Codex release up to 0.160.0-alpha.2 has it, and the wrong-tab identity problem is in Codex's design.
  • Limit (known, not fixed here): the setting stops Codex starting a shared program but not joining one that's already running. codex agents, codex remote-control start and codex app-server daemon start start one regardless. A leftover program from before the update keeps serving until it exits.
  • Trade-off (same as fix(terminal): run Codex in Orca terminals without the shared background server #23900): Codex's "Run in background" doesn't outlive the tab, and codex agents doesn't see sessions in Orca-owned homes.
  • No opt-out in Orca-owned homes (differs from fix(terminal): run Codex in Orca terminals without the shared background server #23900): ORCA_CODEX_ISOLATE=0 still makes the shell function skip --no-daemon, but it no longer brings the shared program back in an Orca-owned home, because the home's setting keeps auto-start off. Orca doesn't pass -c features.daemon_auto_start=true for it: in long homes (macOS managed accounts) the shared program can't bind its socket, and Codex exits when that start fails. The opt-out still applies in your own ~/.codex.

Linked Issue

Refs #22974 (Codex refusing to start in cmd.exe; it may no longer reproduce with Codex 0.159, so the Windows QA will check)

Related: #23591, #23518, #23240, #22836, #22217, #22873

Visual Proof

Pending. The review loop runs live QA on the Windows high spec machine (cmd.exe tab, Codex 0.159: start, run a command, interrupt) and will attach before/after recordings here.

Testing

  • I manually tested these changes locally

  • Automated tests added/updated, or explained why not below

  • 66 named test files pass (763 passed, 6 skipped), including real mirror passes that check ~/.codex stays untouched and the override warning fires once. After the review fixes: 47 related codex, account and startup test files, 597 passed; the written marker text is pinned in tests.

  • The key tests fail when the rule is removed: the socket-length check put back, the user-home refusal off, "your value wins" put back.

  • Typecheck clean (node, cli); oxlint, oxfmt and the changed-code quality gate clean.

  • Not yet run live on Windows or Linux. The review loop's QA covers Windows.

AI Disclosure

Review

Agent skill upstream boundary

  • Not applicable, or this change follows docs/reference/agent-skill-sharing-upstream-boundary.md and copies or mechanically translates no upstream skill-installer source, tests, fixtures, registry entries, path tables, comments, or documentation.

Notes

Ensure no issues in: Security, Cross-platoform support (Linux, Windows, Mac), Remote SSH, Mobile, general backwards compatibility, performance

  • Mixed versions: no wire change. Codex 0.155 logs an unknown feature key and continues.
  • A profile-level [profiles.X.features] daemon_auto_start = true or -c features.daemon_auto_start=true still wins; only hand edits produce those. Per launch, codex -c features.daemon_auto_start=true in a short home (Windows, Linux) starts the shared program on purpose.

Checklist

  • This PR is small and focused
  • I explained what changed and why (ELI5, the user-facing before/after, the mechanism, and why over the alternatives)
  • Before/after screenshots or videos attached for UI changes, or N/A with reason
  • Self-reviewed for correctness, security, and performance
  • Cross-platform, SSH/remote, and path/shortcut impact considered (or N/A)
  • pnpm lint, pnpm typecheck, pnpm test, and pnpm build pass (or CI will cover; local preferred)

Problem: since Codex 0.157 the first interactive codex on a CODEX_HOME
starts one shared background server that later sessions join. It runs
every session's hooks and tools with the first tab's Orca environment
(status and orchestration messages land on the wrong tab), dies with
that tab, and on Windows runs without a console so every hook and
command flashes a window. #23900 adds --no-daemon through Orca's codex
shell function, but cmd.exe tabs, scripts and Quick Commands, absolute
paths, npx, "command codex" and user overrides never reach it. Orca
already wrote features.daemon_auto_start = false into the homes it owns,
but only when the socket path was too long to bind, so short managed
homes (every native Windows pane, Linux managed accounts) kept it on.

Change (a backup behind #23900's flag, not a replacement):
- The existing guard now writes daemon_auto_start = false into every
  home Orca owns: the managed runtime home (also the retained legacy
  shared home), managed account homes, resume homes and WSL managed
  homes, on every launch-prep path that already applied it. It never
  writes into a home named .codex (the user's own, host or WSL), and
  strips a stray one there. The marker is reworded; the old marker is
  still recognized so lines written by earlier builds are rewritten or
  stripped as Orca's own.
- The setting stops Codex starting a server, not joining one already
  running (left from before the update, or started by codex agents,
  codex remote-control start or codex app-server daemon start). Launch
  prep (new launches and resumes) now checks the owned home's control
  socket in the background and logs once while a server is live
  (POSIX connect) or may be live (Windows: socket file present; Node
  cannot connect to AF_UNIX there). It never blocks the launch and never
  stops the server. WSL homes are not probed from the host.

Whose setting wins: an explicit daemon_auto_start the user wrote
(in ~/.codex/config.toml, which Orca mirrors in, or set inside the
managed home, e.g. codex features enable) is kept as written, true or
false, because the user asked for it. The one exception is a home whose
socket path is too long to bind, where Orca still forces false as before
(Codex cannot start otherwise). This matches #23900, which lets the
user's explicit choice (ORCA_CODEX_ISOLATE=0, or arguments that need the
server) turn its flag off. ORCA_CODEX_ISOLATE lives in the pane's shell,
which the host cannot read, so it still governs only the --no-daemon
flag: with ORCA_CODEX_ISOLATE=0 alone, owned homes no longer auto-start
a server; setting daemon_auto_start = true in ~/.codex restores it.
Needs owner confirmation.

Trade-off, same as #23900: in Orca-owned homes nothing auto-starts the
shared server, so "Run in background" does not outlive a tab and codex
agents does not see Orca sessions. Older Codex (0.150-0.155) only logs
an unknown feature key; 0.156 has it off by default. No wire change.
Review follow-up to the previous commit.

- Orca-owned homes now always get features.daemon_auto_start = false,
  including over an explicit true mirrored in from ~/.codex (early 0.156
  adopters turned it on from /experimental). Honouring that true would
  bring the shared-server bugs back only for cmd.exe and script launches,
  while #23900's shell function adds --no-daemon regardless of config.
  Orca logs once per home when it overrides a user's true; the user's
  ~/.codex is never changed. The earlier "user value wins" rule is gone.
- The shared-server socket check at launch prep is removed. It only wrote
  a main-process log line; what Orca should do about a leftover server is
  an open owner question for a follow-up.
- The warning for an inline features table now tells users to rewrite it
  as a [features] table instead of adding daemon_auto_start = false to
  ~/.codex, which would also turn the server off in their own terminals.
- The ".codex home" name heuristic is replaced by the caller's ownership:
  every caller passes the mirror's runtime home, which Orca owns, and the
  user's ~/.codex reaches the mirror only as its read-only source. The
  parameter is renamed orcaOwnedHomePath to state that contract.
- Comments now say what is actually new: most account homes were already
  over the socket limit, so the new reach is mainly the shared runtime
  home on Windows, and on Linux when it is not on the real-home lane.
Round-2 review follow-ups.

- syncSystemConfigIntoManagedCodexHome and ensureCodexDaemonSocketGuard now
  refuse, and log once, when the target home is the source home after
  normalizeRuntimePathForComparison. The WSL ~/.codex was protected only
  by a plain === in WSL launch prep; differing spellings (\\wsl$ vs
  \\wsl.localhost, distro casing) could slip past it.
- ensureCodexDaemonSocketGuard and its writer move to
  codex-owned-home-daemon-guard.ts, next to the refusal, keeping
  codex-config-mirror.ts under the line limit.
- The override warning no longer claims ~/.codex/config.toml was the
  source; a true set only inside Orca's home is replaced there.
- Documented that [profiles.X.features] and -c overrides still win.
…still strip it

An older Orca recognizes only the original marker text. After a downgrade it
could not strip a reworded line, so seeding ~/.codex/config.toml from the
runtime config copied Orca's override into the user's home, and the stall check
reported a false missing-source stall.
The override is now ownership policy, not a socket-path-length fix: rename the
modules and functions to match, drop the socket-path measurement that only
picked a warning sentence, and correct the override warning, which claimed Orca
never edits ~/.codex/config.toml.
…in Orca-owned homes

Problem: ORCA_CODEX_ISOLATE=0 is the documented opt-out from the codex shell
function's --no-daemon. Now that every Orca-owned Codex home carries
[features] daemon_auto_start = false, skipping --no-daemon no longer brings the
shared server back, so the opt-out silently did nothing.

Change: with ORCA_CODEX_ISOLATE=0 the bash/zsh, fish and PowerShell functions
prepend -c features.daemon_auto_start=true instead of --no-daemon, under the
same conditions --no-daemon is added (no agents/queue/--no-daemon/--remote
argument, and codex --help lists --no-daemon, so Codex 0.155 and older never
see the key). The command-line value beats config.toml, and Codex allowlists
features.daemon_auto_start among the -c overrides that do not force embedded
mode. Stale test comments that tied the override to sun_path length are
reworded.

Caveat: a launch that also passes a -c override Codex does not allowlist (for
example reasoning effort) still runs without the shared server.
…ORCA_CODEX_ISOLATE=0

The previous commit made the codex shell function pass
-c features.daemon_auto_start=true when ORCA_CODEX_ISOLATE=0. In a home
whose socket path exceeds sun_path (macOS managed account homes), that
makes Codex auto-start a server it cannot bind, and Codex treats that
failure as fatal, so codex would not start at all.

Orca-owned homes now have no opt-out; the shell function is back to
#23900's behaviour. A per-launch -c features.daemon_auto_start=true is
the manual route in short homes. The test comment rewording from the
previous commit stays.
@brennanb2025

Copy link
Copy Markdown
Contributor Author

Review status: code review done, Windows QA not done yet

The problem. Since Codex 0.156, the first codex started in a Codex home runs one shared background server, and every later codex in that home joins it. On Windows that server has no console, so each hook or command it runs opens a new console window. The owner saw windows pop open in an Orca cmd.exe tab (1.4.217, Codex 0.159) when Codex started, ran a hook, or was interrupted. The shared server also runs every tab's hooks with the first tab's environment, so status lands on the wrong tab, and it dies when the first tab closes. #23900 fixed PowerShell, Git Bash, bash, zsh and fish by adding --no-daemon in Orca's codex shell function, but cmd.exe tabs, scripts and Quick Commands never go through that function.

What changes for users. Every Codex home Orca owns (the managed runtime home, managed account homes, resume homes, WSL managed homes) now always has [features] daemon_auto_start = false. On native Windows every local pane uses such a home, so Codex in a cmd.exe tab, a script or a Quick Command runs its own server, and no console windows should appear. Your own ~/.codex is never written. Limits: a shared server that is already running is still joined, and codex agents, codex remote-control start and codex app-server daemon start still start one. Panes that use your own ~/.codex (the default account on macOS and Linux, and WSL panes without a WSL managed account) are covered only by #23900's shell function.

Decided during review (owner calls). Orca-owned homes have no opt-out: ORCA_CODEX_ISOLATE=0 still skips --no-daemon, but it no longer brings the shared server back in those homes. An attempt to restore it by passing -c features.daemon_auto_start=true was reverted: in long homes (macOS managed accounts) the server's socket path is too long for the OS, and Codex exits when that start fails. A daemon_auto_start = true in ~/.codex is overridden in Orca's homes and logged once per home.

Fixed in this review

  • Orca's config line keeps the marker comment earlier builds wrote (ab9a4337d67). The PR had reworded it, so after a downgrade an older Orca couldn't recognize the line. It then reported a false "settings sync stalled", and with no ~/.codex/config.toml it could copy the line into your own ~/.codex on the next /model change.
  • Renamed the guard to what it now does, applyCodexDaemonAutoStartOverride / ensureCodexDaemonAutoStartOverride, and removed the socket-length measurement that only picked a warning sentence (2e82900d827).
  • Corrected the warning that claimed Orca never edits ~/.codex/config.toml, and the stale "temp homes exceed sun_path" reasons in 11 test mocks. The Codex version in the doc comment is now 0.156 (a0fa9d3ba33).
  • Reverted the ORCA_CODEX_ISOLATE=0 change described above (7f32467f79f); the shell function is identical to main again.
  • PR body: the scope now names what isn't covered, the mechanism description is corrected, and the no-opt-out decision is stated.

Deferred (P3, no user impact)

  • The check that decides whether to log the override warning is its own small TOML scan, and one of its branches can never run. It was kept because the pre-PR review added the warning deliberately.
  • The user-home refusal check also sits in ensureCodexDaemonAutoStartOverride, where no caller can reach it. The legacy shared-home refresh has no refusal, but it always targets Orca's own home. The refusal compares normalized path text and does not resolve symlinks, and no Orca home is a symlink to ~/.codex.
  • Naming nits: "daemon guard" wording in a few call-site comments, and the test file name codex-session-resume-daemon-guard.test.ts.

Verified

  • Code review, whole PR in round 1 plus a narrow check of each fix; a separate readiness pass over the final diff. No P0, P1 or P2 issue remains.
  • Traced from the code: a native-Windows cmd.exe pane gets an Orca-owned CODEX_HOME, and that home gets the setting before the pane's first codex on every entry path (fresh install with no ~/.codex/config.toml, stalled mirror, account switch, resume, WSL managed home).
  • Checked in Codex's source: daemon_auto_start = false skips auto-start but still joins a running server. Codex 0.155 and older treat the key as unknown and only log it. -c features.daemon_auto_start=true is an allowed override, and a failed auto-start is fatal.
  • Tests: 47 related codex, account and startup test files (597 passed), plus the shell-function and wrapper-snapshot tests. Typecheck (node, cli) clean.

Not verified

  • Live Windows QA did not run, so the fix for the cmd.exe windows is still unproven on a real machine. On Windows high spec, new Git Bash terminals exited as soon as they opened, and Orca there stopped responding a few minutes after the QA worker started; the machine still answers ping. The cause is unknown; a full disk is one candidate, as on low spec. Windows low spec has 0 bytes free on C: and Codex 0.152.1, which predates the shared server. The PR stays a draft until the cmd.exe check (start, run a hook, interrupt; then a forced-on control run) passes on a working Windows box with Codex 0.159.
  • Linux, and WSL panes, were not run live.

@brennanb2025

Copy link
Copy Markdown
Contributor Author

Closing: Codex deprecated daemon_auto_start, and #41873 stops Orca regenerating it.

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