Skip to content

Embedded app-server loses runtime exec paths in derived configs, which breaks apply_patch for non-CLI hosts #18256

@niteshbalusu11

Description

@niteshbalusu11

What issue are you seeing?

When Codex is embedded inside another application instead of being run as
the codex CLI itself, apply_patch can fail even when arg0_paths.codex_self_exe is set correctly at
startup

What steps can reproduce the bug?

  1. Start Codex in-process from a host binary that is not the codex executable.

  2. Pass a valid arg0_paths.codex_self_exe pointing to a real Codex runtime binary.

  3. Start a thread/turn that triggers apply_patch.

  4. Observe that the file change fails even though the same bundled Codex binary can apply the patch
    directly outside the embedded host.

let client = InProcessAppServerClient::start(InProcessClientStartArgs {
    arg0_paths: Arg0DispatchPaths {
        codex_self_exe: Some(path_to_real_codex_binary),
        codex_linux_sandbox_exe: None,
        main_execve_wrapper_exe: None,
    },
    // normal config + startup args...
}).await?;

The failure shows up after thread/turn config derivation, not at startup.

From inspection, the problematic paths are the helpers that derive a fresh Config but do not reapply
runtime exec paths:

  • derive_config_from_params(...)

  • derive_config_for_cwd(...)

What is the expected behavior?

Embedded app-server mode should preserve the runtime exec paths from
arg0_paths across all config derivation paths, so tool runtimes like apply_patch behave the same way
they do in CLI-hosted flows.

If codex_self_exe was valid at startup, derived configs should continue to carry it unless
explicitly overridden.

Additional information

I am attaching a patch if you'd like to use since external contribution is closed.

codex-embedded-runtime-exec-paths-main.patch

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingtool-callsIssues related to tool calling

    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