Skip to content

app-server local command execution lacks a cwd-scoped environment contract #24638

@dpritchett

Description

@dpritchett

What issue are you seeing?

Codex local command execution can silently use different environment sources for visually similar TUI launches.

A plain codex session may reuse an implicit local app-server daemon. Adding any -c override prevents that reuse and starts a different execution topology. This means command env can differ even when cwd and the visible UI look equivalent.

This is surprising and operationally risky because the UI presents both sessions as local command execution in the same directory, but env-sensitive commands may behave differently.

What steps can reproduce the bug?

First, make sure an implicit local app-server daemon already exists. In my case, this was a long-lived daemon started earlier by normal Codex use. The important precondition is that plain codex can reuse an existing local app-server daemon.

Then, in a shell:

mkdir -p /tmp/codex-env-repro
cd /tmp/codex-env-repro
export CODEX_ENV_REPRO=present
printenv CODEX_ENV_REPRO

Control output:

present

Start Codex normally:

codex

Inside Codex:

pwd
printenv CODEX_ENV_REPRO

Observed:

/private/tmp/codex-env-repro
# no output

Now exit and start Codex with a config override:

codex -c shell_environment_policy.inherit=all

Inside Codex:

pwd
printenv CODEX_ENV_REPRO

Observed:

/tmp/codex-env-repro
present

What is the expected behavior?

Either:

  1. both local TUI launches use the same command-env provenance, or
  2. Codex clearly exposes when command env comes from a reused app-server daemon instead of the launching terminal process.

The important part is not this specific variable. The issue is that adding a -c override changes process topology and therefore command env, while the UI still presents both as local execution in the selected cwd.

Additional information

shell_environment_policy.inherit = "all" appears to be valid and already defaults to all, so the override value itself is probably not the fix. The relevant behavior appears to be that non-empty CLI overrides prevent implicit local app-server daemon reuse.

Metadata

Metadata

Assignees

No one assigned

    Labels

    CLIIssues related to the Codex CLIapp-serverIssues involving app server protocol or interfacesbugSomething isn't working

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions