codex - 💡(How to fix) Fix Embedded app-server loses runtime exec paths in derived configs, which breaks apply_patch for non-CLI hosts [1 participants]

Official PRs (…)
ON THIS PAGE

Recommended Tools

×6

Utilities matched from this issue’s tags and category — try them while you read without losing context.

GitHub issue graph ai analysis

Paste a GitHub issue URL. We fetch that issue, discover linked issues from bodies/comments/timeline, collect linked pull requests, and produce a structured English report.

The report is written in English Markdown for sharing and archival.

Helpful · Quick feedback

Loading…
GitHub stats
openai/codex#18256Fetched 2026-04-17 08:30:46
View on GitHub
Comments
0
Participants
1
Timeline
4
Reactions
0
Participants
Timeline (top)
labeled ×3unlabeled ×1

Fix Action

Fix / Workaround

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

  1. Start a thread/turn that triggers apply_patch.

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

Code Example

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?;
RAW_BUFFERClick to expand / collapse

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

extent analysis

TL;DR

The issue can be fixed by ensuring that the codex_self_exe path is preserved across all config derivation paths in embedded app-server mode.

Guidance

  • Review the derive_config_from_params and derive_config_for_cwd functions to ensure they correctly propagate the codex_self_exe path from the initial arg0_paths configuration.
  • Verify that the codex_self_exe path is not being overridden or lost during config derivation, potentially by adding logging or debugging statements to track its value.
  • Consider applying the provided patch (codex-embedded-runtime-exec-paths-main.patch) to update the config derivation logic and preserve the codex_self_exe path.
  • Test the embedded app-server mode with the updated config derivation logic to ensure that the apply_patch function works as expected.

Example

No code snippet is provided as the issue does not contain sufficient information to create a minimal example.

Notes

The provided patch may resolve the issue, but its contents and effects are unknown without further review. It is recommended to carefully evaluate the patch before applying it to the codebase.

Recommendation

Apply the workaround by reviewing and updating the config derivation logic to preserve the codex_self_exe path, as the provided patch may not be directly applicable or may introduce unintended changes.

Vote matrix · Quick signals

Works
Did the solution work? Tap to confirm.
Easy Fix
Was it a quick fix?
Time Saver
Did it save you time?
Blocking
Was it severely blocking?
Common Issue
Are others likely hitting this too?
Flaky / Intermittent
Is it intermittent?
Verified / Reproducible
Can you reproduce it reliably?
Loading…

Still need to ship something?

×6

Another batch ranked right after the header list — different links, same matching logic.

Back to top recommendations

TRENDING