Skip to content

Fix Codex smoke workflow by preserving OPENAI_API_KEY in AWF container env#34129

Merged
pelikhan merged 4 commits into
mainfrom
copilot/aw-fix-smoke-codex-failure-again
May 22, 2026
Merged

Fix Codex smoke workflow by preserving OPENAI_API_KEY in AWF container env#34129
pelikhan merged 4 commits into
mainfrom
copilot/aw-fix-smoke-codex-failure-again

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented May 22, 2026

Smoke Codex fails before producing output because the Codex runtime cannot read OPENAI_API_KEY inside the AWF sandbox, even when the secret is configured. The workflow currently injects the key but also excludes it from container-visible env, causing immediate engine startup failure.

  • Root-cause correction (Codex AWF env isolation)

    • Updated Codex execution step generation to stop excluding OPENAI_API_KEY from AWF container env.
    • Kept CODEX_API_KEY excluded, preserving existing secret-isolation behavior for the alias var while allowing the runtime-required var through.
  • Regression guard

    • Added a focused Codex engine assertion to ensure generated steps do not contain --exclude-env OPENAI_API_KEY.
  • Behavioral impact

    • Codex engine can now start in smoke workflows with existing CODEX_API_KEY || OPENAI_API_KEY secret mapping, instead of terminating with “Missing environment variable: OPENAI_API_KEY”.
ExcludeEnvVarNames: ComputeAWFExcludeEnvVarNames(workflowData, []string{
    "CODEX_API_KEY",
})

Copilot AI linked an issue May 22, 2026 that may be closed by this pull request
Copilot AI and others added 2 commits May 22, 2026 22:41
Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
Copy link
Copy Markdown
Collaborator

@pelikhan pelikhan left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@copilot main and recompile

Comment thread pkg/workflow/codex_engine.go Outdated
// Keep CODEX_API_KEY out of the AWF agent container. Codex CLI itself
// requires OPENAI_API_KEY to be present at runtime.
ExcludeEnvVarNames: ComputeAWFExcludeEnvVarNames(workflowData, []string{
"CODEX_API_KEY",
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@copilot so remove this one

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done in d1dcead. I removed the remaining CODEX_API_KEY AWF exclude-env entry and updated Codex assertions/golden outputs accordingly.

Copilot AI changed the title [WIP] Fix Smoke Codex workflow failure due to missing environment variable Fix Codex smoke workflow by preserving OPENAI_API_KEY in AWF container env May 22, 2026
Copilot AI requested a review from pelikhan May 22, 2026 22:46
Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
Copy link
Copy Markdown
Contributor Author

Copilot AI commented May 22, 2026

@copilot main and recompile

Done in d1dcead. I recompiled lock workflows from the current branch state after the Codex AWF env change.

Copilot AI requested a review from pelikhan May 22, 2026 22:58
@pelikhan pelikhan marked this pull request as ready for review May 22, 2026 22:58
Copilot AI review requested due to automatic review settings May 22, 2026 22:58
@pelikhan pelikhan merged commit 232ffc2 into main May 22, 2026
@pelikhan pelikhan deleted the copilot/aw-fix-smoke-codex-failure-again branch May 22, 2026 22:59
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Fixes Codex smoke workflow failures in AWF-sandboxed runs by changing how Codex execution steps are generated so the Codex runtime can see required API-key environment variables inside the container.

Changes:

  • Updated Codex engine AWF wrapping to stop excluding API-key env vars from the container environment.
  • Updated workflow lockfiles and Codex golden output to reflect the new AWF invocation flags.
  • Added a regression test assertion to ensure generated steps don’t exclude OPENAI_API_KEY (and currently also CODEX_API_KEY).
Show a summary per file
File Description
pkg/workflow/codex_engine.go Changes AWF exclude-env computation for Codex execution.
pkg/workflow/codex_engine_test.go Adds assertions guarding against excluding API key env vars in generated AWF command.
pkg/workflow/testdata/TestWasmGolden_AllEngines/codex.golden Updates golden workflow output for Codex AWF command flags.
pkg/linters/manualmutexunlock/manualmutexunlock.go Whitespace-only formatting change.
.github/workflows/smoke-codex.lock.yml Regenerates locked workflow with updated AWF exclude-env behavior and heredoc markers.
.github/workflows/smoke-call-workflow.lock.yml Regenerates locked workflow with updated AWF exclude-env behavior and heredoc markers.
.github/workflows/schema-feature-coverage.lock.yml Regenerates locked workflow with updated AWF exclude-env behavior and heredoc markers.
.github/workflows/necromancer.lock.yml Regenerates locked workflow with updated AWF exclude-env behavior and heredoc markers.
.github/workflows/issue-arborist.lock.yml Regenerates locked workflow with updated AWF exclude-env behavior and heredoc markers.
.github/workflows/grumpy-reviewer.lock.yml Regenerates locked workflow with updated AWF exclude-env behavior and heredoc markers.
.github/workflows/duplicate-code-detector.lock.yml Regenerates locked workflow with updated AWF exclude-env behavior and heredoc markers.
.github/workflows/daily-observability-report.lock.yml Regenerates locked workflow with updated AWF exclude-env behavior and heredoc markers.
.github/workflows/daily-fact.lock.yml Regenerates locked workflow with updated AWF exclude-env behavior and heredoc markers.
.github/workflows/daily-cache-strategy-analyzer.lock.yml Regenerates locked workflow with updated AWF exclude-env behavior and heredoc markers.
.github/workflows/codex-github-remote-mcp-test.lock.yml Regenerates locked workflow with updated AWF exclude-env behavior.
.github/workflows/changeset.lock.yml Regenerates locked workflow with updated AWF exclude-env behavior.
.github/workflows/ai-moderator.lock.yml Regenerates locked workflow with updated AWF exclude-env behavior.

Copilot's findings

Tip

Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

  • Files reviewed: 16/17 changed files
  • Comments generated: 3

Comment on lines +291 to 293
// Keep Codex runtime API key variables available in the AWF container.
ExcludeEnvVarNames: ComputeAWFExcludeEnvVarNames(workflowData, nil),
})
Comment on lines +291 to +292
// Keep Codex runtime API key variables available in the AWF container.
ExcludeEnvVarNames: ComputeAWFExcludeEnvVarNames(workflowData, nil),
Comment on lines +106 to +111
if strings.Contains(stepContent, "--exclude-env OPENAI_API_KEY") {
t.Errorf("OPENAI_API_KEY must remain available to Codex runtime, got:\n%s", stepContent)
}
if strings.Contains(stepContent, "--exclude-env CODEX_API_KEY") {
t.Errorf("CODEX_API_KEY must remain available to Codex runtime, got:\n%s", stepContent)
}
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.

[aw] Smoke Codex failed

3 participants