Skip to content

feat(coderd/aibridge): build providers from deployment config without a DB#26605

Draft
pawbana wants to merge 4 commits into
pawel/aigov-308-implement-apiv2aibridgeserve-endpoint-2from
pawel/aigov-315-implement-basic-coder-aibridge-start-sub-command
Draft

feat(coderd/aibridge): build providers from deployment config without a DB#26605
pawbana wants to merge 4 commits into
pawel/aigov-308-implement-apiv2aibridgeserve-endpoint-2from
pawel/aigov-315-implement-basic-coder-aibridge-start-sub-command

Conversation

@pawbana

@pawbana pawbana commented Jun 23, 2026

Copy link
Copy Markdown
Contributor

No description provided.

@linear-code

linear-code Bot commented Jun 23, 2026

Copy link
Copy Markdown

AIGOV-315

pawbana commented Jun 23, 2026

Copy link
Copy Markdown
Contributor Author

Warning

This pull request is not mergeable via GitHub because a downstack PR is open. Once all requirements are satisfied, merge this PR as a stack on Graphite.
Learn more

This stack of pull requests is managed by Graphite. Learn more about stacking.

@github-actions

Copy link
Copy Markdown

Docs preview

📖 View docs preview for docs/reference/cli/ai-gateway.md

@pawbana pawbana force-pushed the pawel/aigov-308-implement-apiv2aibridgeserve-endpoint-3 branch from a66f1fe to c768ef1 Compare June 23, 2026 11:35
@pawbana pawbana force-pushed the pawel/aigov-315-implement-basic-coder-aibridge-start-sub-command branch from d2902a8 to a0e84e0 Compare June 23, 2026 11:35
@pawbana pawbana force-pushed the pawel/aigov-308-implement-apiv2aibridgeserve-endpoint-3 branch from c768ef1 to 8a51ad7 Compare June 23, 2026 13:46
@pawbana pawbana force-pushed the pawel/aigov-315-implement-basic-coder-aibridge-start-sub-command branch from a0e84e0 to 0814404 Compare June 23, 2026 13:46
@pawbana pawbana force-pushed the pawel/aigov-308-implement-apiv2aibridgeserve-endpoint-3 branch from 8a51ad7 to 94f6f0d Compare June 23, 2026 14:11
@pawbana pawbana force-pushed the pawel/aigov-315-implement-basic-coder-aibridge-start-sub-command branch from 0814404 to 06972b6 Compare June 23, 2026 14:11
@pawbana pawbana force-pushed the pawel/aigov-308-implement-apiv2aibridgeserve-endpoint-3 branch from 94f6f0d to 0d518d8 Compare June 23, 2026 17:00
@pawbana pawbana force-pushed the pawel/aigov-315-implement-basic-coder-aibridge-start-sub-command branch from 06972b6 to ce1531b Compare June 23, 2026 17:00
pawbana and others added 4 commits June 23, 2026 17:01
… a DB

Factor the per-provider-type construction out of buildAIProviderFromRow
into a database-neutral buildProvider helper, and add two entry points
that share it:

- coderd.ProvidersFromConfig normalizes the deployment AI Bridge config
  (legacy + indexed CODER_AI_GATEWAY_PROVIDER_<N>_* env vars) into a
  DB-neutral provider list, reusing the same logic as the env seed.
- cli.BuildProvidersFromConfig turns that into runtime aibridge.Provider
  instances with no database access.

This lets the upcoming standalone AI Gateway set up providers purely from
its configuration. No behavior change for the embedded DB-backed path.

Co-authored-by: Coder Agent <agent@coder.com>
Add aibridged.NewWebsocketDialer, which connects to coderd's
/api/v2/aibridge/serve endpoint over a WebSocket, multiplexes it with
yamux, and returns a DRPCClient exposing the Recorder, MCPConfigurator
and Authorizer services. It is the standalone counterpart to the
in-memory pipe used by the embedded daemon.

Authentication uses the AI Gateway key header; the API version is sent as
a query parameter and the build version as a header. Failed upgrades are
returned as *codersdk.Error so the daemon's connect loop can tell fatal
auth/entitlement failures apart from transient ones.

Co-authored-by: Coder Agent <agent@coder.com>
Add the standalone AI Gateway command under the existing 'coder
ai-gateway' group. It connects to coderd over DRPC via
/api/v2/aibridge/serve for authentication, recording and MCP
configuration, builds providers from deployment configuration, and serves
incoming LLM client traffic on its own HTTP listener (with optional TLS
termination). Request interception and recording behave the same as the
embedded daemon, which it reuses directly.

The daemon is served at the listener root, with an /api/v2/aibridge alias
for parity with the embedded route. Standalone-specific options use the
CODER_AI_GATEWAY_* prefix; all other AI Gateway config options are shared
with embedded mode.

Health endpoints, metrics, tracing, structured logging, live provider
reload and E2E tests are intentionally out of scope and will follow.

Co-authored-by: Coder Agent <agent@coder.com>
The connect loop warns when a dial fails but previously logged a
successful connect at debug, so a standalone gateway recovering from a
transient coderd outage produced no visible signal. Log the (re)connection
at info so the warning on failure is paired with a clear restoration
message. Resolves the long-standing TODO now that external gateways exist.

Co-authored-by: Coder Agent <agent@coder.com>
@pawbana pawbana force-pushed the pawel/aigov-315-implement-basic-coder-aibridge-start-sub-command branch from ce1531b to cfecff6 Compare June 23, 2026 17:01
@pawbana pawbana force-pushed the pawel/aigov-308-implement-apiv2aibridgeserve-endpoint-3 branch from 0d518d8 to 3ca7c1b Compare June 23, 2026 17:01
@pawbana pawbana changed the base branch from pawel/aigov-308-implement-apiv2aibridgeserve-endpoint-3 to graphite-base/26605 June 23, 2026 17:19
@pawbana pawbana changed the base branch from graphite-base/26605 to pawel/aigov-308-implement-apiv2aibridgeserve-endpoint-2 June 23, 2026 17:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant