# CopilotKitCoreRuntimeConnectionStatus

> Connection states between CopilotKitCore and the CopilotRuntime.

## Overview [#overview]

`CopilotKitCoreRuntimeConnectionStatus` represents the state of the connection between `CopilotKitCore` and its runtime. You encounter it via [`copilotkit.runtimeConnectionStatus`](/reference/core/classes/CopilotKitCore) and the [`onRuntimeConnectionStatusChanged`](/reference/core/types/CopilotKitCoreSubscriber) 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`, and a successful one moves it back. 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]

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

## Definition [#definition]

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

## Members [#members]

<PropertyReference name="Disconnected" type="disconnected">
  No connection to the runtime has been established. This is the initial state when no `runtimeUrl` is set.
</PropertyReference>

<PropertyReference name="Connected" type="connected">
  The runtime responded successfully and the client is ready to run agents.
</PropertyReference>

<PropertyReference name="Connecting" type="connecting">
  A connection attempt is in flight: runtime info is being fetched.
</PropertyReference>

<PropertyReference name="Error" type="error">
  The last contact with the runtime did not succeed. This covers two situations:

  - **The first contact never succeeded.** There are no runtime agents, because none were ever obtained.
  - **Contact was lost during the session.** The runtime answered at load and stopped answering later, for example after a dev server stop or a deploy. Your runtime agents keep their messages and threads. You can still send. A successful send sets the status back to `Connected`.

  So `Error` with agents present is a working state, not a bug. The next successful runtime request returns the status to `Connected` and re-syncs what the runtime reports.
</PropertyReference>

## Usage [#usage]

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

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