mirror of
https://github.com/coder/coder.git
synced 2026-09-24 15:04:27 +08:00
refactor: deprecate AIGatewayRoutingEnabled, remove direct chat routing (#26862)
This PR removes the now-dead direct-routing code: - Deletes the direct routing implementation. - Collapses the resolvedModelRoute discriminated union into aiGatewayModelRoute. - Removes the dead providerKeys cascade. - Deletes the preferredShortTextCandidates quickgen function. - Simplifies the advisor override error handling. - Deprecates the AIGatewayRoutingEnabled deployment option. It is now a no-op so as to not break existing deployments on upgrade. Once direct routing was gone, the AI Gateway became mandatory for chat, which surfaced gaps in how the product behaves with the gateway disabled: - Exposes ai-gateway-enabled to the frontend via embedded page metadata. - Disables the chat composer via the existing AgentSetupNotice when the gateway is disabled, for both new and existing chats. - Fixes nil/typed-nil chatDaemon panics on startup and shutdown when gateway is disabled. - Fixes chat WebSocket from retrying the still-gated stream endpoint forever when the gateway is disabled.
This commit is contained in:
@@ -143,6 +143,17 @@ func (api *API) workspaceAgentRPC(rw http.ResponseWriter, r *http.Request) {
|
||||
slog.F("role", role))
|
||||
}
|
||||
|
||||
// api.chatDaemon is a *chatd.Server that stays nil when AI Gateway is
|
||||
// disabled. Assigning a nil *chatd.Server directly to the
|
||||
// interface-typed ContextDirtyMarker field below would produce a
|
||||
// non-nil interface value (a typed nil), defeating agentapi's own
|
||||
// "if DirtyMarker != nil" check and panicking on first use. Only set
|
||||
// the field when there's a real chat daemon to call into.
|
||||
var contextDirtyMarker agentapi.ContextDirtyMarker
|
||||
if api.chatDaemon != nil {
|
||||
contextDirtyMarker = api.chatDaemon
|
||||
}
|
||||
|
||||
agentAPI := agentapi.New(agentapi.Options{
|
||||
AgentID: workspaceAgent.ID,
|
||||
OwnerID: workspace.OwnerID,
|
||||
@@ -180,9 +191,7 @@ func (api *API) workspaceAgentRPC(rw http.ResponseWriter, r *http.Request) {
|
||||
|
||||
// Optional:
|
||||
UpdateAgentMetricsFn: api.UpdateAgentMetrics,
|
||||
// chatDaemon is always constructed (only its worker is gated), so
|
||||
// this is non-nil; agentapi treats a nil marker as "chatd absent".
|
||||
ContextDirtyMarker: api.chatDaemon,
|
||||
ContextDirtyMarker: contextDirtyMarker,
|
||||
}, workspace, workspaceAgent)
|
||||
|
||||
streamID := tailnet.StreamID{
|
||||
|
||||
Reference in New Issue
Block a user