Skip to content

Commit b6d4ef2

Browse files
authored
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 <danny@coder.com>
1 parent 1d1e1f9 commit b6d4ef2

File tree

1 file changed

+28
-6
lines changed

1 file changed

+28
-6
lines changed

dogfood/coder/main.tf

Lines changed: 28 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -217,6 +217,24 @@ data "coder_parameter" "devcontainer_autostart" {
217217
mutable = true
218218
}
219219

220+
data "coder_parameter" "use_ai_bridge" {
221+
type = "bool"
222+
name = "Use AI Bridge"
223+
default = true
224+
description = "If enabled, AI requests will be sent via AI Bridge."
225+
mutable = true
226+
}
227+
228+
# Only used if AI Bridge is disabled.
229+
# dogfood/main.tf injects this value from a GH Actions secret;
230+
# `coderd_template.dogfood` passes the value injected by .github/workflows/dogfood.yaml in `TF_VAR_CODER_DOGFOOD_ANTHROPIC_API_KEY`.
231+
variable "anthropic_api_key" {
232+
type = string
233+
description = "The API key used to authenticate with the Anthropic API, if AI Bridge is disabled."
234+
default = ""
235+
sensitive = true
236+
}
237+
220238
provider "docker" {
221239
host = lookup(local.docker_host, data.coder_parameter.region.value)
222240
}
@@ -458,11 +476,15 @@ resource "coder_agent" "dev" {
458476
arch = "amd64"
459477
os = "linux"
460478
dir = local.repo_dir
461-
env = {
462-
OIDC_TOKEN : data.coder_workspace_owner.me.oidc_access_token,
463-
ANTHROPIC_BASE_URL : "https://dev.coder.com/api/v2/aibridge/anthropic",
464-
ANTHROPIC_AUTH_TOKEN : data.coder_workspace_owner.me.session_token
465-
}
479+
env = merge(
480+
{
481+
OIDC_TOKEN : data.coder_workspace_owner.me.oidc_access_token,
482+
},
483+
data.coder_parameter.use_ai_bridge.value ? {
484+
ANTHROPIC_BASE_URL : "https://dev.coder.com/api/v2/aibridge/anthropic",
485+
ANTHROPIC_AUTH_TOKEN : data.coder_workspace_owner.me.session_token,
486+
} : {}
487+
)
466488
startup_script_behavior = "blocking"
467489

468490
display_apps {
@@ -836,7 +858,7 @@ module "claude-code" {
836858
workdir = local.repo_dir
837859
claude_code_version = "latest"
838860
order = 999
839-
claude_api_key = data.coder_workspace_owner.me.session_token # To Enable AI Bridge integration
861+
claude_api_key = data.coder_parameter.use_ai_bridge.value ? data.coder_workspace_owner.me.session_token : var.anthropic_api_key
840862
agentapi_version = "latest"
841863

842864
system_prompt = local.claude_system_prompt

0 commit comments

Comments
 (0)