From 021014cc56f5a3c1f7fb97f7fad3a579152a01c1 Mon Sep 17 00:00:00 2001 From: Eyejoker Date: Wed, 11 Mar 2026 02:25:20 +0900 Subject: [PATCH] feat: add CODEX_MODEL and CODEX_EFFORT env var support for codex-runner --- container/codex-runner/src/index.ts | 12 +++++------- src/container-runner.ts | 8 ++++++++ 2 files changed, 13 insertions(+), 7 deletions(-) diff --git a/container/codex-runner/src/index.ts b/container/codex-runner/src/index.ts index 64168a3..f91c878 100644 --- a/container/codex-runner/src/index.ts +++ b/container/codex-runner/src/index.ts @@ -128,11 +128,10 @@ async function runCodexExec(prompt: string, resume: boolean): Promise<{ result: return new Promise((resolve) => { const args: string[] = []; const effectiveCwd = WORK_DIR || GROUP_DIR; + const codexModel = process.env.CODEX_MODEL || ''; + const codexEffort = process.env.CODEX_EFFORT || ''; if (resume) { - // Resume the most recent session with a new prompt - // --dangerously-bypass-approvals-and-sandbox: fully disables sandbox - // (--full-auto forces workspace-write which blocks /workspace/extra/ mounts) args.push( 'exec', 'resume', '--last', '--dangerously-bypass-approvals-and-sandbox', @@ -140,17 +139,16 @@ async function runCodexExec(prompt: string, resume: boolean): Promise<{ result: prompt, ); } else { - // Fresh session - // --dangerously-bypass-approvals-and-sandbox: fully disables sandbox - // (--full-auto forces workspace-write which blocks /workspace/extra/ mounts) args.push( 'exec', '--dangerously-bypass-approvals-and-sandbox', '-C', effectiveCwd, '--skip-git-repo-check', '--color', 'never', - prompt, ); + if (codexModel) args.push('-m', codexModel); + if (codexEffort) args.push('--effort', codexEffort); + args.push(prompt); } log(`Running: codex ${args.slice(0, 6).join(' ')}... (resume=${resume})`); diff --git a/src/container-runner.ts b/src/container-runner.ts index c3b5ad3..530cae7 100644 --- a/src/container-runner.ts +++ b/src/container-runner.ts @@ -126,6 +126,8 @@ function prepareGroupEnvironment( 'CLAUDE_EFFORT', 'OPENAI_API_KEY', 'CODEX_OPENAI_API_KEY', + 'CODEX_MODEL', + 'CODEX_EFFORT', ]); // Build a clean env without Claude Code nesting detection variables @@ -174,6 +176,12 @@ function prepareGroupEnvironment( process.env.OPENAI_API_KEY; if (openaiKey) env.OPENAI_API_KEY = openaiKey; + // Codex model/effort configuration + const codexModel = envVars.CODEX_MODEL || process.env.CODEX_MODEL; + if (codexModel) env.CODEX_MODEL = codexModel; + const codexEffort = envVars.CODEX_EFFORT || process.env.CODEX_EFFORT; + if (codexEffort) env.CODEX_EFFORT = codexEffort; + // Codex session directory const hostCodexDir = path.join(os.homedir(), '.codex'); const sessionCodexDir = path.join(