Repository navigation
Description
Summary
After trying the v0.74.2 prerelease, the original Codex model-selection issue appears fixed: generated lock files now invoke Codex with --model "$GH_AW_MODEL_AGENT_CODEX" instead of -c model=....
However, workflows using the OpenAI Codex engine now fail because the sandboxed Codex process reports:
Missing environment variable: `OPENAI_API_KEY`.
Reproduction Context
Repo/PR:
- Repo: https://github.com/chrizbo/agentics-beyond-code
- PR with
v0.74.2compiled locks: Switch agentic workflows to OpenAI Codex chrizbo/agentics-beyond-code#131 - Compile commit: chrizbo/agentics-beyond-code@701a1fb
- Failed workflow run: https://github.com/chrizbo/agentics-beyond-code/actions/runs/25929907528
Workflow tested:
.github/workflows/daily-standup-prep.lock.yml- Triggered manually against branch
openai-aw-updates - Repo secret
OPENAI_API_KEYis configured CODEX_API_KEYis not configured
What Worked
The prerelease fixes the model flag generation. In the failed run, the logs show the requested model reaching Codex:
codex --model openai/gpt-5-mini exec ...
model: "openai/gpt-5-mini", model_provider_id: "openai-proxy"
Model: openai/gpt-5-mini
What Failed
The agent fails before useful work with:
Missing environment variable: `OPENAI_API_KEY`.
The generated lock validates OPENAI_API_KEY successfully during activation and later sets both env vars for the Codex step:
CODEX_API_KEY: ${{ secrets.CODEX_API_KEY || secrets.OPENAI_API_KEY }}
OPENAI_API_KEY: ${{ secrets.CODEX_API_KEY || secrets.OPENAI_API_KEY }}But the generated awf command excludes both variables from the sandboxed execution:
--exclude-env CODEX_API_KEY ... --exclude-env OPENAI_API_KEY
The generated Codex config also points Codex at the OpenAI proxy while still declaring an env var requirement:
model_provider = "openai-proxy"
[model_providers.openai-proxy]
name = "OpenAI AWF proxy"
base_url = "http://172.30.0.30:10000"
env_key = "OPENAI_API_KEY"
supports_websockets = falseExpected Behavior
When gh-aw runs Codex through the AWF OpenAI proxy, the sandboxed Codex process should not fail because the raw provider secret is intentionally excluded from the agent container.
Question
Should gh-aw:
- inject a non-secret placeholder
OPENAI_API_KEYfor the proxy provider, - configure Codex to use a different auth path when
openai-proxyis active, or - omit/avoid
env_key = "OPENAI_API_KEY"in the generated Codex config for proxied execution?
Related
This was discovered while testing the prerelease suggested in #32413 (comment). I also left an initial comment there before realizing this should probably be tracked as a separate issue.
Activity
pelikhan commentedon May 15, 2026
/scout investigate the run and figure out if we are configuring codex properly as with something like ollama
lpcox commentedon May 15, 2026
🔗 AWF tracking issue: https://github.com/github/gh-aw-firewall/issues/github/gh-aw-firewall#3232
chrizbo commentedon May 20, 2026
Follow-up after testing the newer AW prerelease:
gh-aw v0.74.6is now available and compiling my repo with it does pick upgh-aw-firewall v0.25.49.env_key = "OPENAI_API_KEY"in the Codexopenai-proxyprovider block.awfcommand still excludes bothCODEX_API_KEYandOPENAI_API_KEYfrom the sandboxed execution.Example from
.github/workflows/daily-standup-prep.lock.ymlafter compiling withv0.74.6:And the same generated step still has:
So the firewall version bump appears to have landed in AW, but the compiler/generated Codex config still seems to preserve the problematic
env_keyrequirement. I restored the compile probe locally afterward, so this is just a generated-output check rather than a committed repo change.pelikhan commentedon May 21, 2026
/scout investigate failure
github-actions commentedon May 21, 2026
🔭 Recon complete! Scout has charted the territory. Map ready! 🗺️
github-actions commentedon May 21, 2026
🔍 Scout Research Report
Triggered by
@pelikhanvia/scout investigate failure(original prompt: "investigate the run and figure out if we are configuring codex properly as with something like ollama")Executive Summary
The Codex AWF proxy config is not modeled like an Ollama provider, and that's the root cause. In Codex's own config schema, local/proxy providers (Ollama, custom relays) omit
env_keyentirely —env_keyis only meant for providers that need the agent process to read an API key from its environment. The AWFopenai-proxyprovider does its own upstream auth, butpkg/workflow/codex_mcp.go:168hardcodesenv_key = "OPENAI_API_KEY", which then collides directly with the sandbox's--exclude-env OPENAI_API_KEYflag emitted bypkg/workflow/codex_engine.go:293. The config demands the var; the sandbox strips it; Codex aborts.Critical Findings
pkg/workflow/codex_mcp.go:168—yaml.WriteString(indent + "env_key = \"OPENAI_API_KEY\"\n")inrenderOpenAIProxyProviderTomlpkg/workflow/codex_engine.go:293—ExcludeEnvVarNames: ComputeAWFExcludeEnvVarNames(workflowData, []string{"CODEX_API_KEY", "OPENAI_API_KEY"})--exclude-envflags:pkg/workflow/awf_helpers.go:392-403pkg/workflow/codex_engine_test.go:347assertsenv_key = "OPENAI_API_KEY"is present in the rendered TOML, so this is intentionally generated, not accidental.pkg/workflow/testdata/TestWasmGolden_AllEngines/codex.golden:494shows--env-all --exclude-env CODEX_API_KEY ... --exclude-env OPENAI_API_KEYalongside the same config block.How Ollama / Pi avoids this in gh-aw and in Codex CLI
In Codex CLI itself, the Ollama provider block has no
env_key. From the [Codex provider configuration guide]((www.morphllm.com/redacted)Providers that do need client-side auth (OpenRouter, Morph, etc.) declare
env_key; local/proxy providers that handle their own auth simply omit it.In gh-aw, the Pi engine (which talks to Ollama via the AWF gateway) doesn't use env vars for the gateway secret at all. It writes a
models.jsonfile mounted into the sandbox atpkg/workflow/pi_engine.go:124-142:So the answer to the original question "are we configuring codex properly as with something like ollama?" is no — Ollama-style providers in Codex omit
env_key, while gh-aw's Codex path hardcodes it.Why the fall-through reasoning matters
The AWF proxy at
(172.30.0.30/redacted) is the thing that holds the actual upstream OpenAI/Codex credentials. The agent container shouldn't need them at all — that's the whole point of--exclude-env` for sandboxed engines. Right now gh-aw is doing both: stripping the secret from the sandbox and telling Codex to look for it there. One of those two has to give.Codex will accept a provider definition without
env_key(verified by the Codexmodel_providers.ollamapattern). It uses the provider'sbase_urlfor the actual request and only consultsenv_keywhen authenticating. With the proxy doing auth,env_keyis dead weight that causes a startup-time check to fail.Recommendations
env_keyfrom theopenai-proxyblock. Match the Ollama pattern in Codex CLI: a proxy provider that handles auth upstream should not declareenv_key. Changepkg/workflow/codex_mcp.go:161-170to drop line 168, and updatepkg/workflow/codex_engine_test.go:343-347accordingly. This requires no change to--exclude-envand keeps the sandbox secrets-free.wire_api. Codex's Ollama-style providers usually setwire_api = "chat"(Chat Completions) vs. the built-inopenaiprovider's Responses API. Verify whether the AWF OpenAI gateway speaks Responses or Chat Completions and addwire_apiif needed — otherwise model behavior may differ from native OpenAI calls. Reference: [Codex provider configuration]((www.morphllm.com/redacted)env_keyis desired for non-proxied mode, make the line conditional on whether the firewall/proxy is active (the same condition that already gatesrenderOpenAIProxyProviderToml). When the firewall is off, the lock file uses the built-inopenaiprovider via the normal env var path and the issue doesn't arise.OPENAI_API_KEY=dummyinto the sandbox would work, but it re-introduces an env-var contract that future refactors can break, and it muddles the security model (the sandbox is supposed to never see provider credentials, real or fake).Key Sources
pkg/workflow/codex_mcp.go:161-170,pkg/workflow/codex_engine.go:293,pkg/workflow/awf_helpers.go:392-403,pkg/workflow/pi_engine.go:124-142pkg/workflow/codex_engine_test.go:343-347env_key): (www.morphllm.com/redacted)OPENAI_API_KEYdiscussion (confirmsenv_keyis the variable-lookup mechanism for non-built-in providers): (community.openai.com/redacted)Suggested Next Steps
renderOpenAIProxyProviderTomlto drop theenv_keyline (and update the matching test assertion).chrizbo/agentics-beyond-codePR [copilot] Restrict frontmatter schema with additionalProperties: false, align with GitHub Actions schema, and add tests #131 against a freshly compiled lock to confirm Codex starts without the env-var error.wire_api = "chat"to the proxy block — this depends on the gateway's API surface and is worth a quick check before shipping.env_keyand that the matching--exclude-env OPENAI_API_KEYstays in the awf args, so the regression can't reappear.lpcox commentedon May 21, 2026
This is already handled on the AWF side when
--enable-api-proxyis active.AWF fix:
src/services/api-proxy-service.tslines 250-261When the api-proxy sidecar is enabled, AWF:
OPENAI_API_KEY/CODEX_API_KEYfrom the agent container (credential isolation)sk-placeholder-for-api-proxy) so Codex's startup auth check passesOPENAI_BASE_URLto the sidecar (http://172.30.0.30:10000)The issue reported here is on the gh-aw compilation side: the generated lock file uses
--exclude-env OPENAI_API_KEYwithout also enabling--enable-api-proxy(which would trigger the placeholder injection). The fix should ensure that when gh-aw generates an AWF command for Codex with a proxiedopenai-proxyprovider, it passes--enable-api-proxyand--openai-api-keyso AWF handles the credential isolation + placeholder injection automatically.lpcox commentedon May 21, 2026
How to fix via stdin config
gh-aw's lock compiler should generate an AWF config with
apiProxy.enabled: trueinstead of (or in addition to)--exclude-env OPENAI_API_KEY. Example:{ "apiProxy": { "enabled": true }, "network": { "allowDomains": ["api.openai.com"] } }Piped to AWF:
When
apiProxy.enabledis true andOPENAI_API_KEYis in the host environment, AWF will:OPENAI_API_KEY=sk-placeholder-for-api-proxyso Codex's auth check passesOPENAI_BASE_URL=http://172.30.0.30:10000(the sidecar)This eliminates the need for
--exclude-env OPENAI_API_KEY— credential isolation is automatic when the api-proxy is enabled.See:
docs/awf-config-spec.md§5 CLI Mapping andsrc/services/api-proxy-service.tslines 250-261fix(codex): stop excluding OPENAI_API_KEY from AWF sandbox (github#33833