Skip to content

fix(acp): route codex -c overrides through CODEX_CONFIG for npm adapter#31

Open
stephanbrez wants to merge 1 commit into
Intelligent-Internet:mainfrom
stephanbrez:fix/codex-c-overrides-via-codex-config
Open

fix(acp): route codex -c overrides through CODEX_CONFIG for npm adapter#31
stephanbrez wants to merge 1 commit into
Intelligent-Internet:mainfrom
stephanbrez:fix/codex-c-overrides-via-codex-config

Conversation

@stephanbrez

Copy link
Copy Markdown

Fixes #27, and adds custom model override support (requested in the #27
comments, not part of the original issue).

Problem (#27)

The npm @agentclientprotocol/codex-acp adapter (v1.1.0+, verified against
1.1.2) does not parse -c overrides from argv — it reads its startup
configuration from the CODEX_CONFIG env var (JSON), parsed at
src/CodexAcpClient.ts and spread unchanged into codex's thread/start
config. As a result, the -c flags appended by _augment_acp_command
(sandbox_mode, approval_policy, model_reasoning_effort) were silently
discarded — sandbox, approval policy, and reasoning effort never reached the
worker.

Fix

Build CODEX_CONFIG in _acp_subprocess_env in three layers, each overriding
the previous:

  1. User-supplied CODEX_CONFIG (ambient env).
  2. -c overrides parsed from the augmented command string, via
    _parse_codex_c_overrides (handles both double- and single-quoted values).
  3. Zenith's three safety keys (sandbox_mode, approval_policy,
    model_reasoning_effort) — always win, since sandbox/approval are
    autonomy-safety requirements and effort is the per-role resolved value.

The -c flags remain in argv for -c-honoring codex-acp builds (harmless if
ignored by the npm adapter). _acp_subprocess_env now accepts
reasoning_effort and acp_command; both call sites (run_node,
run_terminal_review) thread role_config.worker_reasoning_effort and the
augmented command through.

Additional: custom model override

Routing all -c overrides through CODEX_CONFIG also lets a user-specified
codex model reach the adapter — previously dropped for the same reason. A
model supplied via ZENITH_*_ACP_COMMAND (-c model="...") or ambient
CODEX_CONFIG is now preserved (layers 1–2) while zenith's safety keys still
override (layer 3). This is the model-override capability requested in the #27
comments; it is not part of the original issue but rides on the same mechanism.

Verification

Verified end-to-end against the installed adapter: with a CODEX_CONFIG
carrying model, sandbox_mode="danger-full-access",
approval_policy="never", and model_reasoning_effort="max", the adapter's
startup log (app-server.log) shows codexConfig with all four keys received.

Tests

  • _parse_codex_c_overrides extracts model + sandbox from double- and
    single-quoted -c flags; empty when no flags present.
  • CODEX_CONFIG JSON present with correct effort; defaults to xhigh.
  • User CODEX_CONFIG merged (preserves ambient model); command-string model
    wins over ambient model.
  • Custom model from augmented command preserved alongside zenith's safety keys.
  • Zenith's safety keys override user-supplied safety values; invalid user JSON
    replaced. Claude path has no CODEX_CONFIG.

The npm @agentclientprotocol/codex-acp adapter (v1.1.0+, verified against
1.1.2) does not parse -c overrides from argv — it reads its startup
configuration from the CODEX_CONFIG env var (JSON), parsed at
src/CodexAcpClient.ts and spread unchanged into codex's thread/start
config. The -c flags appended by _augment_acp_command (sandbox_mode,
approval_policy, model_reasoning_effort) were silently discarded — sandbox,
approval policy, and reasoning effort never reached the worker (issue Intelligent-Internet#27).

Build CODEX_CONFIG in _acp_subprocess_env in three layers, each overriding
the previous:

1. User-supplied CODEX_CONFIG (ambient env).
2. -c overrides parsed from the augmented command string, via
   _parse_codex_c_overrides (handles both double- and single-quoted values).
3. Zenith's three safety keys (sandbox_mode, approval_policy,
   model_reasoning_effort) — always win, since sandbox/approval are
   autonomy-safety requirements and effort is the per-role resolved value.

The -c flags remain in argv for -c-honoring codex-acp builds (harmless if
ignored by the npm adapter). _acp_subprocess_env now accepts reasoning_effort
and acp_command; both call sites (run_node, run_terminal_review) thread
role_config.worker_reasoning_effort and the augmented command through.

Additionally, routing all -c overrides through CODEX_CONFIG lets a
user-specified codex model reach the adapter — previously dropped for the
same reason. A model supplied via ZENITH_*_ACP_COMMAND (-c model="...") or
ambient CODEX_CONFIG is preserved (layers 1–2) while zenith's safety keys
still override (layer 3). This model-override support was requested in the
issue Intelligent-Internet#27 comments; it is not part of the original issue but rides on the
same mechanism.

Verified end-to-end against the installed adapter: the adapter's startup
log (app-server.log) shows codexConfig with model, sandbox_mode,
approval_policy, and model_reasoning_effort all received.

Tests:
- _parse_codex_c_overrides extracts model + sandbox from double and single
  quoted -c flags; empty when no flags present.
- CODEX_CONFIG JSON present with correct effort; defaults to xhigh.
- User CODEX_CONFIG merged (preserves ambient model); command-string model
  wins over ambient model.
- Custom model from augmented command preserved alongside zenith's safety
  keys.
- Zenith's safety keys override user-supplied safety values; invalid user
  JSON replaced. Claude path has no CODEX_CONFIG.

Fixes Intelligent-Internet#27.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

codex worker -c overrides never reach the npm codex-acp adapter (sandbox, approval policy, reasoning effort silently dropped)

1 participant