fix: expose agentapi_port in codex/auggie/gemini/opencode modules#838
fix: expose agentapi_port in codex/auggie/gemini/opencode modules#838qinkangdeid wants to merge 2 commits intocoder:mainfrom
Conversation
|
Note: this is a more focused version of #829 (which was self-closed by the author). That PR updated 12 modules; this one targets only the 4 coder-labs modules to keep the scope minimal and reviewable. |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 2e8d99bab7
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| install_agentapi = var.install_agentapi | ||
| agentapi_subdomain = var.subdomain | ||
| agentapi_version = var.agentapi_version | ||
| agentapi_port = var.agentapi_port |
There was a problem hiding this comment.
Propagate configurable AgentAPI port into module configs
Passing agentapi_port into the agentapi submodule here does not actually reconfigure the client-side MCP wiring, because the module install paths still hardcode http://localhost:3284 (for example: registry/coder-labs/modules/codex/scripts/install.sh:132, auggie/scripts/install.sh:88, gemini/main.tf:167 and gemini/scripts/install.sh:145, opencode/scripts/install.sh:97). With any non-default agentapi_port, these modules will still point tools at 3284, so task reporting/MCP calls hit the wrong endpoint or fail entirely, which breaks the multi-tool port-conflict fix this commit is trying to add.
Useful? React with 👍 / 👎.
Pass ARG_AGENTAPI_PORT from main.tf install_script blocks into each
module's install.sh, replacing hardcoded localhost:3284 references
with ${ARG_AGENTAPI_PORT:-3284}. This ensures the MCP client-side
URL matches the configured AgentAPI port end-to-end.
Changes per module:
- codex: main.tf (pass env var) + install.sh (use env var)
- auggie: main.tf (pass env var) + install.sh (use env var)
- gemini: main.tf (pass env var + fix inline JSON) + install.sh (use env var)
- opencode: main.tf (pass env var) + install.sh (use env var)
Addressed Codex Review FeedbackThe automated review correctly identified that passing What was added (commit a5aba0e)8 files changed, 9 insertions(+), 5 deletions(-):
This follows the existing pattern in the End-to-end verificationTested by deploying a Coder workspace template with both Both AgentAPI instances run on separate ports with no conflict. The port flows end-to-end: Terraform variable → agentapi server listener → install.sh MCP client URL → Coder app healthcheck. |
Summary
When multiple AI coding tools (e.g. Claude Code + Codex, or Gemini + OpenCode) are installed in the same Coder workspace, they all hardcode AgentAPI to port 3284, causing port conflicts that prevent the second tool from starting.
The underlying
agentapisubmodule already supports a configurableagentapi_portparameter, but the parent modules (codex, auggie, gemini, opencode) don't expose or pass it through. This PR adds aagentapi_portvariable (defaulting to 3284 for backward compatibility) to all four modules and passes it to theagentapisubmodule.Changes
For each of the 4 modules (
codex,auggie,gemini,opencode):variable "agentapi_port"with typenumber, default3284agentapi_port = var.agentapi_portin themodule "agentapi"blockRelated Issues
Fixes #666
Fixes #837