From d0e9c5eda562e8a7a655460c429c08fb6f91cffc Mon Sep 17 00:00:00 2001 From: Sas Swart Date: Thu, 11 Jun 2026 09:17:26 +0200 Subject: [PATCH] =?UTF-8?q?fix:=20avoid=20an=20errant=C2=A0license=20warni?= =?UTF-8?q?ng=20banner=20on=20new=20deployments=20that=20d=E2=80=A6=20(#26?= =?UTF-8?q?239)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Problem: CODER_AI_GATEWAY_ENABLED defaulted to true, which both started the in-memory gateway and enabled the licensed FeatureAIBridge. As a result, deployments that never configured AI Gateway saw a spurious "AI Governance add-on is required" warning whenever they had an older (non-add-on) Premium license, since the feature was enabled-and-entitled by default. Fix: Decouple "external AI Gateway API enabled" from "in-memory daemon running," so the external/licensed surface is off by default while Coder Agents retain access by default. --- cli/server.go | 13 +++++++++---- cli/testdata/coder_server_--help.golden | 2 +- cli/testdata/server-config.yaml.golden | 8 ++++---- coderd/coderd.go | 3 +-- codersdk/deployment.go | 4 ++-- docs/reference/cli/server.md | 2 +- enterprise/cli/testdata/coder_server_--help.golden | 2 +- 7 files changed, 19 insertions(+), 15 deletions(-) diff --git a/cli/server.go b/cli/server.go index 4508db623e..e24ac8dbd7 100644 --- a/cli/server.go +++ b/cli/server.go @@ -1053,10 +1053,15 @@ func (r *RootCmd) Server(newAPI func(context.Context, *coderd.Options) (*coderd. // dispatch LLM requests via the in-process transport without // crossing the gated /api/v2/aibridge HTTP route. The HTTP route // itself is registered (and license-gated) only by enterprise/coderd; - // in AGPL builds it does not exist at all. The daemon starts here - // unconditionally when the bridge feature is enabled by config so - // chatd can use it regardless of license entitlement. - if vals.AI.BridgeConfig.Enabled.Value() { + // in AGPL builds it does not exist at all. + // + // The daemon must run whenever either consumer needs it: the + // external/licensed AI Gateway HTTP API (CODER_AI_GATEWAY_ENABLED) + // or Coder Agents routing chat traffic through the in-process + // transport (CODER_CHAT_AI_GATEWAY_ROUTING_ENABLED). Agents get + // access regardless of license entitlement; the external HTTP + // route stays license-gated. + if vals.AI.BridgeConfig.Enabled.Value() || vals.AI.Chat.AIGatewayRoutingEnabled.Value() { aibridgeReg := prometheus.WrapRegistererWithPrefix("coder_aibridged_", coderAPI.PrometheusRegistry) aibridgeMetrics := aibridge.NewMetrics(aibridgeReg) aibridgeProviders, _, err := BuildProviders(aibridgeInitCtx, options.Database, vals.AI.BridgeConfig, logger.Named("aibridge.providers"), aibridgeMetrics) diff --git a/cli/testdata/coder_server_--help.golden b/cli/testdata/coder_server_--help.golden index 63640d49f9..16426da0a9 100644 --- a/cli/testdata/coder_server_--help.golden +++ b/cli/testdata/coder_server_--help.golden @@ -183,7 +183,7 @@ AI GATEWAY OPTIONS: Length of time to retain data such as interceptions and all related records (token, prompt, tool use). - --ai-gateway-enabled bool, $CODER_AI_GATEWAY_ENABLED (default: true) + --ai-gateway-enabled bool, $CODER_AI_GATEWAY_ENABLED (default: false) Whether to start an in-memory AI Gateway instance. --ai-gateway-max-concurrency int, $CODER_AI_GATEWAY_MAX_CONCURRENCY (default: 0) diff --git a/cli/testdata/server-config.yaml.golden b/cli/testdata/server-config.yaml.golden index 15dd31638d..0d04fdbf9d 100644 --- a/cli/testdata/server-config.yaml.golden +++ b/cli/testdata/server-config.yaml.golden @@ -779,8 +779,8 @@ chat: aibridge: # Deprecated: use --ai-gateway-enabled or CODER_AI_GATEWAY_ENABLED instead. # Whether to start an in-memory aibridged instance. - # (default: true, type: bool) - enabled: true + # (default: false, type: bool) + enabled: false # Deprecated: use --ai-gateway-openai-base-url or CODER_AI_GATEWAY_OPENAI_BASE_URL # instead. The base URL of the OpenAI API. # (default: https://api.openai.com/v1/, type: string) @@ -878,8 +878,8 @@ aibridge: circuit_breaker_max_requests: 3 ai_gateway: # Whether to start an in-memory AI Gateway instance. - # (default: true, type: bool) - enabled: true + # (default: false, type: bool) + enabled: false # Deprecated: manage AI Providers from the Coder UI or HTTP API. If set, this # option seeds provider configuration at startup only exactly once. It will not be # used in service runtime. The base URL of the OpenAI API. diff --git a/coderd/coderd.go b/coderd/coderd.go index b2d50f7068..b3098b8e3c 100644 --- a/coderd/coderd.go +++ b/coderd/coderd.go @@ -811,8 +811,7 @@ func New(options *Options) *API { providerAPIKeys = *options.ChatProviderAPIKeys } - chatAIGatewayRoutingEnabled := options.DeploymentValues.AI.BridgeConfig.Enabled.Value() && - options.DeploymentValues.AI.Chat.AIGatewayRoutingEnabled.Value() + chatAIGatewayRoutingEnabled := options.DeploymentValues.AI.Chat.AIGatewayRoutingEnabled.Value() api.chatDaemon = chatd.New(chatd.Config{ Logger: options.Logger.Named("chatd"), diff --git a/codersdk/deployment.go b/codersdk/deployment.go index 3e447a4db4..a6f72fc8f5 100644 --- a/codersdk/deployment.go +++ b/codersdk/deployment.go @@ -1805,7 +1805,7 @@ func (c *DeploymentValues) Options() serpent.OptionSet { Flag: "ai-gateway-enabled", Env: "CODER_AI_GATEWAY_ENABLED", Value: &c.AI.BridgeConfig.Enabled, - Default: "true", + Default: "false", Group: &deploymentGroupAIGateway, YAML: "enabled", } @@ -4191,7 +4191,7 @@ Write out the current server config as YAML to stdout.`, Flag: "aibridge-enabled", Env: "CODER_AIBRIDGE_ENABLED", Value: &c.AI.BridgeConfig.Enabled, - Default: "true", + Default: "false", Group: &deploymentGroupAIBridge, YAML: "enabled", Hidden: true, diff --git a/docs/reference/cli/server.md b/docs/reference/cli/server.md index 356358a873..4131f1e8df 100644 --- a/docs/reference/cli/server.md +++ b/docs/reference/cli/server.md @@ -1730,7 +1730,7 @@ Force chat debug logging on for every chat, bypassing the runtime admin and user | Type | bool | | Environment | $CODER_AI_GATEWAY_ENABLED | | YAML | ai_gateway.enabled | -| Default | true | +| Default | false | Whether to start an in-memory AI Gateway instance. diff --git a/enterprise/cli/testdata/coder_server_--help.golden b/enterprise/cli/testdata/coder_server_--help.golden index 801bae69c9..f568cc9755 100644 --- a/enterprise/cli/testdata/coder_server_--help.golden +++ b/enterprise/cli/testdata/coder_server_--help.golden @@ -184,7 +184,7 @@ AI GATEWAY OPTIONS: Length of time to retain data such as interceptions and all related records (token, prompt, tool use). - --ai-gateway-enabled bool, $CODER_AI_GATEWAY_ENABLED (default: true) + --ai-gateway-enabled bool, $CODER_AI_GATEWAY_ENABLED (default: false) Whether to start an in-memory AI Gateway instance. --ai-gateway-max-concurrency int, $CODER_AI_GATEWAY_MAX_CONCURRENCY (default: 0)