| Agent Type | Package | Description |
|---|---|---|
BuiltInAgent |
@copilotkit/agent |
Uses Vercel AI SDK streamText with configurable model providers |
LangGraphAgent |
@ag-ui/langgraph |
Wraps a LangGraph deployment (Python or JS) |
A2AAgent |
Varies | Agent-to-Agent protocol agent |
Custom AbstractAgent |
@ag-ui/client |
Any class extending AbstractAgent with a run() returning Observable<BaseEvent> |
Symptom: CopilotKitCoreErrorCode.agent_not_found or CopilotKitErrorCode.AGENT_NOT_FOUND
Diagnostic steps:
-
Hit the
/infoendpoint to see registered agents:curl http://localhost:3001/api/copilotkit/info | jq .agents -
Compare the agent names in the response with the
agentIdprop:<CopilotChat agentId="myAgent" />; // or const { run } = useAgent({ name: "myAgent" });
-
Check the runtime agent map -- keys must match exactly (case-sensitive):
new CopilotRuntime({ agents: { myAgent: new BuiltInAgent({ /* ... */ }), // Key "myAgent" is the agent ID }, });
-
If using lazy agent loading (
agents: Promise<...>), check that the promise resolves successfully.
If an agent throws during construction, the runtime may start without it:
- BuiltInAgent:
resolveModel()throws if the provider string is invalid (e.g.,"openai/"without a model name, or"unknown/model"). - LangGraphAgent: May fail if the LangGraph deployment URL is unreachable.
- A2AAgent: May fail if the A2A endpoint is misconfigured.
RunStartedEvent
-> TextMessageStartEvent (messageId)
-> TextMessageChunkEvent (delta: "Hello")
-> TextMessageChunkEvent (delta: " world")
-> TextMessageEndEvent
RunFinishedEvent
RunStartedEvent
-> TextMessageStartEvent
-> TextMessageChunkEvent (delta: "Let me check...")
-> TextMessageEndEvent
-> ToolCallStartEvent (toolCallId, toolName)
-> ToolCallArgsEvent (delta: '{"query": "weather"}')
-> ToolCallEndEvent
-> ToolCallResultEvent (result: '{"temp": 72}')
-> TextMessageStartEvent
-> TextMessageChunkEvent (delta: "The temperature is 72F")
-> TextMessageEndEvent
RunFinishedEvent
RunStartedEvent
-> RunErrorEvent (message: "...") // Non-fatal, run continues
-> TextMessageStartEvent
-> ...
RunFinishedEvent
Or for fatal errors:
RunStartedEvent
-> RunErrorEvent (message: "...") // Fatal
// Stream ends without RunFinishedEvent
RunStartedEvent
-> StateSnapshotEvent (snapshot: {...}) // Full state
-> StateDeltaEvent (delta: [{op: "replace", path: "/count", value: 5}])
-> TextMessageStartEvent
-> ...
RunFinishedEvent
RunStartedEvent
-> ReasoningStartEvent
-> ReasoningMessageStartEvent
-> ReasoningMessageContentEvent (delta: "thinking...")
-> ReasoningMessageEndEvent
-> ReasoningEndEvent
-> TextMessageStartEvent
-> TextMessageChunkEvent
-> TextMessageEndEvent
RunFinishedEvent
Known issue: Reasoning events can cause stalls if the client-side event handler does not consume them properly (issue #3323).
Symptom: Agent emits StateSnapshotEvent or StateDeltaEvent but the React component does not re-render.
Diagnostic steps:
- Verify the agent is emitting state events -- check the SSE stream in the Network tab.
- If using
useFrontendToolwith state, ensure the state shape matches what the component expects. - For LangGraph agents: verify
copilotkit_emit_stateevents are reaching the frontend (see Python SDK event prefix mismatch, issue #3519).
Symptom: Agent does not receive application context set via useAgentContext or similar hooks.
Diagnostic steps:
- Context is sent as
forwardedPropsin the AG-UIRunAgentInput. Check the request body to/agent/:id/run. - For Mastra agents: context propagation through the middleware chain may not work correctly (issue #3426).
- Verify that
useAgentContextis called inside theCopilotKitProvidertree and before the agent runs.
Error code: tool_not_found
The agent called a tool name that does not match any registered frontend tool.
Diagnostic steps:
- List registered tools by checking the AG-UI
Tool[]array in the request to/agent/:id/run. - Ensure
useFrontendToolis registered with the exact tool name (case-sensitive). - The tool must be registered BEFORE the agent run starts -- if it is registered lazily after mount, a race condition can occur.
Error code: tool_argument_parse_failed
The LLM generated arguments that do not match the tool's parameter schema.
Diagnostic steps:
- Check the
ToolCallArgsEventin the SSE stream -- thedeltafield contains the raw JSON. - Validate the JSON against the tool's schema (Zod or JSON Schema).
- This is usually an LLM issue -- consider improving the tool description or parameter descriptions.
- For Zod schema validation issues in backend actions, see issue #3198.
Error code: tool_handler_failed
The tool's execute function threw an exception.
Diagnostic steps:
- Check the browser console for the error.
- The
onErrorcallback inCopilotChatorCopilotKitProviderreceives the error with context. - Wrap the tool handler in try/catch for better error reporting.
Symptom: The tool returns a result but the agent does not produce a follow-up message.
Diagnostic steps:
- Check that
ToolCallResultEventwas emitted in the SSE stream after the tool completed. - For Human-in-the-Loop tools: the
runIdmay change after HITL resolve (issue #3456), breaking the continuation. - For mixed frontend/backend tools: OpenAI may reject the request if tool definitions conflict (issue #3424).
BuiltInAgent uses resolveModel() to convert string identifiers to Vercel AI SDK LanguageModel instances.
Supported formats:
"openai/gpt-5","openai/gpt-4o","openai/o3-mini""anthropic/claude-sonnet-4.5","anthropic/claude-opus-4""google/gemini-2.5-pro","google/gemini-2.5-flash""vertex/gemini-2.5-pro"(uses Google Vertex AI)
Common errors:
Invalid model string "..."-- Missing provider prefix or model nameUnknown provider "..." in "..."-- Unsupported provider (only openai, anthropic, google, vertex)- Missing API key --
OPENAI_API_KEY,ANTHROPIC_API_KEY, orGOOGLE_API_KEYnot set in environment
BuiltInAgent supports MCP (Model Context Protocol) clients:
new BuiltInAgent({
model: "openai/gpt-4o",
mcpClients: [
{ type: "http", url: "http://localhost:8080" },
{
type: "sse",
url: "http://localhost:8081/sse",
headers: { Authorization: "Bearer ..." },
},
],
});MCP debugging:
type: "http"usesStreamableHTTPClientTransporttype: "sse"usesSSEClientTransport- If the MCP server is unreachable, the agent may fail silently or throw during tool discovery
- Check the MCP server logs for incoming connection attempts
The CopilotKit Python SDK (v0.1.83) dispatches custom events with a "copilotkit_" prefix, but ag-ui-langgraph expects event names without that prefix. This causes copilotkit_emit_message, copilotkit_emit_state, and copilotkit_emit_tool_call to be silently dropped (issue #3519).
The official LangGraph JS template may be outdated and incompatible with current CopilotKit versions (issue #3231). Check for the latest template version.
Intelligence mode uses the CopilotKitIntelligence client to manage threads:
- 409 Conflict on createThread: Another request created the thread between get and create. Handled automatically by
getOrCreateThread. - 404 on getThread: Thread does not exist. The client will create a new one.
- Auth failures (401): Invalid
apiKeyortenantIdin the Intelligence configuration.
Intelligence mode uses WebSocket for real-time events:
- Runner WebSocket:
{wsUrl}/runner-- used by the runtime to communicate with the Intelligence platform - Client WebSocket:
{wsUrl}/client-- used by the frontend for real-time thread updates
If WebSocket connections fail:
- Check that the
wsUrlis correct (should start withwss://) - Verify the API key and tenant ID
- Check for WebSocket-blocking proxies or firewalls
- The URLs are auto-derived from the base
wsUrl--/runnerand/clientsuffixes are appended automatically
The CopilotKit Web Inspector (@copilotkit/web-inspector) provides real-time visibility into:
- AG-UI events as they flow
- Error events with error codes
- Agent state snapshots
- Tool call lifecycle
Enable it during development:
import { CopilotKitWebInspector } from "@copilotkit/web-inspector";
<CopilotKitProvider runtimeUrl="/api/copilotkit">
<CopilotKitWebInspector />
<YourApp />
</CopilotKitProvider>;