7acadae
CopilotKitDocs
  • Docs
  • Integrations
  • Reference
Get Started
QuickstartCoding Agents
Concepts
ArchitectureGenerative UI OverviewOSS vs Enterprise
Agentic Protocols
OverviewAG-UIAG-UI MiddlewareMCPA2A
Build Chat UIs
Prebuilt Components
CopilotChatCopilotSidebarCopilotPopup
Custom Look and Feel
CSS CustomizationSlots (Subcomponents)Fully Headless UIReasoning Messages
Multimodal AttachmentsVoice
Build Generative UI
Controlled
Tool-based Generative UITool RenderingState RenderingReasoning
Your Components
Display ComponentsInteractive Components
Declarative
A2UIDynamic Schema A2UIFixed Schema A2UI
Open-Ended
MCP Apps
Adding Agent Powers
Frontend ToolsShared State
Human-in-the-Loop
HITL OverviewPausing the Agent for InputHeadless Interrupts
Sub-AgentsAgent ConfigProgrammatic Control
Agents & Backends
Built-in Agent
Backend
Copilot RuntimeFactory ModeAG-UI
Runtime Server AdapterAuthentication
Built-in Agent (TanStack AI)
Advanced ConfigurationMCP ServersModel SelectionServer Tools
Observe & Operate
InspectorVS Code Extension
Troubleshooting
Common Copilot IssuesError Debugging & ObservabilityDebug ModeAG-UI Event InspectorHook ExplorerError Observability Connectors
Enterprise
CopilotKit PremiumHow the Enterprise Intelligence Platform WorksHow Threads & Persistence WorkObservabilitySelf-Hosting IntelligenceThreads
Deploy
AWS AgentCore
What's New
Full MCP Apps SupportLangGraph Deep Agents in CopilotKitA2UI Launches with full AG-UI SupportCopilotKit v1.50Generative UI Spec SupportA2A and MCP Handshake
Migrate
Migrate to V2Migrate to 1.8.2
Other
Contributing
Code ContributionsDocumentation Contributions
Anonymous Telemetry
Built-in Agent (TanStack AI)TroubleshootingError Debugging & Observability

Error Debugging & Observability

Surface errors visually in development, and wire programmatic error handlers for Sentry / Datadog / your analytics pipeline in production.

How to debug errors

CopilotKit provides a visual error console for local development and a programmatic onError callback for production observability. The visual console is completely free and requires no API keys.

Quick setup#

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

export default function App() {
  return (
    <CopilotKit
      runtimeUrl="/api/copilotkit"
      showDevConsole={true} // [!code highlight]
    >
      {/* your app */}
    </CopilotKit>
  );
}
Warning

Avoid showing the dev console in production — it exposes internal error details to end users.

When to use development debugging#

  • Local development — errors appear immediately in your UI
  • Quick debugging — no setup required, works out of the box
  • Testing — verify error handling during development

Programmatic error handling#

The v2 API provides an onError callback on both CopilotKit and CopilotChat. No publicApiKey is required.

Provider-level error handling#

Catches every error across the entire application:

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

<CopilotKit
  runtimeUrl="/api/copilotkit"
  onError={(event) => {
    // event.code    — error type (e.g. "runtime_info_fetch_failed", "agent_run_failed")
    // event.error   — the Error object
    // event.context — additional context (agentId, toolName, etc.)
    console.error(`[CopilotKit ${event.code}]`, event.error.message);
    errorTracker.capture(event);
  }}
>
  <App />
</CopilotKit>;

Chat-level error handling#

Scoped to a specific chat's agent — fires in addition to the provider-level handler:

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

<CopilotChat
  agentId="my-agent"
  onError={(event) => {
    showToast(`Agent error: ${event.error.message}`);
  }}
/>;

Error codes#

CodeDescription
runtime_info_fetch_failedCould not reach the runtime's /info endpoint
agent_connect_failedAgent connection (thread setup) failed
agent_run_failedAgent run rejected (e.g. network error)
agent_run_failed_eventThe agent's onRunFailed subscriber fired
agent_run_error_eventAgent emitted a RUN_ERROR event
tool_argument_parse_failedTool call arguments were not valid JSON
tool_handler_failedA frontend tool handler threw
Info

Need to see the full event pipeline — what events your agent emits, whether they reach the client, and where they're dropped? See the Inspector for a live AG-UI event view.

Troubleshooting#

Dev console not showing#

  • Confirm showDevConsole={true}
  • Check for JavaScript errors in the browser console
  • Ensure no CSS is hiding the error banner

Production error pipeline checklist#

  • Provider-level onError is wired and forwards to your error tracker
  • showDevConsole is false in production builds
  • Agent IDs in errors match the agents registered on your runtime
  • Critical error codes (agent_run_failed, tool_handler_failed) are alerted on, not just logged
On this page
Quick setupWhen to use development debuggingProgrammatic error handlingProvider-level error handlingChat-level error handlingError codesTroubleshootingDev console not showingProduction error pipeline checklist