Skip to content

feat: add option to disable the embedded AI Gateway - #31967

Merged
mollymaefraser merged 9 commits into
mainfrom
molly/aigov-514-add-a-separate-switch-for-the-embedded-ai
Nov 11, 2026
Merged

mollymaefraser merged 9 commits into
mainfrom
molly/aigov-514-add-a-separate-switch-for-the-embedded-ai

Conversation

@mollymaefraser

Copy link
Copy Markdown
Collaborator

Adds --ai-gateway-embedded-enabled / CODER_AI_GATEWAY_EMBEDDED_ENABLED (default true) so standalone-only deployments can stop coderd from starting the in-memory AI Gateway.

CODER_AI_GATEWAY_ENABLED stays the global switch: the AI Gateway entitlement, /api/v2/ai-gateway/serve, and cost-control metrics still depend only on it. The embedded daemon now starts only when both options are true.

ENABLED EMBEDDED_ENABLED Result
true true Unchanged
true false No embedded gateway; standalone gateways keep working
false any No AI Gateway

Refs AIGOV-514

Open questions for reviewers

  • Coder Agents does not work with the embedded gateway disabled. chatd still starts, but model calls fail with "AI Gateway transport factory is not configured" because there is no in-process transport. AIGOV-597 (routing Agents through standalone gateways) was canceled. The docs and option help state that Agents requires the embedded gateway. Is that acceptable, or should chatd also be turned off in this mode?
  • Option name: the ticket proposed CODER_AI_GATEWAY_EMBEDDED_ENABLED tentatively. OK to keep?

Verification

$ go test ./cli/ -run 'TestServer_AIGateway' -count=1
ok      github.com/coder/coder/v2/cli   0.518s
$ go test ./enterprise/coderd/ -run 'TestAIGatewayServe' -count=1
ok      github.com/coder/coder/v2/enterprise/coderd     0.755s

TestServer_AIGatewayEmbedded fails when the new check is removed.

Implementation notes
  • codersdk/deployment.go: new option and AIBridgeConfig.EmbeddedEnabled field; updated --ai-gateway-enabled description.
  • cli/server.go: outer if Enabled sets up cost-control metrics and the blocked-users collector (the standalone /serve endpoint uses these too). Inner if EmbeddedEnabled creates the daemon, registers the in-memory handler, and adds its cleanup.
  • cli/server_test.go: TestServer_AIGatewayEmbedded covers the three modes by checking for the embedded daemon's startup log.
  • enterprise/coderd/aibridgeserve_test.go: TestAIGatewayServeEmbeddedDisabled checks the entitlement and /serve still work with embedded disabled.
  • docs/ai-governance/ai-gateway/standalone.md: new "Disable the embedded gateway" section.
  • Remaining files are generated by make gen.
  • Found during review: keeping metrics inside the embedded check would have dropped cost-control metrics for standalone gateways.

Generated with Coder Agents; reviewed, revised, and verified by @mollymaefraser.

@mollymaefraser mollymaefraser self-assigned this Nov 10, 2026
@mollymaefraser
mollymaefraser temporarily deployed to main November 10, 2026 14:47 — with GitHub Actions Inactive
@linear-code

linear-code Bot commented Nov 10, 2026

Copy link
Copy Markdown

AIGOV-514

@github-actions

github-actions Bot commented Nov 10, 2026 •

Copy link
Copy Markdown
Contributor

All contributors have signed the CLA ✍️ ✅
Posted by the CLA Assistant Lite bot.

@mollymaefraser

Copy link
Copy Markdown
Collaborator Author

I have read the CLA Document and I hereby sign the CLA

cdrci2 added a commit to coder/cla that referenced this pull request Nov 10, 2026
@mollymaefraser
mollymaefraser temporarily deployed to main November 10, 2026 14:49 — with GitHub Actions Inactive
@mollymaefraser
mollymaefraser marked this pull request as ready for review November 10, 2026 14:52
@mollymaefraser
mollymaefraser temporarily deployed to main November 10, 2026 14:52 — with GitHub Actions Inactive
@mollymaefraser
mollymaefraser temporarily deployed to main November 10, 2026 15:25 — with GitHub Actions Inactive
@mollymaefraser
mollymaefraser marked this pull request as draft November 10, 2026 15:27
@mollymaefraser
mollymaefraser marked this pull request as ready for review November 10, 2026 16:23
@mollymaefraser
mollymaefraser temporarily deployed to main November 10, 2026 16:23 — with GitHub Actions Inactive
@mollymaefraser
mollymaefraser temporarily deployed to main November 10, 2026 16:23 — with GitHub Actions Inactive
@mollymaefraser
mollymaefraser temporarily deployed to main November 10, 2026 16:34 — with GitHub Actions Inactive
@mollymaefraser
mollymaefraser temporarily deployed to main November 10, 2026 16:43 — with GitHub Actions Inactive
@mollymaefraser
mollymaefraser temporarily deployed to main November 11, 2026 08:29 — with GitHub Actions Inactive

@SasSwart SasSwart left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM! Congratulations on your first PR as part of the team! Two small nits on wording for your consideration.

Comment thread codersdk/deployment.go Resolved
Comment thread codersdk/deployment.go Resolved
@mollymaefraser
mollymaefraser temporarily deployed to main November 11, 2026 11:31 — with GitHub Actions Inactive
@mollymaefraser
mollymaefraser temporarily deployed to main November 11, 2026 11:37 — with GitHub Actions Inactive
@mollymaefraser
mollymaefraser enabled auto-merge (squash) November 11, 2026 11:37
@mollymaefraser
mollymaefraser merged commit 0a7ef88 into main Nov 11, 2026
30 of 31 checks passed
@mollymaefraser
mollymaefraser deleted the molly/aigov-514-add-a-separate-switch-for-the-embedded-ai branch November 11, 2026 11:50
@mollymaefraser
mollymaefraser temporarily deployed to main November 11, 2026 11:50 — with GitHub Actions Inactive
@github-actions github-actions Bot locked and limited conversation to collaborators Nov 11, 2026

This branch was previously deployed

1 inactive deployment
main — c1f8e145 Deployed Nov 11, 2026 by mollymaefraser via cla #254272
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants