diff --git a/registry/coder-labs/modules/codex/README.md b/registry/coder-labs/modules/codex/README.md index b4a895dea..16e6c105b 100644 --- a/registry/coder-labs/modules/codex/README.md +++ b/registry/coder-labs/modules/codex/README.md @@ -13,7 +13,7 @@ Run Codex CLI in your workspace to access OpenAI's models through the Codex inte ```tf module "codex" { source = "registry.coder.com/coder-labs/codex/coder" - version = "4.1.1" + version = "4.1.2" agent_id = coder_agent.example.id openai_api_key = var.openai_api_key workdir = "/home/coder/project" @@ -32,7 +32,7 @@ module "codex" { module "codex" { count = data.coder_workspace.me.start_count source = "registry.coder.com/coder-labs/codex/coder" - version = "4.1.1" + version = "4.1.2" agent_id = coder_agent.example.id openai_api_key = "..." workdir = "/home/coder/project" @@ -51,7 +51,7 @@ For tasks integration with AI Bridge, add `enable_aibridge = true` to the [Usage ```tf module "codex" { source = "registry.coder.com/coder-labs/codex/coder" - version = "4.1.1" + version = "4.1.2" agent_id = coder_agent.example.id workdir = "/home/coder/project" enable_aibridge = true @@ -94,7 +94,7 @@ data "coder_task" "me" {} module "codex" { source = "registry.coder.com/coder-labs/codex/coder" - version = "4.1.1" + version = "4.1.2" agent_id = coder_agent.example.id openai_api_key = "..." ai_prompt = data.coder_task.me.prompt @@ -112,7 +112,7 @@ This example shows additional configuration options for custom models, MCP serve ```tf module "codex" { source = "registry.coder.com/coder-labs/codex/coder" - version = "4.1.1" + version = "4.1.2" agent_id = coder_agent.example.id openai_api_key = "..." workdir = "/home/coder/project" diff --git a/registry/coder-labs/modules/codex/main.test.ts b/registry/coder-labs/modules/codex/main.test.ts index a4edd8185..f8d9f0a59 100644 --- a/registry/coder-labs/modules/codex/main.test.ts +++ b/registry/coder-labs/modules/codex/main.test.ts @@ -464,22 +464,13 @@ describe("codex", async () => { }); await execModuleScript(id); - - const startLog = await readFileContainer( - id, - "/home/coder/.codex-module/agentapi-start.log", - ); - const configToml = await readFileContainer( id, "/home/coder/.codex/config.toml", ); - expect(startLog).toContain("AI Bridge is enabled, using profile aibridge"); - expect(startLog).toContain( - "Starting Codex with arguments: --profile aibridge", - ); expect(configToml).toContain( "[profiles.aibridge]\n" + 'model_provider = "aibridge"', ); + expect(configToml).toContain('profile = "aibridge"'); }); }); diff --git a/registry/coder-labs/modules/codex/main.tf b/registry/coder-labs/modules/codex/main.tf index cc07ce2f9..41bf86ee1 100644 --- a/registry/coder-labs/modules/codex/main.tf +++ b/registry/coder-labs/modules/codex/main.tf @@ -136,8 +136,8 @@ variable "agentapi_version" { variable "codex_model" { type = string - description = "The model for Codex to use. Defaults to gpt-5.2-codex." - default = "gpt-5.2-codex" + description = "The model for Codex to use. Defaults to gpt-5.3-codex." + default = "gpt-5.3-codex" } variable "pre_install_script" { @@ -184,12 +184,13 @@ resource "coder_env" "coder_aibridge_session_token" { } locals { - workdir = trimsuffix(var.workdir, "/") - app_slug = "codex" - install_script = file("${path.module}/scripts/install.sh") - start_script = file("${path.module}/scripts/start.sh") - module_dir_name = ".codex-module" - aibridge_config = <<-EOF + workdir = trimsuffix(var.workdir, "/") + app_slug = "codex" + install_script = file("${path.module}/scripts/install.sh") + start_script = file("${path.module}/scripts/start.sh") + module_dir_name = ".codex-module" + latest_codex_model = "gpt-5.3-codex" + aibridge_config = <<-EOF [model_providers.aibridge] name = "AI Bridge" base_url = "${data.coder_workspace.me.access_url}/api/v2/aibridge/openai/v1" @@ -249,6 +250,8 @@ module "agentapi" { chmod +x /tmp/install.sh ARG_OPENAI_API_KEY='${var.openai_api_key}' \ ARG_REPORT_TASKS='${var.report_tasks}' \ + ARG_CODEX_MODEL='${var.codex_model}' \ + ARG_LATEST_CODEX_MODEL='${local.latest_codex_model}' \ ARG_INSTALL='${var.install_codex}' \ ARG_CODEX_VERSION='${var.codex_version}' \ ARG_BASE_CONFIG_TOML='${base64encode(var.base_config_toml)}' \ diff --git a/registry/coder-labs/modules/codex/scripts/install.sh b/registry/coder-labs/modules/codex/scripts/install.sh index 97d539a8c..4742c4137 100644 --- a/registry/coder-labs/modules/codex/scripts/install.sh +++ b/registry/coder-labs/modules/codex/scripts/install.sh @@ -20,6 +20,8 @@ echo "=== Codex Module Configuration ===" printf "Install Codex: %s\n" "$ARG_INSTALL" printf "Codex Version: %s\n" "$ARG_CODEX_VERSION" printf "App Slug: %s\n" "$ARG_CODER_MCP_APP_STATUS_SLUG" +printf "Codex Model: %s\n" "${ARG_CODEX_MODEL:-"Default"}" +printf "Latest Codex Model: %s\n" "${ARG_LATEST_CODEX_MODEL}" printf "Start Directory: %s\n" "$ARG_CODEX_START_DIRECTORY" printf "Has Base Config: %s\n" "$([ -n "$ARG_BASE_CONFIG_TOML" ] && echo "Yes" || echo "No")" printf "Has Additional MCP: %s\n" "$([ -n "$ARG_ADDITIONAL_MCP_SERVERS" ] && echo "Yes" || echo "No")" @@ -90,15 +92,25 @@ function install_codex() { write_minimal_default_config() { local config_path="$1" + + ARG_DEFAULT_PROFILE="" + + if [[ "${ARG_ENABLE_AIBRIDGE}" = "true" ]]; then + ARG_DEFAULT_PROFILE='profile = "aibridge"' + fi + cat << EOF > "$config_path" # Minimal Default Codex Configuration sandbox_mode = "workspace-write" approval_policy = "never" preferred_auth_method = "apikey" +${ARG_DEFAULT_PROFILE} [sandbox_workspace_write] network_access = true +[notice.model_migrations] +"${ARG_CODEX_MODEL}" = "${ARG_LATEST_CODEX_MODEL}" EOF } diff --git a/registry/coder-labs/modules/codex/scripts/start.sh b/registry/coder-labs/modules/codex/scripts/start.sh index 3e55dc70f..e0e7d9725 100644 --- a/registry/coder-labs/modules/codex/scripts/start.sh +++ b/registry/coder-labs/modules/codex/scripts/start.sh @@ -155,11 +155,8 @@ setup_workdir() { build_codex_args() { CODEX_ARGS=() - if [ "$ARG_ENABLE_AIBRIDGE" = "true" ]; then - printf "AI Bridge is enabled, using profile aibridge\n" - CODEX_ARGS+=("--profile" "aibridge") - elif [ -n "$ARG_CODEX_MODEL" ]; then - CODEX_ARGS+=("--model" "$ARG_CODEX_MODEL") + if [[ -n "${ARG_CODEX_MODEL}" ]] && [[ "${ARG_ENABLE_AIBRIDGE}" != "true" ]]; then + CODEX_ARGS+=("--model" "${ARG_CODEX_MODEL}") fi if [ "$ARG_CONTINUE" = "true" ]; then @@ -213,7 +210,7 @@ capture_session_id() { start_codex() { printf "Starting Codex with arguments: %s\n" "${CODEX_ARGS[*]}" - agentapi server --term-width 67 --term-height 1190 -- codex "${CODEX_ARGS[@]}" & + agentapi server --type codex --term-width 67 --term-height 1190 -- codex "${CODEX_ARGS[@]}" & capture_session_id }