@copilotkit/react-core 1.71.0 → 1.71.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (35) hide show
  1. package/dist/{copilotkit-B4Jb1QEy.cjs → copilotkit-BkVEkUS0.cjs} +5 -2
  2. package/dist/copilotkit-BkVEkUS0.cjs.map +1 -0
  3. package/dist/{copilotkit-snbJkMqQ.mjs → copilotkit-D5BTo0YG.mjs} +5 -2
  4. package/dist/copilotkit-D5BTo0YG.mjs.map +1 -0
  5. package/dist/index.cjs +1 -1
  6. package/dist/index.mjs +1 -1
  7. package/dist/index.umd.js +4 -1
  8. package/dist/index.umd.js.map +1 -1
  9. package/dist/v2/headless.cjs +4 -1
  10. package/dist/v2/headless.cjs.map +1 -1
  11. package/dist/v2/headless.mjs +4 -1
  12. package/dist/v2/headless.mjs.map +1 -1
  13. package/dist/v2/index.cjs +1 -1
  14. package/dist/v2/index.mjs +1 -1
  15. package/dist/v2/index.umd.js +4 -1
  16. package/dist/v2/index.umd.js.map +1 -1
  17. package/package.json +8 -9
  18. package/dist/copilotkit-B4Jb1QEy.cjs.map +0 -1
  19. package/dist/copilotkit-snbJkMqQ.mjs.map +0 -1
  20. package/skills/react-core/SKILL.md +0 -110
  21. package/skills/react-core/references/agent-access.md +0 -398
  22. package/skills/react-core/references/attachments.md +0 -311
  23. package/skills/react-core/references/capabilities.md +0 -138
  24. package/skills/react-core/references/chat-components.md +0 -246
  25. package/skills/react-core/references/client-side-tools.md +0 -358
  26. package/skills/react-core/references/custom-message-renderers.md +0 -223
  27. package/skills/react-core/references/debug-mode.md +0 -140
  28. package/skills/react-core/references/human-in-the-loop.md +0 -312
  29. package/skills/react-core/references/provider-setup.md +0 -358
  30. package/skills/react-core/references/rendering-activity-messages.md +0 -201
  31. package/skills/react-core/references/rendering-tool-calls.md +0 -319
  32. package/skills/react-core/references/suggestions.md +0 -211
  33. package/skills/react-core/references/switching-agents-recipes.md +0 -161
  34. package/skills/react-core/references/switching-agents.md +0 -240
  35. package/skills/react-core/references/threads.md +0 -289
