CopilotKitCoreSubscriber
Set of optional callbacks notified of CopilotKitCore lifecycle events.
Overview
CopilotKitCoreSubscriber is the object passed to CopilotKitCore.subscribe. Every callback is optional, receives an event object that always includes the copilotkit instance, and may return void or a Promise<void>. Use it to react to connection status, tool execution, suggestions, configuration changes, and errors.
Import
import type { CopilotKitCoreSubscriber } from "@copilotkit/core";Definition
Every callback is optional, receives an event object that always includes the
copilotkit instance, and returns void or Promise<void>. The shape below
shows the representative onRuntimeConnectionStatusChanged callback; the
Properties section documents each callback's exact event shape.
interface CopilotKitCoreSubscriber {
onRuntimeConnectionStatusChanged?: (event: {
copilotkit: CopilotKitCore;
status: CopilotKitCoreRuntimeConnectionStatus;
}) => void | Promise<void>;
// ...one optional callback per lifecycle event (tool execution, agents,
// context, suggestions, properties, headers, errors, thread stores).
// See the Properties section below for each callback's event shape.
}Properties
Prop
Type
Prop
Type
Prop
Type
Prop
Type
Prop
Type
Prop
Type
Prop
Type
Prop
Type
Prop
Type
Prop
Type
Prop
Type
Prop
Type
Prop
Type
Prop
Type
Usage
const subscription = copilotkit.subscribe({
onRuntimeConnectionStatusChanged: ({ status }) => {
console.log("connection:", status);
},
onError: ({ code, error }) => {
console.error(code, error);
},
});
// later
subscription.unsubscribe();