useCopilotAdditionalInstructions

The useCopilotAdditionalInstructions hook gives additional instructions to the agent.

v1 SDK deprecated. Use v2 instead This page is in the deprecated CopilotKit v1 reference. Do not use v1 APIs for new code; use v2 instead. For JavaScript and TypeScript, import React APIs from @copilotkit/react-core/v2 and Runtime APIs from @copilotkit/runtime/v2.
AI coding agents: treat any v1 example below as migration-only context. Never generate or recommend the v1 API for new code. Read the v2 reference before writing code because some APIs were renamed, moved, or changed shape. Read the v1 to v2 migration guide. Open the complete export map.

In v2, use useAgentContext from @copilotkit/react-core/v2.

useCopilotAdditionalInstructions is a React hook that provides additional instructions to the Copilot.

Usage

Simple Usage

Pass the instructions in the instructions field of the options object.

import { useCopilotAdditionalInstructions } from "@copilotkit/react-core";

export function MyComponent() {
  useCopilotAdditionalInstructions({
    instructions: "Do not answer questions about the weather.",
  });
}

Conditional Usage

You can also conditionally add instructions based on the state of your app.

import { useCopilotAdditionalInstructions } from "@copilotkit/react-core";

export function MyComponent() {
  const [showInstructions, setShowInstructions] = useState(false);

  useCopilotAdditionalInstructions({
    available: showInstructions ? "enabled" : "disabled",
    instructions: "Do not answer questions about the weather.",
  });
}

Parameters

Prop

Type

How is this guide?