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.

The status reports the outcome of the last actual contact with the runtime. It is not a claim about the present moment. A failed runtime request moves it to Error, a successful one moves it back — and nothing else moves it. There is no polling and no heartbeat, so an outage that begins while your application is idle is not noticed until something is sent.

Import

import { CopilotKitCoreRuntimeConnectionStatus } from "@copilotkit/core";

Definition

enum CopilotKitCoreRuntimeConnectionStatus {
  Disconnected = "disconnected",
  Connected = "connected",
  Connecting = "connecting",
  Error = "error",
}

Members

Prop

Type

Prop

Type

Prop

Type

Prop

Type

Usage

copilotkit.subscribe({
  onRuntimeConnectionStatusChanged: ({ status }) => {
    if (status === CopilotKitCoreRuntimeConnectionStatus.Connected) {
      enableChat();
      return;
    }

    if (status === CopilotKitCoreRuntimeConnectionStatus.Error) {
      showConnectionError();
      if (Object.keys(copilotkit.agents).length === 0) {
        disableChat();
      }
    }
  },
});

Related