fix: add CODEX_HOME env var to MCP gateway step for Codex engine workflows#27457
fix: add CODEX_HOME env var to MCP gateway step for Codex engine workflows#27457
Conversation
…flows
The MCP gateway setup step needs CODEX_HOME to be available as an
environment variable so that the Codex config sync (copying the
converted MCP config into CODEX_HOME) can reference it. Without this,
mkdir -p "${CODEX_HOME}" expands to an empty string and fails.
Adds CODEX_HOME=/tmp/gh-aw/mcp-config to collectMCPEnvironmentVariables
only when the engine is codex, matching the value already set on the
agent execution step in codex_engine.go.
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
|
✅ Smoke CI completed successfully! |
There was a problem hiding this comment.
Pull request overview
Adds the missing CODEX_HOME environment variable to the MCP gateway startup step for Codex workflows, preventing ${CODEX_HOME} from expanding to an empty string during gateway setup.
Changes:
- Extend
collectMCPEnvironmentVariables()to includeCODEX_HOMEfor Codex workflows. - Add unit tests ensuring
CODEX_HOMEis present for Codex and absent for other engines.
Show a summary per file
| File | Description |
|---|---|
| pkg/workflow/mcp_environment.go | Adds conditional CODEX_HOME env var injection for Codex in MCP gateway env collection. |
| pkg/workflow/mcp_environment_test.go | Adds tests covering CODEX_HOME inclusion/exclusion based on engine. |
Copilot's findings
Tip
Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
- Files reviewed: 2/2 changed files
- Comments generated: 2
| // Codex engine needs CODEX_HOME available in the gateway setup step so that | ||
| // the converted MCP config can be copied into the writable Codex home directory. | ||
| // This matches the value set on the agent step in codex_engine.go. | ||
| if workflowData != nil && workflowData.AI == string(constants.CodexEngine) { | ||
| envVars["CODEX_HOME"] = "/tmp/gh-aw/mcp-config" | ||
| } |
There was a problem hiding this comment.
The CODEX_HOME env var is currently gated on workflowData.AI == "codex" (the logical engine ID). This will miss custom engine definitions that are backed by the Codex runtime via engine.definition.runtime-id (supported by the EngineCatalog), and those workflows would still hit the same empty ${CODEX_HOME} failure when the Codex runtime emits CODEX_HOME references in the gateway step. Consider keying this off the resolved runtime adapter instead (e.g., pass the CodingAgentEngine into collectMCPEnvironmentVariables and check engine.GetID() == string(constants.CodexEngine)).
| mcpTools := []string{"github"} | ||
| workflowData := &WorkflowData{AI: "codex"} | ||
|
|
There was a problem hiding this comment.
This test hardcodes the engine name as the string "codex". To avoid drift with the supported engine IDs, consider using string(constants.CodexEngine) (and similarly for the non-codex cases) so renames/aliases are caught at compile time.
|
@copilot address this review feedback #27457 (review) |
Agent-Logs-Url: https://github.com/github/gh-aw/sessions/27e0a550-30d5-4846-8d4e-03d3761d5659 Co-authored-by: lpcox <15877973+lpcox@users.noreply.github.com>
Problem
PR #27418 adds code in
codex_mcp.gothat copies the converted MCP config into${CODEX_HOME}/config.tomlduring the "Start MCP Gateway" step. However,CODEX_HOMEis only defined as an environment variable on the agent execution step (incodex_engine.go), not on the gateway setup step.This causes
mkdir -p "${CODEX_HOME}"to expand tomkdir -p "", which fails with:Root Cause
The
collectMCPEnvironmentVariables()function inmcp_environment.gocollects env vars for the "Start MCP Gateway" step but did not includeCODEX_HOME. When PR #27418 references${CODEX_HOME}in that step, it resolves to an empty string.Fix
Add
CODEX_HOME=/tmp/gh-aw/mcp-configtocollectMCPEnvironmentVariables()only when the engine is codex, matching the value already hardcoded on the agent step incodex_engine.go:283.Changes
pkg/workflow/mcp_environment.go: AddCODEX_HOMEto the gateway step env for Codex engine workflowspkg/workflow/mcp_environment_test.go: Add tests verifying CODEX_HOME is present for codex and absent for copilot/claude/empty enginesTesting
CODEX_HOMEappears only in codex workflow lock filesRelates to #27418