From b6d4ef21588e4c07a3abc1313682e493719e0acd Mon Sep 17 00:00:00 2001 From: Danny Kopping Date: Mon, 10 Nov 2025 03:55:42 -0500 Subject: [PATCH] chore: conditionally disable `aibridge` in dogfood template (#20686) Allow for conditionally disabling AI Bridge to investigate occasional issues. When AI Bridge is disabled, a static credential will be configured for Claude. AI Bridge is still enabled by default. Signed-off-by: Danny Kopping --- dogfood/coder/main.tf | 34 ++++++++++++++++++++++++++++------ 1 file changed, 28 insertions(+), 6 deletions(-) diff --git a/dogfood/coder/main.tf b/dogfood/coder/main.tf index 40eec5e913..ce57a022f7 100644 --- a/dogfood/coder/main.tf +++ b/dogfood/coder/main.tf @@ -217,6 +217,24 @@ data "coder_parameter" "devcontainer_autostart" { mutable = true } +data "coder_parameter" "use_ai_bridge" { + type = "bool" + name = "Use AI Bridge" + default = true + description = "If enabled, AI requests will be sent via AI Bridge." + mutable = true +} + +# Only used if AI Bridge is disabled. +# dogfood/main.tf injects this value from a GH Actions secret; +# `coderd_template.dogfood` passes the value injected by .github/workflows/dogfood.yaml in `TF_VAR_CODER_DOGFOOD_ANTHROPIC_API_KEY`. +variable "anthropic_api_key" { + type = string + description = "The API key used to authenticate with the Anthropic API, if AI Bridge is disabled." + default = "" + sensitive = true +} + provider "docker" { host = lookup(local.docker_host, data.coder_parameter.region.value) } @@ -458,11 +476,15 @@ resource "coder_agent" "dev" { arch = "amd64" os = "linux" dir = local.repo_dir - env = { - OIDC_TOKEN : data.coder_workspace_owner.me.oidc_access_token, - ANTHROPIC_BASE_URL : "https://dev.coder.com/api/v2/aibridge/anthropic", - ANTHROPIC_AUTH_TOKEN : data.coder_workspace_owner.me.session_token - } + env = merge( + { + OIDC_TOKEN : data.coder_workspace_owner.me.oidc_access_token, + }, + data.coder_parameter.use_ai_bridge.value ? { + ANTHROPIC_BASE_URL : "https://dev.coder.com/api/v2/aibridge/anthropic", + ANTHROPIC_AUTH_TOKEN : data.coder_workspace_owner.me.session_token, + } : {} + ) startup_script_behavior = "blocking" display_apps { @@ -836,7 +858,7 @@ module "claude-code" { workdir = local.repo_dir claude_code_version = "latest" order = 999 - claude_api_key = data.coder_workspace_owner.me.session_token # To Enable AI Bridge integration + claude_api_key = data.coder_parameter.use_ai_bridge.value ? data.coder_workspace_owner.me.session_token : var.anthropic_api_key agentapi_version = "latest" system_prompt = local.claude_system_prompt