@@ -1,358 +0,0 @@
1
- # CopilotKit Client-Side Tools (React)
2
-
3
- This skill builds on `copilotkit/provider-setup`. Tools registered via
4
- `useFrontendTool` execute in the browser and are exposed to the agent over
5
- AG-UI.
6
-
7
- Hook signature:
8
-
9
- ```ts
10
- useFrontendTool<T>(tool: ReactFrontendTool<T>, deps?: ReadonlyArray<unknown>);
11
- ```
12
-
13
- The hook re-registers when `tool.name`, `tool.available`, or any entry in
14
- `deps` changes. Closures inside `handler` capture React state at
15
- registration time — pass `deps` when the handler references state.
16
-
17
- ## UI-kit detection rule
18
-
19
- Before writing any `render` JSX, check the consumer's `package.json` for a
20
- UI kit and reuse its primitives:
21
-
22
- - `components/ui/*` (shadcn)
23
- - `@mui/material` (MUI)
24
- - `@chakra-ui/react` (Chakra)
25
- - `antd` (Ant Design)
26
- - `@mantine/core` (Mantine)
27
-
28
- Only write raw JSX if no kit is present.
29
-
30
- ## Setup
31
-
32
- ```tsx
33
- "use client";
34
- import { useFrontendTool } from "@copilotkit/react-core/v2";
35
- import { z } from "zod";
36
-
37
- export function SearchToolHost() {
38
- useFrontendTool({
39
- name: "searchDocs",
40
- description: "Search the in-app documentation",
41
- parameters: z.object({ query: z.string() }),
42
- handler: async ({ query }, { signal }) => {
43
- const r = await fetch(`/api/search?q=${encodeURIComponent(query)}`, {
44
- signal,
45
- });
46
- return (await r.json()).results.join("\n");
47
- },
48
- });
49
- return null;
50
- }
51
- ```
52
-
53
- `zod` is a hard peer dependency — install it alongside `@copilotkit/react-core`.
54
-
55
- ## Core Patterns
56
-
57
- ### Handler with React state + deps
58
-
59
- ```tsx
60
- const [cart, setCart] = useState<string[]>([]);
61
-
62
- useFrontendTool(
63
- {
64
- name: "addItem",
65
- parameters: z.object({ id: z.string() }),
66
- handler: async ({ id }) => {
67
- setCart((c) => [...c, id]);
68
- },
69
- },
70
- [setCart],
71
- );
72
- ```
73
-
74
- ### Forward `signal` into fetch (so `stopAgent` cancels in-flight calls)
75
-
76
- ```tsx
77
- useFrontendTool({
78
- name: "search",
79
- parameters: z.object({ q: z.string() }),
80
- handler: async ({ q }, { signal }) => {
81
- const r = await fetch(`/search?q=${q}`, { signal });
82
- return r.text();
83
- },
84
- });
85
- ```
86
-
87
- ### Render progress UI for a tool (reuse the consumer's UI kit)
88
-
89
- ```tsx
90
- // Consumer has shadcn → use Card + Skeleton
91
- import { Card, CardContent } from "@/components/ui/card";
92
- import { Skeleton } from "@/components/ui/skeleton";
93
-
94
- useFrontendTool({
95
- name: "show",
96
- parameters: z.object({ id: z.string() }),
97
- handler: async ({ id }) => fetchItem(id),
98
- render: ({ status, parameters, result }) => (
99
- <Card>
100
- {status === "inProgress" ? (
101
- <Skeleton className="h-24 w-full" />
102
- ) : (
103
- <CardContent>{result}</CardContent>
104
- )}
105
- </Card>
106
- ),
107
- });
108
- ```
109
-
110
- ### Programmatic invocation with string follow-up
111
-
112
- `copilotkit.runTool` accepts `followUp: boolean | "generate" | string`.
113
- A string is injected as a synthetic user message before the agent runs.
114
-
115
- ```tsx
116
- import { useCopilotKit } from "@copilotkit/react-core/v2";
117
-
118
- const { copilotkit } = useCopilotKit();
119
-
120
- await copilotkit.runTool({
121
- name: "searchDocs",
122
- parameters: { query: "zod" },
123
- followUp: "Summarize these results in 3 bullets", // inject as user message, run agent
124
- });
125
- ```
126
-
127
- ## Common Mistakes
128
-
129
- ### CRITICAL — Writing JSX from scratch for `render` when the app has a UI kit
130
-
131
- Wrong:
132
-
133
- ```tsx
134
- useFrontendTool({
135
- name: "show",
136
- parameters: z.object({ id: z.string() }),
137
- handler,
138
- render: ({ status }) => <div style={{ padding: 12 }}>…</div>,
139
- });
140
- ```
141
-
142
- Correct:
143
-
144
- ```tsx
145
- // First check package.json for shadcn / @mui/* / @chakra-ui/* / antd / @mantine/*, then:
146
- import { Card, CardContent } from "@/components/ui/card";
147
- import { Skeleton } from "@/components/ui/skeleton";
148
-
149
- useFrontendTool({
150
- name: "show",
151
- parameters: z.object({ id: z.string() }),
152
- handler,
153
- render: ({ status, result }) => (
154
- <Card>
155
- {status === "inProgress" ? (
156
- <Skeleton />
157
- ) : (
158
- <CardContent>{result}</CardContent>
159
- )}
160
- </Card>
161
- ),
162
- });
163
- ```
164
-
165
- Consumers almost always have a UI kit. Raw JSX produces unbranded output
166
- and skips the accessibility patterns their existing primitives encode.
167
-
168
- Source: maintainer interview (Phase 2c)
169
-
170
- ### HIGH — Stale closure inside `handler`
171
-
172
- Wrong:
173
-
174
- ```tsx
175
- useFrontendTool({
176
- name: "addItem",
177
- parameters: z.object({ id: z.string() }),
178
- handler: async ({ id }) => {
179
- addTo(cart, id); // `cart` is captured at registration — goes stale
180
- },
181
- });
182
- ```
183
-
184
- Correct:
185
-
186
- ```tsx
187
- useFrontendTool(
188
- {
189
- name: "addItem",
190
- parameters: z.object({ id: z.string() }),
191
- handler: async ({ id }) => {
192
- addTo(cart, id);
193
- },
194
- },
195
- [cart],
196
- );
197
- ```
198
-
199
- `useFrontendTool` only re-registers when `name`, `available`, or `deps`
200
- change. Without `deps`, closures over React state freeze at first mount.
201
-
202
- Source: `packages/react-core/src/v2/hooks/use-frontend-tool.tsx:45`
203
-
204
- ### HIGH — Ignoring `signal` in async handlers
205
-
206
- Wrong:
207
-
208
- ```tsx
209
- useFrontendTool({
210
- name: "search",
211
- parameters: z.object({ q: z.string() }),
212
- handler: async ({ q }) => (await fetch(`/search?q=${q}`)).text(),
213
- });
214
- ```
215
-
216
- Correct:
217
-
218
- ```tsx
219
- useFrontendTool({
220
- name: "search",
221
- parameters: z.object({ q: z.string() }),
222
- handler: async ({ q }, { signal }) =>
223
- (await fetch(`/search?q=${q}`, { signal })).text(),
224
- });
225
- ```
226
-
227
- `stopAgent` / `agent.abortRun` abort via `AbortSignal`. A handler that
228
- doesn't forward `signal` keeps fetching after cancel, racing the next turn.
229
-
230
- Source: `packages/core/src/types.ts:24-30`
231
-
232
- ### HIGH — Assuming `followUp` defaults to `false`
233
-
234
- Wrong:
235
-
236
- ```tsx
237
- useFrontendTool({
238
- name: "logAnalyticsEvent",
239
- parameters: z.object({ name: z.string() }),
240
- handler: async ({ name }) => {
241
- analytics.track(name);
242
- },
243
- // followUp omitted → defaults to TRUE. Agent re-runs after every analytics call.
244
- });
245
- ```
246
-
247
- Correct:
248
-
249
- ```tsx
250
- useFrontendTool({
251
- name: "logAnalyticsEvent",
252
- parameters: z.object({ name: z.string() }),
253
- handler: async ({ name }) => {
254
- analytics.track(name);
255
- },
256
- followUp: false, // side-effect tool — don't re-invoke the agent
257
- });
258
- ```
259
-
260
- For agent-invoked tools, run-handler checks `tool?.followUp !== false` — so
261
- `undefined` AND `true` both fire a follow-up `runAgent`. Only explicit
262
- `false` suppresses it. Pure side-effect tools must opt out or they loop.
263
-
264
- Source: `packages/core/src/core/run-handler.ts:607`
265
-
266
- ### HIGH — Missing `zod` peer dependency
267
-
268
- Wrong:
269
-
270
- ```bash
271
- pnpm install @copilotkit/react-core
272
- # zod missing — the CopilotKit provider fails to load
273
- ```
274
-
275
- Correct:
276
-
277
- ```bash
278
- pnpm install @copilotkit/react-core zod
279
- ```
280
-
281
- `zod` is a hard peer of `@copilotkit/react-core` and is imported at
282
- provider module scope. Without it the provider module throws on load.
283
-
284
- Source: `packages/react-core/package.json` (peerDependencies)
285
-
286
- ### MEDIUM — Duplicate tool name across hooks
287
-
288
- Wrong:
289
-
290
- ```tsx
291
- // ComponentA
292
- useFrontendTool({ name: "save", parameters, handler: saveA });
293
- // ComponentB mounted in same tree:
294
- useFrontendTool({ name: "save", parameters, handler: saveB });
295
- // console.warn: "Tool 'save' already exists … Overriding"
296
- ```
297
-
298
- Correct:
299
-
300
- ```tsx
301
- useFrontendTool({
302
- name: "save",
303
- agentId: "research",
304
- parameters,
305
- handler: saveA,
306
- });
307
- useFrontendTool({
308
- name: "save",
309
- agentId: "coding",
310
- parameters,
311
- handler: saveB,
312
- });
313
- ```
314
-
315
- Tool names must be globally unique per `agentId`. Second mount warns and
316
- replaces the first. Scope with `agentId` when multiple agents need their
317
- own "save" handler.
318
-
319
- Source: `packages/react-core/src/v2/hooks/use-frontend-tool.tsx:17-22`
320
-
321
- ### MEDIUM — Passing `"generate"` or a string to `useFrontendTool`'s `followUp`
322
-
323
- Wrong:
324
-
325
- ```tsx
326
- useFrontendTool({
327
- name: "searchDocs",
328
- parameters: z.object({ q: z.string() }),
329
- handler,
330
- followUp: "Summarize these results" as any, // silently truthy on registered tools
331
- });
332
- ```
333
-
334
- Correct:
335
-
336
- ```tsx
337
- // Registered tools — boolean only:
338
- useFrontendTool({
339
- name: "searchDocs",
340
- parameters: z.object({ q: z.string() }),
341
- handler,
342
- followUp: true,
343
- });
344
-
345
- // For string follow-ups, call runTool programmatically:
346
- const { copilotkit } = useCopilotKit();
347
- await copilotkit.runTool({
348
- name: "searchDocs",
349
- parameters: { q: "zod" },
350
- followUp: "Summarize these results", // injects user message, runs agent
351
- });
352
- ```
353
-
354
- `FrontendTool.followUp` is typed `boolean`. Strings are silently truthy
355
- (treated as `true`). The `"generate"` and custom-string modes only work
356
- on `copilotkit.runTool({ followUp })`.
357
-
358
- Source: `packages/core/src/types.ts:39`; `packages/core/src/core/run-handler.ts:47,763,848-863`
@@ -1,223 +0,0 @@
1
- # CopilotKit Custom Message Renderers (React)
2
-
3
- This skill builds on `copilotkit/provider-setup` and
4
- `copilotkit/chat-components`. `useRenderCustomMessages` is consumed
5
- internally by `<CopilotChat>` / `<CopilotChatView>`.
6
-
7
- Key rules:
8
-
9
- - Renderers are passed to the `CopilotKit` provider via `renderCustomMessages`.
10
- - The hook returns `null` when called outside `CopilotChatConfigurationProvider`.
11
- - First non-null result wins — agent-scoped renderers evaluated first.
12
- - `stateSnapshot` is `undefined` before the run's `runId` resolves.
13
-
14
- ## Setup
15
-
16
- ```tsx
17
- "use client";
18
- import { CopilotKit } from "@copilotkit/react-core/v2";
19
- import type { ReactCustomMessageRenderer } from "@copilotkit/react-core/v2";
20
- import { useMemo } from "react";
21
- import { Button } from "@/components/ui/button";
22
-
23
- const CopyButton: ReactCustomMessageRenderer = {
24
- render: ({ message, position }) => {
25
- if (position !== "after") return null;
26
- if (message.role !== "assistant") return null;
27
- const content = typeof message.content === "string" ? message.content : "";
28
- if (!content) return null;
29
- return (
30
- <Button
31
- variant="ghost"
32
- size="sm"
33
- onClick={() => navigator.clipboard.writeText(content)}
34
- >
35
- Copy
36
- </Button>
37
- );
38
- },
39
- };
40
-
41
- export function Providers({ children }: { children: React.ReactNode }) {
42
- const renderers = useMemo(() => [CopyButton], []);
43
- return (
44
- <CopilotKit runtimeUrl="/api/copilotkit" renderCustomMessages={renderers}>
45
- {children}
46
- </CopilotKit>
47
- );
48
- }
49
- ```
50
-
51
- ## Core Patterns
52
-
53
- ### State-snapshot viewer after completed runs
54
-
55
- ```tsx
56
- const StateSnapshotRenderer: ReactCustomMessageRenderer = {
57
- render: ({ message, position, stateSnapshot }) => {
58
- if (position !== "after") return null;
59
- if (message.role !== "assistant") return null;
60
- if (!stateSnapshot) return null; // run not yet resolved
61
- return (
62
- <details>
63
- <summary>Agent state</summary>
64
- <pre>{JSON.stringify(stateSnapshot, null, 2)}</pre>
65
- </details>
66
- );
67
- },
68
- };
69
- ```
70
-
71
- ### Agent-scoped renderer
72
-
73
- ```tsx
74
- const ResearchNotes: ReactCustomMessageRenderer = {
75
- agentId: "research",
76
- render: ({ message, position, stateSnapshot }) => {
77
- if (position !== "after" || !stateSnapshot) return null;
78
- const notes = (stateSnapshot as { notes?: string[] }).notes ?? [];
79
- return (
80
- <ul>
81
- {notes.map((n, i) => (
82
- <li key={i}>{n}</li>
83
- ))}
84
- </ul>
85
- );
86
- },
87
- };
88
- ```
89
-
90
- ### Debug panel before user messages
91
-
92
- ```tsx
93
- const DebugBefore: ReactCustomMessageRenderer = {
94
- render: ({ message, position, messageIndex, runId }) => {
95
- if (position !== "before" || message.role !== "user") return null;
96
- // `runId` is always a string, but it falls back to a synthetic
97
- // "missing-run-id:<messageId>" value before a run is registered.
98
- // Slice only when it looks like a real id, otherwise show a dash.
99
- const shortId = runId?.startsWith("missing-run-id:")
100
- ? "—"
101
- : (runId?.slice(0, 6) ?? "—");
102
- return (
103
- <div style={{ opacity: 0.5, fontSize: 11 }}>
104
- #{messageIndex} · run {shortId}
105
- </div>
106
- );
107
- },
108
- };
109
- ```
110
-
111
- ## Common Mistakes
112
-
113
- ### HIGH — Using the hook outside a chat configuration provider
114
-
115
- Wrong:
116
-
117
- ```tsx
118
- // Component mounted outside <CopilotChat>/<CopilotChatView>
119
- function StandaloneRenderer() {
120
- const render = useRenderCustomMessages(); // returns null — no chat config in tree
121
- return render ? render({ message, position: "after" }) : null;
122
- }
123
- ```
124
-
125
- Correct:
126
-
127
- ```tsx
128
- // Option A — register renderers via the provider prop so <CopilotChat> picks them up:
129
- <CopilotKit renderCustomMessages={renderers}>
130
- <CopilotChat agentId="default" />
131
- </CopilotKit>;
132
-
133
- // Option B — call the hook only inside a chat-configured subtree:
134
- import { CopilotChatConfigurationProvider } from "@copilotkit/react-core/v2";
135
- <CopilotChatConfigurationProvider agentId="default">
136
- <ComponentThatCallsUseRenderCustomMessages />
137
- </CopilotChatConfigurationProvider>;
138
- ```
139
-
140
- `useRenderCustomMessages` returns `null` when there is no
141
- `CopilotChatConfigurationProvider` in the tree. `<CopilotChat>` wraps its
142
- children in one automatically; direct use outside a chat component
143
- requires the explicit wrapper.
144
-
145
- Source: `packages/react-core/src/v2/hooks/use-render-custom-messages.tsx:15-17`
146
-
147
- ### MEDIUM — Relying on `stateSnapshot` during early streaming
148
-
149
- Wrong:
150
-
151
- ```tsx
152
- render: ({ stateSnapshot }) => <pre>{JSON.stringify(stateSnapshot.items)}</pre>;
153
- // Crashes during the first token — stateSnapshot is undefined before runId resolves.
154
- ```
155
-
156
- Correct:
157
-
158
- ```tsx
159
- render: ({ stateSnapshot }) => (
160
- <pre>{stateSnapshot ? JSON.stringify(stateSnapshot.items) : "…"}</pre>
161
- );
162
- ```
163
-
164
- `stateSnapshot` comes from `copilotkit.getStateByRun(agentId, threadId,
165
- runId)`. `runId` is `undefined` until the run is registered, so the
166
- snapshot starts `undefined` and only becomes truthy after the first
167
- state emit. Guard with a fallback.
168
-
169
- Source: `packages/react-core/src/v2/hooks/use-render-custom-messages.tsx:69-71`
170
-
171
- ### MEDIUM — Expecting every renderer in the array to run
172
-
173
- Wrong:
174
-
175
- ```tsx
176
- // Both renderers want to add an "after assistant" button and return <div>…</div>
177
- // Only the first one (or the agent-scoped one) fires — the second is skipped.
178
- const renderers = [Renderer1, Renderer2];
179
- ```
180
-
181
- Correct:
182
-
183
- ```tsx
184
- // Merge the two into a single renderer that returns one element:
185
- const Combined: ReactCustomMessageRenderer = {
186
- render: (props) => (
187
- <div className="flex gap-1">
188
- <Renderer1Inner {...props} />
189
- <Renderer2Inner {...props} />
190
- </div>
191
- ),
192
- };
193
- ```
194
-
195
- The hook iterates the sorted renderer list and breaks at the first non-null
196
- result. Two independent renderers returning JSX for the same
197
- `(message, position)` pair will have only one fire. Compose them into a
198
- single renderer if you want both to appear.
199
-
200
- Source: `packages/react-core/src/v2/hooks/use-render-custom-messages.tsx:73-95`
201
-
202
- ### MEDIUM — Memoization miss on `renderCustomMessages` array
203
-
204
- Wrong:
205
-
206
- ```tsx
207
- <CopilotKit
208
- renderCustomMessages={[CopyButton, DebugBefore]} // fresh array every render
209
- />
210
- ```
211
-
212
- Correct:
213
-
214
- ```tsx
215
- const renderers = useMemo(() => [CopyButton, DebugBefore], []);
216
- <CopilotKit renderCustomMessages={renderers} />;
217
- ```
218
-
219
- The provider's stable-array-prop diff console-errors when a new array
220
- identity appears every render and thrashes renderer registration.
221
- Memoize or hoist.
222
-
223
- Source: `packages/react-core/src/v2/providers/CopilotKitProvider.tsx` (useStableArrayProp)
@@ -1,140 +0,0 @@
1
- # CopilotKit Debug Mode (React)
2
-
3
- This skill builds on `copilotkit/provider-setup`. Both debug surfaces are
4
- props on the `CopilotKit` provider (from `@copilotkit/react-core/v2`).
5
-
6
- Two independent knobs:
7
-
8
- 1. `enableInspector` disables the development-only visual Inspector when set
9
- to `false`.
10
- 2. `debug` controls console logging for the event pipeline.
11
-
12
- The Inspector is always off in production. Configure `debug` separately for
13
- the logging behavior you need.
14
-
15
- ## Setup
16
-
17
- ```tsx
18
- "use client";
19
- import { CopilotKit } from "@copilotkit/react-core/v2";
20
-
21
- export function Providers({ children }: { children: React.ReactNode }) {
22
- return (
23
- <CopilotKit
24
- runtimeUrl="/api/copilotkit"
25
- debug={{ events: true, lifecycle: true, verbose: false }}
26
- >
27
- {children}
28
- </CopilotKit>
29
- );
30
- }
31
- ```
32
-
33
- The Inspector is enabled automatically in development browser builds on any
34
- host. Production builds never load it.
35
-
36
- ## Core Patterns
37
-
38
- ### Full payload logging during a repro
39
-
40
- `debug: true` enables `events + lifecycle` but keeps `verbose` off to avoid
41
- leaking PII by default. For a bug repro, explicitly set `verbose: true` to
42
- dump full message/tool-call payloads.
43
-
44
- ```tsx
45
- <CopilotKit
46
- runtimeUrl="/api/copilotkit"
47
- debug={{ events: true, lifecycle: true, verbose: true }}
48
- />
49
- ```
50
-
51
- ### Disable the Inspector in development
52
-
53
- ```tsx
54
- <CopilotKit runtimeUrl="/api/copilotkit" enableInspector={false} />
55
- ```
56
-
57
- Use this when you want no Inspector FAB in local development. Production
58
- builds never load the Inspector.
59
-
60
- ## Common Mistakes
61
-
62
- ### HIGH — Using `showDevConsole` to control the Inspector
63
-
64
- Wrong:
65
-
66
- ```tsx
67
- <CopilotKit runtimeUrl="/api/copilotkit" showDevConsole="auto" />
68
- ```
69
-
70
- Correct:
71
-
72
- ```tsx
73
- <CopilotKit runtimeUrl="/api/copilotkit" />
74
- ```
75
-
76
- `showDevConsole` no longer controls Inspector visibility. Omit it. The
77
- Inspector is on in development and off in production.
78
-
79
- Source: `packages/react-core/src/v2/providers/CopilotKitProvider.tsx:301-321`
80
-
81
- ### MEDIUM — Expecting `debug: true` to log full payloads
82
-
83
- Wrong:
84
-
85
- ```tsx
86
- <CopilotKit debug={true} />
87
- // Then wondering why message contents aren't in the console
88
- ```
89
-
90
- Correct:
91
-
92
- ```tsx
93
- <CopilotKit debug={{ events: true, lifecycle: true, verbose: true }} />
94
- ```
95
-
96
- `debug: true` is shorthand for `{ events: true, lifecycle: true, verbose: false }`.
97
- `verbose` defaults to `false` to avoid logging user message bodies / tool
98
- arguments / state snapshots — it must be opted into explicitly.
99
-
100
- Source: `docs/snippets/shared/troubleshooting/debug-mode.mdx:85-93`
101
-
102
- ### MEDIUM — Passing fields that aren't in `DebugConfig`
103
-
104
- Wrong:
105
-
106
- ```tsx
107
- <CopilotKit debug={{ events: true, network: true, errors: true }} />
108
- ```
109
-
110
- Correct:
111
-
112
- ```tsx
113
- <CopilotKit debug={{ events: true, lifecycle: true, verbose: true }} />
114
- ```
115
-
116
- `DebugConfig` has exactly three fields: `events`, `lifecycle`, `verbose`.
117
- Anything else is silently ignored by the type-narrowing at the provider.
118
-
119
- Source: `packages/react-core/src/v2/providers/CopilotKitProvider.tsx` (DebugConfig type)
120
-
121
- ### MEDIUM — Inspector crashing in sandboxed iframes
122
-
123
- Wrong:
124
-
125
- ```tsx
126
- // App embedded in a sandboxed iframe with the development Inspector enabled
127
- <CopilotKit runtimeUrl="..." />
128
- ```
129
-
130
- Correct:
131
-
132
- ```tsx
133
- <CopilotKit runtimeUrl="..." enableInspector={false} />
134
- ```
135
-
136
- The inspector persists its anchor via `localStorage`. In sandboxed iframes
137
- without storage access, `loadInspectorState` throws on mount. Disable it for
138
- an iframe deployment or whitelist storage in the sandbox attrs.
139
-
140
- Source: `packages/web-inspector/src/lib/persistence.ts` (`loadInspectorState`)