Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 6 additions & 2 deletions src/ucode/agents/codex.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
import subprocess
import sys
import time
import shutil
from collections.abc import Callable
from pathlib import Path

Expand Down Expand Up @@ -554,8 +555,11 @@ def _app_server_start_model() -> str:
# inherited (no capture), so Ctrl-C reaches codex directly and the resulting
# KeyboardInterrupt propagates past the retry check — quitting an interactive
# session is never mistaken for a --profile rejection.
resolved_binary = shutil.which(binary) or binary
if not resolved_binary:
raise RuntimeError(f"Unable to locate {binary} on PATH")
started = time.monotonic()
returncode = subprocess.run([binary, "--profile", CODEX_PROFILE_NAME, *tool_args]).returncode
returncode = subprocess.run([resolved_binary, "--profile", CODEX_PROFILE_NAME, *tool_args]).returncode
if returncode != 0 and time.monotonic() - started < _PROFILE_REJECTED_MAX_SECONDS:
# Fast failure: most likely codex rejected --profile on this subcommand.
# Relaunch without it, handing over the terminal. (A fast failure for
Expand All @@ -570,7 +574,7 @@ def _app_server_start_model() -> str:
f"without it: Codex will resolve {LEGACY_CODEX_CONFIG_PATH} and any OS-managed "
"settings instead of the ucode profile."
)
exec_or_spawn([binary, *tool_args])
exec_or_spawn([resolved_binary, *tool_args])
return # unreachable in production (exec replaces the process)
sys.exit(returncode)

Expand Down