copilotkit-debug
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
ChineseCopilotKit Debugging Skill
CopilotKit 调试技能
When to Use
使用场景
Invoke this skill when:
- The CopilotKit runtime is unreachable or returning errors
- Agents fail to connect, respond, or stream events
- Frontend tools are not executing or returning results
- Transcription (voice) is failing
- Version mismatch errors appear between packages
- AG-UI SSE events are malformed or missing
- CORS errors block browser requests to the runtime
在以下情况调用此技能:
- CopilotKit运行时无法访问或返回错误
- Agent连接失败、无响应或事件流中断
- 前端工具无法执行或返回结果
- 语音转录功能失效
- 各包之间出现版本不匹配错误
- AG-UI SSE事件格式错误或缺失
- CORS错误阻止浏览器向运行时发送请求
Diagnostic Workflow
诊断流程
Step 1: Gather Information
步骤1:收集信息
Before proposing any fix, collect:
- Package versions -- Run (or the v1 equivalents). Version mismatches between runtime and react packages are a common root cause.
npm ls @copilotkit/runtime @copilotkit/react @copilotkit/core @ag-ui/client - Runtime mode -- Is this SSE mode () or Intelligence mode (
CopilotSseRuntime)? Check the runtime constructor.CopilotIntelligenceRuntime - Transport configuration -- What is set to in
runtimeUrl? Does it match theCopilotKitProviderinbasePath?createCopilotEndpoint - Agent type -- Is the agent a ,
BuiltInAgent,LangGraphAgent, or customA2AAgent?AbstractAgent - Error messages -- Collect the exact error from browser console and server logs. CopilotKit uses structured error codes (see ).
references/error-patterns.md - Browser network tab -- Check the request (runtime discovery), the
/infoSSE stream, and any CORS preflight failures./agent/:id/run
在提出修复方案前,先收集以下信息:
- 包版本 —— 运行 (或v1等价命令)。运行时与react包之间的版本不匹配是常见的根本原因。
npm ls @copilotkit/runtime @copilotkit/react @copilotkit/core @ag-ui/client - 运行时模式 —— 当前是SSE模式()还是智能模式(
CopilotSseRuntime)?检查运行时构造函数。CopilotIntelligenceRuntime - 传输配置 —— 中的
CopilotKitProvider设置为何值?它是否与runtimeUrl中的createCopilotEndpoint匹配?basePath - Agent类型 —— Agent是、
BuiltInAgent、LangGraphAgent还是自定义A2AAgent?AbstractAgent - 错误信息 —— 从浏览器控制台和服务器日志中收集准确的错误信息。CopilotKit使用结构化错误代码(详见)。
references/error-patterns.md - 浏览器网络面板 —— 检查请求(运行时发现)、
/infoSSE流以及任何CORS预检失败情况。/agent/:id/run
Step 2: Check Logs and Error Codes
步骤2:检查日志与错误代码
CopilotKit has three error code systems:
- V1 error codes -- Legacy error codes from the v1 runtime layer (). Codes like
@copilotkit/runtime,NETWORK_ERROR,AGENT_NOT_FOUND. Still surfaced in some contexts sinceAPI_NOT_FOUNDpackages wrap v2 internally.@copilotkit/* - V2 -- Used by
CopilotKitCoreErrorCode. Codes like@copilotkit/core,runtime_info_fetch_failed,agent_connect_failed.agent_run_failed - -- Used by both v1 and v2 for voice transcription. Codes like
TranscriptionErrorCode,service_not_configured,rate_limited.auth_failed
Match the error code to the catalog in for root cause and resolution.
references/error-patterns.mdCopilotKit拥有三套错误代码体系:
- V1错误代码 —— 来自v1运行时层()的旧版错误代码。例如
@copilotkit/runtime、NETWORK_ERROR、AGENT_NOT_FOUND。由于API_NOT_FOUND包内部封装了v2,这些代码在某些场景下仍会出现。@copilotkit/* - V2 —— 由
CopilotKitCoreErrorCode使用。例如@copilotkit/core、runtime_info_fetch_failed、agent_connect_failed。agent_run_failed - —— v1和v2均用于语音转录。例如
TranscriptionErrorCode、service_not_configured、rate_limited。auth_failed
将错误代码与中的目录匹配,找到根本原因和解决方法。
references/error-patterns.mdStep 3: Trace AG-UI Events
步骤3:追踪AG-UI事件
For streaming/agent issues, trace the AG-UI event flow:
- RunStartedEvent -- Confirms the agent run was initiated
- TextMessageStartEvent / TextMessageChunkEvent / TextMessageEndEvent -- Text streaming
- ToolCallStartEvent / ToolCallArgsEvent / ToolCallEndEvent -- Tool invocations
- ToolCallResultEvent -- Tool results flowing back
- StateSnapshotEvent / StateDeltaEvent -- Agent state synchronization
- ReasoningStartEvent / ReasoningMessageContentEvent / ReasoningMessageEndEvent -- Reasoning tokens (can cause stalls, see issue #3323)
- RunFinishedEvent -- Successful completion
- RunErrorEvent -- Agent-level error
Enable the CopilotKit Web Inspector () to see events in real time. Or check the SSE stream directly in the browser Network tab -- each event is a line in the response.
@copilotkit/web-inspectordata:text/event-stream针对流传输/Agent问题,追踪AG-UI事件流:
- RunStartedEvent —— 确认Agent运行已启动
- TextMessageStartEvent / TextMessageChunkEvent / TextMessageEndEvent —— 文本流传输
- ToolCallStartEvent / ToolCallArgsEvent / ToolCallEndEvent —— 工具调用
- ToolCallResultEvent —— 工具结果返回
- StateSnapshotEvent / StateDeltaEvent —— Agent状态同步
- ReasoningStartEvent / ReasoningMessageContentEvent / ReasoningMessageEndEvent —— 推理令牌(可能导致停滞,详见问题#3323)
- RunFinishedEvent —— 成功完成
- RunErrorEvent —— Agent级错误
启用CopilotKit Web Inspector()实时查看事件。或直接在浏览器网络面板中检查SSE流——每个事件都是响应中的行。
@copilotkit/web-inspectortext/event-streamdata:Step 4: Identify Root Cause
步骤4:定位根本原因
Use the reference documents to match symptoms to known issues:
- -- Connectivity, CORS, transport, SSE streaming
references/runtime-debugging.md - -- Agent discovery, state sync, tool execution, AG-UI protocol
references/agent-debugging.md - -- Complete error code catalog with resolutions
references/error-patterns.md - -- Step-by-step diagnostic sequences for common scenarios
references/quick-workflows.md
使用参考文档将症状与已知问题匹配:
- —— 连接性、CORS、传输、SSE流传输
references/runtime-debugging.md - —— Agent发现、状态同步、工具执行、AG-UI协议
references/agent-debugging.md - —— 完整的错误代码目录及解决方法
references/error-patterns.md - —— 常见场景的分步诊断流程
references/quick-workflows.md
Step 5: Fix and Verify
步骤5:修复与验证
- Apply the fix
- Verify the endpoint returns the expected agent list
/info - Confirm the SSE stream produces a complete event sequence (RunStarted through RunFinished)
- Check the browser console for any remaining structured errors
- 应用修复方案
- 验证端点返回预期的Agent列表
/info - 确认SSE流生成完整的事件序列(从RunStarted到RunFinished)
- 检查浏览器控制台是否仍有结构化错误
Using mcp-docs for Live Documentation Lookups
使用mcp-docs进行实时文档查询
During debugging, use the MCP server to look up the latest CopilotKit documentation. This server provides two tools: (search documentation) and (search source code examples).
copilotkit-docssearch-docssearch-code调试期间,使用 MCP服务器查询最新的CopilotKit文档。该服务器提供两个工具:(搜索文档)和(搜索源代码示例)。
copilotkit-docssearch-docssearch-codeMCP Setup
MCP设置
Claude Code: The MCP server is auto-configured by the plugin's -- no manual setup needed. The agent can call the and tools from the server directly.
.mcp.jsonsearch-docssearch-codecopilotkit-docsCodex: Add the following to your :
.codex/config.tomltoml
[mcp_servers.copilotkit-docs]
type = "http"
url = "https://mcp.copilotkit.ai/mcp"Claude Code: MCP服务器由插件的自动配置——无需手动设置。Agent可直接从服务器调用和工具。
.mcp.jsoncopilotkit-docssearch-docssearch-codeCodex: 将以下内容添加到中:
.codex/config.tomltoml
[mcp_servers.copilotkit-docs]
type = "http"
url = "https://mcp.copilotkit.ai/mcp"Tool Usage
工具使用
The and tools are invoked as MCP tool calls (not CLI commands). Examples of what to search for during debugging:
search-docssearch-codesearch-docs("AGENT_NOT_FOUND")
search-docs("CopilotRuntime configuration")
search-docs("AG-UI protocol events")
search-docs("troubleshooting common issues")
search-docs("CORS configuration copilotkit")
search-code("CopilotRuntime error handling")The official troubleshooting docs are at:
https://docs.copilotkit.ai/troubleshooting/common-issueshttps://docs.copilotkit.ai/coagents/troubleshooting/common-issues
search-docssearch-codesearch-docs("AGENT_NOT_FOUND")
search-docs("CopilotRuntime configuration")
search-docs("AG-UI protocol events")
search-docs("troubleshooting common issues")
search-docs("CORS configuration copilotkit")
search-code("CopilotRuntime error handling")官方故障排查文档地址:
https://docs.copilotkit.ai/troubleshooting/common-issueshttps://docs.copilotkit.ai/coagents/troubleshooting/common-issues
Key File Locations in the CopilotKit Codebase
CopilotKit代码库中的关键文件位置
| Component | Path |
|---|---|
| V1 Error classes & codes | |
| V2 Core error codes | |
| V2 Transcription errors | |
| Runtime SSE response | |
| Runtime info endpoint | |
| Runtime CORS config | |
| Intelligence platform client | |
| Agent package (BuiltInAgent) | |
| Web Inspector | |
| 组件 | 路径 |
|---|---|
| V1错误类与代码 | |
| V2核心错误代码 | |
| V2转录错误 | |
| 运行时SSE响应 | |
| 运行时info端点 | |
| 运行时CORS配置 | |
| 智能平台客户端 | |
| Agent包(BuiltInAgent) | |
| Web Inspector | |