Run code mode exclusively through the standalone host (#36217)

## What changed

- Move the V8 implementation into a dedicated `codex-code-mode-runtime` crate used by `codex-code-mode-host`, removing the embedded runtime fallback from the Codex process.
- Resolve the host executable from the active installation layout and check its availability before selecting tools.
- Fall back to direct tools with a one-time warning when optional code mode is unavailable. Keep `code_mode_only` and `disable_in_process_fallback` configurations fail-closed.

## Testing

- Cover host discovery for standalone and package layouts, including missing hosts and symlinks.
- Verify direct-tool fallback, one-time warnings, and fail-closed code-mode-only behavior.

GitOrigin-RevId: 5aa3c6f1db148b2231fc24089a2ee0e2b00dbddb
This commit is contained in:
Channing Conger authored and copyberry committed 2026-07-30 20:24:29 +00:00
1 parent acd540f158
commit 97576b1794
51 files changed
+627 -424

No files matched your search

+13 -1
View File
@@ -63,7 +63,7 @@ pub(crate) fn tool_user_shell_type(
}
}
fn effective_tool_mode(turn_context: &TurnContext) -> ToolMode {
pub(crate) fn requested_tool_mode(turn_context: &TurnContext) -> ToolMode {
turn_context.model_info.tool_mode.unwrap_or_else(|| {
if turn_context.config.features.enabled(Feature::CodeModeOnly) {
ToolMode::CodeModeOnly
@@ -75,6 +75,18 @@ fn effective_tool_mode(turn_context: &TurnContext) -> ToolMode {
})
}
pub(crate) fn effective_tool_mode(turn_context: &TurnContext) -> ToolMode {
let requested_tool_mode = requested_tool_mode(turn_context);
if !turn_context.code_mode_available
&& requested_tool_mode == ToolMode::CodeMode
&& !turn_context.config.code_mode.disable_in_process_fallback
{
ToolMode::Direct
} else {
requested_tool_mode
}
}
/// Format the combined exec output for sending back to the model.
/// Includes exit code and duration metadata; truncates large bodies safely.
pub fn format_exec_output_for_model(