From a65827dc1234efb6efb25961963784780cb16587 Mon Sep 17 00:00:00 2001 From: Atif Ali Date: Sat, 27 Jun 2026 03:04:23 +0500 Subject: [PATCH 1/2] fix(coder-labs/modules/codex): rename session token env to OPENAI_ prefix Rename CODER_AIBRIDGE_SESSION_TOKEN to OPENAI_CODER_AIGATEWAY_SESSION_TOKEN. OIAgent filters the subprocess env and strips vars not prefixed with OPENAI_, so the AI Gateway token was lost when running Codex through Omnigent's native Codex bridge. Using an OPENAI_ prefix fixes this at the source. Bump version to 5.2.1. --- registry/coder-labs/modules/codex/README.md | 10 +++++----- registry/coder-labs/modules/codex/main.test.ts | 2 +- registry/coder-labs/modules/codex/main.tf | 6 ++++-- registry/coder-labs/modules/codex/main.tftest.hcl | 4 ++-- 4 files changed, 12 insertions(+), 10 deletions(-) diff --git a/registry/coder-labs/modules/codex/README.md b/registry/coder-labs/modules/codex/README.md index 2ce186b32..d17618611 100644 --- a/registry/coder-labs/modules/codex/README.md +++ b/registry/coder-labs/modules/codex/README.md @@ -13,7 +13,7 @@ Install and configure the [Codex CLI](https://github.com/openai/codex) in your w ```tf module "codex" { source = "registry.coder.com/coder-labs/codex/coder" - version = "5.2.0" + version = "5.2.1" agent_id = coder_agent.main.id openai_api_key = var.openai_api_key } @@ -33,7 +33,7 @@ locals { module "codex" { source = "registry.coder.com/coder-labs/codex/coder" - version = "5.2.0" + version = "5.2.1" agent_id = coder_agent.main.id workdir = local.codex_workdir openai_api_key = var.openai_api_key @@ -64,7 +64,7 @@ resource "coder_app" "codex" { ```tf module "codex" { source = "registry.coder.com/coder-labs/codex/coder" - version = "5.2.0" + version = "5.2.1" agent_id = coder_agent.main.id workdir = "/home/coder/project" enable_ai_gateway = true @@ -88,7 +88,7 @@ When `enable_ai_gateway = true`, the module configures Codex to use the `aigatew ```tf module "codex" { source = "registry.coder.com/coder-labs/codex/coder" - version = "5.2.0" + version = "5.2.1" agent_id = coder_agent.main.id workdir = "/home/coder/project" openai_api_key = var.openai_api_key @@ -117,7 +117,7 @@ The module exposes the `scripts` output: an ordered list of `coder exp sync` nam ```tf module "codex" { source = "registry.coder.com/coder-labs/codex/coder" - version = "5.2.0" + version = "5.2.1" agent_id = coder_agent.main.id openai_api_key = var.openai_api_key } diff --git a/registry/coder-labs/modules/codex/main.test.ts b/registry/coder-labs/modules/codex/main.test.ts index da82621a5..f6d37f3b2 100644 --- a/registry/coder-labs/modules/codex/main.test.ts +++ b/registry/coder-labs/modules/codex/main.test.ts @@ -398,7 +398,7 @@ describe("codex", async () => { "[model_providers.aigateway]", 'name = "Custom AI Bridge"', 'base_url = "https://custom.example.com"', - 'env_key = "CODER_AIBRIDGE_SESSION_TOKEN"', + 'env_key = "OPENAI_CODER_AIGATEWAY_SESSION_TOKEN"', 'wire_api = "responses"', ].join("\n"); const { id, coderEnvVars, scripts } = await setup({ diff --git a/registry/coder-labs/modules/codex/main.tf b/registry/coder-labs/modules/codex/main.tf index 7deb46452..21977ea42 100644 --- a/registry/coder-labs/modules/codex/main.tf +++ b/registry/coder-labs/modules/codex/main.tf @@ -118,10 +118,12 @@ resource "coder_env" "openai_api_key" { # Authenticates the client against Coder's AI Gateway using the workspace # owner's session token. Referenced by config.toml model_providers.aigateway. +# Uses OPENAI_ prefix so the variable is preserved in OIAgent's filtered +# subprocess environment (OIAgent strips non-OPENAI_ env vars). resource "coder_env" "ai_gateway_session_token" { count = var.enable_ai_gateway ? 1 : 0 agent_id = var.agent_id - name = "CODER_AIBRIDGE_SESSION_TOKEN" + name = "OPENAI_CODER_AIGATEWAY_SESSION_TOKEN" value = data.coder_workspace_owner.me.session_token } @@ -131,7 +133,7 @@ locals { [model_providers.aigateway] name = "AI Gateway" base_url = "${data.coder_workspace.me.access_url}/api/v2/aibridge/openai/v1" - env_key = "CODER_AIBRIDGE_SESSION_TOKEN" + env_key = "OPENAI_CODER_AIGATEWAY_SESSION_TOKEN" wire_api = "responses" EOF diff --git a/registry/coder-labs/modules/codex/main.tftest.hcl b/registry/coder-labs/modules/codex/main.tftest.hcl index 3bcd681ac..37aec6941 100644 --- a/registry/coder-labs/modules/codex/main.tftest.hcl +++ b/registry/coder-labs/modules/codex/main.tftest.hcl @@ -60,8 +60,8 @@ run "test_ai_gateway_enabled" { } assert { - condition = coder_env.ai_gateway_session_token[0].name == "CODER_AIBRIDGE_SESSION_TOKEN" - error_message = "CODER_AIBRIDGE_SESSION_TOKEN should be set" + condition = coder_env.ai_gateway_session_token[0].name == "OPENAI_CODER_AIGATEWAY_SESSION_TOKEN" + error_message = "OPENAI_CODER_AIGATEWAY_SESSION_TOKEN should be set" } assert { From 7cba5d5c97a70ac46295d9e7e3534070b716fca4 Mon Sep 17 00:00:00 2001 From: Atif Ali Date: Sat, 27 Jun 2026 03:07:55 +0500 Subject: [PATCH 2/2] chore: remove OIAgent-specific comment from coder_env resource --- registry/coder-labs/modules/codex/main.tf | 2 -- 1 file changed, 2 deletions(-) diff --git a/registry/coder-labs/modules/codex/main.tf b/registry/coder-labs/modules/codex/main.tf index 21977ea42..6ad5e3a54 100644 --- a/registry/coder-labs/modules/codex/main.tf +++ b/registry/coder-labs/modules/codex/main.tf @@ -118,8 +118,6 @@ resource "coder_env" "openai_api_key" { # Authenticates the client against Coder's AI Gateway using the workspace # owner's session token. Referenced by config.toml model_providers.aigateway. -# Uses OPENAI_ prefix so the variable is preserved in OIAgent's filtered -# subprocess environment (OIAgent strips non-OPENAI_ env vars). resource "coder_env" "ai_gateway_session_token" { count = var.enable_ai_gateway ? 1 : 0 agent_id = var.agent_id