CopilotKitCoreRuntimeConnectionStatus
Connection states between CopilotKitCore and the CopilotRuntime.
Overview
CopilotKitCoreRuntimeConnectionStatus represents the state of the connection between CopilotKitCore and its runtime. You encounter it via copilotkit.runtimeConnectionStatus and the onRuntimeConnectionStatusChanged subscriber callback.
Import
import { CopilotKitCoreRuntimeConnectionStatus } from "@copilotkit/core";Definition
enum CopilotKitCoreRuntimeConnectionStatus {
Disconnected = "disconnected",
Connected = "connected",
Connecting = "connecting",
Error = "error",
}Members
Disconnecteddisconnected
No connection to the runtime has been established. This is the initial state when no runtimeUrl is set.
Connectedconnected
The runtime responded successfully and the client is ready to run agents.
Connectingconnecting
A connection attempt is in flight — runtime info is being fetched.
Errorerror
The connection attempt failed.
Usage
copilotkit.subscribe({
onRuntimeConnectionStatusChanged: ({ status }) => {
if (status === CopilotKitCoreRuntimeConnectionStatus.Connected) {
enableChat();
} else if (status === CopilotKitCoreRuntimeConnectionStatus.Error) {
showConnectionError();
}
},
});Related
- CopilotKitCore — exposes the connection lifecycle via
runtimeConnectionStatus. - CopilotKitCoreSubscriber —
onRuntimeConnectionStatusChangedreceives this status.