fix(acp): route codex -c overrides through CODEX_CONFIG for npm adapter#31
Open
stephanbrez wants to merge 1 commit into
Open
Conversation
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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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-acpadapter (v1.1.0+, verified against1.1.2) does not parse
-coverrides from argv — it reads its startupconfiguration from the
CODEX_CONFIGenv var (JSON), parsed atsrc/CodexAcpClient.tsand spread unchanged into codex'sthread/startconfig. As a result, the
-cflags appended by_augment_acp_command(
sandbox_mode,approval_policy,model_reasoning_effort) were silentlydiscarded — sandbox, approval policy, and reasoning effort never reached the
worker.
Fix
Build
CODEX_CONFIGin_acp_subprocess_envin three layers, each overridingthe previous:
CODEX_CONFIG(ambient env).-coverrides parsed from the augmented command string, via_parse_codex_c_overrides(handles both double- and single-quoted values).sandbox_mode,approval_policy,model_reasoning_effort) — always win, since sandbox/approval areautonomy-safety requirements and effort is the per-role resolved value.
The
-cflags remain in argv for-c-honoring codex-acp builds (harmless ifignored by the npm adapter).
_acp_subprocess_envnow acceptsreasoning_effortandacp_command; both call sites (run_node,run_terminal_review) threadrole_config.worker_reasoning_effortand theaugmented command through.
Additional: custom model override
Routing all
-coverrides throughCODEX_CONFIGalso lets a user-specifiedcodex model reach the adapter — previously dropped for the same reason. A
modelsupplied viaZENITH_*_ACP_COMMAND(-c model="...") or ambientCODEX_CONFIGis now preserved (layers 1–2) while zenith's safety keys stilloverride (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_CONFIGcarrying
model,sandbox_mode="danger-full-access",approval_policy="never", andmodel_reasoning_effort="max", the adapter'sstartup log (
app-server.log) showscodexConfigwith all four keys received.Tests
_parse_codex_c_overridesextracts model + sandbox from double- andsingle-quoted
-cflags; empty when no flags present.CODEX_CONFIGJSON present with correct effort; defaults toxhigh.CODEX_CONFIGmerged (preserves ambient model); command-string modelwins over ambient model.
replaced. Claude path has no
CODEX_CONFIG.