Community编程与开发github.com

OpenClaw 调试

调试 OpenClaw 模型/提供者/工具表面/代码模式/流式与实时/Crabbox 行为;在代码修改前选择日志、探测点和证明路径;获取存储的会话、转录和附件作为证据。

OpenClaw 调试 是什么?

OpenClaw 调试技能为开发者提供了一套系统化的方法论和实用命令,用于诊断 OpenClaw AI 代理平台中不同行为差异(如本地测试、线上模型、不同提供商、代码模式、工具搜索、Crabbox 和 CI)。它强调在猜测之前获取可靠的调试信号,避免了盲目切换模型或环境。该技能详细说明了如何启用精确的调试标志来监控模型传输、有效载荷和 SSE 事件,以及如何检查工具表面、配置激活状态和提供者负载。此外,它还提供了通过 CLI 或直接查询 SQLite 数据库来获取聊天会话、完整转录和附件作为证据的方法。关键代码路径的引用使开发人员能够快速定位到源代码中的相关模块。最后,它根据错误类型指导选择最有效的证明方法(如本地测试、文档检查或实时提供商测试),并建议标准的报告格式。

兼容平台~Claude Code✓Codex CLI~Cursor
npx skills add https://github.com/clawdbot/clawdbot/tree/main/.agents/skills/openclaw-debugging

Installed? Explore more 编程与开发 skills: steipete/bluebubbles, steipete/eightctl, steipete/blucli · View all 6 →

在你喜欢的 AI 中提问

打开一个已预加载此 Agent Skill 的新对话。

文档

OpenClaw 调试 是做什么的?

本地测试、线上模型、提供商、代码模式、工具搜索、Crabbox、CI 之间的行为有所不同:在猜测之前获取调试信号。

先阅读

  • docs/logging.md:日志文件、openclaw logs、目标调试标志。
  • docs/reference/test.md:本地测试命令。
  • docs/tools/code-mode.md:代码模式执行/等待 + 工具目录规则。
  • $openclaw-testing:测试通道选择。
  • $crabbox:广泛的、Docker、包、Linux、线上密钥、CI 等效证明。

默认循环

  1. 陈述可疑边界:配置、工具构建、提供商负载、获取、流式/SSE、转录回放、工作器/运行时、包/分发、CI。
  2. 添加/启用最窄的证明边界的信号。
  3. 使用相同的提供商/模型/配置复现。切勿随机切换模型,除非模型本身就是被测变量。
  4. 比较配置状态与实际运行激活状态。
  5. 修补根本原因。
  6. 重新运行确切的失败探测点;仅在约定要求时才扩大范围。

模型传输日志

模型请求形状/流时间:使用针对性的环境标志而非全局调试:

OPENCLAW_DEBUG_MODEL_TRANSPORT=1 openclaw gateway
OPENCLAW_DEBUG_MODEL_PAYLOAD=tools OPENCLAW_DEBUG_SSE=events openclaw gateway
OPENCLAW_DEBUG_MODEL_PAYLOAD=full-redacted OPENCLAW_DEBUG_SSE=peek openclaw gateway

有用的标志:

  • OPENCLAW_DEBUG_MODEL_TRANSPORT=1:请求开始、获取响应、SDK 标头、第一个 SSE 事件、流完成、传输错误,记录在 info 级别。
  • OPENCLAW_DEBUG_MODEL_PAYLOAD=summary:限制的有效载荷摘要。
  • OPENCLAW_DEBUG_MODEL_PAYLOAD=tools:所有面向模型的工具名称。
  • OPENCLAW_DEBUG_MODEL_PAYLOAD=full-redacted:带大小限制且经过编辑的 JSON 有效载荷。仅在调试时使用;提示/消息文本仍可能出现。
  • OPENCLAW_DEBUG_SSE=events:第一个事件 + 流完成时间。
  • OPENCLAW_DEBUG_SSE=peek:前五个经过编辑的 SSE 事件。
  • OPENCLAW_DEBUG_CODE_MODE=1:代码模式工具表面诊断。

观察日志:

openclaw logs --follow

常见边界

  • 配置 vs 激活: 已启用的配置可能与禁用的运行工具、原始运行、空的允许列表、缺失的模型工具支持共存。在执行提供商负载不变性检查之前,请检查实际可见的工具。
  • 工具表面: 检查最终模型可见的工具名称,而不仅仅是注册表/配置。代码模式 = 在实际激活后仅有 exec + wait。
  • 提供商负载: 在 SDK 调用之前,记录字段、模型 ID、服务层级、推理、输入大小、元数据键、提示缓存键存在性、工具名称。
  • 获取 vs SSE: fetch 响应证明 HTTP 标头已到达;第一个 SSE 事件证明提供商正文处理正在进行。这里的差距表示流/正文/提供商问题,而不是工具执行问题。
  • 工作器/分发包: 涉及工作器、动态导入、包导出、懒加载运行时边界、发布路径 → pnpm build。
  • 线上密钥: 缺少提供商密钥 → 在声明线上证明受阻之前,配置好密钥工作流。环境变量检查只检查存在性;绝不打印密钥。

获取会话和转录

聊天会话错误报告:获取实际的转录、发送者归属、附件作为证据。

首先使用 CLI(需要已配置的安装;对线上 Gateway 安全):

openclaw sessions list --agent <agentId> --json
openclaw sessions tail
openclaw sessions export-trajectory

文档:存储布局 docs/reference/database-schemas.md; CLI https://docs.openclaw.ai/cli/sessions。

原始存储:当 CLI 不可用(例如通过 SSH 远程主机)或需要事件级细节时:

  • 每个代理的数据平面:~/.openclaw/agents/<agentId>/agent/openclaw-agent.sqlite。 规范模式:src/state/openclaw-agent-schema.sql。
  • 托管/systemd 状态:服务用户的主目录(例如 /home/openclaw/.openclaw/...), 而非 root 用户。root 用户可能拥有包含不同代理的单独误安装。 如果预期的代理目录缺失:使用 find / -maxdepth 6 -name openclaw-agent.sqlite 定位真实的数据库。
  • Web 聊天 URL 会话 ID 片段:/chat/<agentId>/<slug>-<hex>。 在 session_nodes 中解析:session_key LIKE '%<hex>%' → current_session_id、display_name。键的形状: agent:<agentId>:<surface>:<uuid>;子代理会话使用表面 subagent。
  • 转录:transcript_events(session_id、seq、event_json)。 event_json.message:role(user/assistant/toolResult)+ content(字符串或 text/toolCall/image 类型的部分)。
  • 发送者来源:真实的用户消息带有 message.__openclaw (senderId、senderName、senderIsOwner);运行时合成的输入则没有。 使用此字段区分操作员编写的文本和注入的提示。
  • 全文转录搜索:session_transcript_fts。
  • 附件:media://inbound/<file> URL → <state-dir>/media/inbound/<file>。
  • 用户附加的图片 ≠ image 内容部分。消息信封携带 message.__openclaw.media[] 条目:url(media://inbound/<file>)、 contentType、kind、fileName。仅提取部分的提取器会遗漏所有图片; 在原始 event_json 中搜索 media://。远程主机:使用 scp 将文件复制到本地 (每个 scp 参数一个远程路径);在那里读取。

没有 sqlite3 二进制的主机仍有 Node:node:sqlite 无需依赖。

node -e 'const {DatabaseSync}=require("node:sqlite");
const db=new DatabaseSync(process.argv[1],{readOnly:true});
console.log(JSON.stringify(db.prepare(
  "SELECT seq,event_json FROM transcript_events WHERE session_id=? ORDER BY seq"
).all(process.argv[2])))' <db-path> <session-id>
  • 始终以 readOnly: true 打开在线存储;切勿写入正在运行的 Gateway 的状态 (根目录 AGENTS.md 验证规则)。
  • 处理真实数据工作:首先将数据库复制到开发状态目录。

代码指针

  • 模型负载 + 响应流: src/agents/openai-transport-stream.ts
  • 受保护的获取/计时: src/agents/provider-transport-fetch.ts
  • OpenAI/Codex 提供者包装器: src/llm/providers/stream-wrappers/openai.ts
  • 工具构造、工具搜索、代码模式激活: src/agents/embedded-agent-runner/run/attempt.ts
  • 代码模式运行时和工作器: src/agents/code-mode.ts extensions/code-mode-quickjs/src/code-mode.worker.ts
  • 工具搜索目录: src/agents/tool-search.ts

证明选择

  • 单个辅助函数/负载错误:本地针对性的 Vitest。
  • 仅文档/日志:pnpm check:docs + git diff --check。
  • 工作器/分发/懒导入/包表面:针对性的测试 + pnpm build。
  • 线上提供者/模型行为:相同的提供者/模型、调试标志、如有则使用真实密钥。
  • Docker/包/Linux/CI 等效:当前专用 Linux 工作器(如果能力足够); 否则使用 $crabbox。
  • CI 失败:确切的 SHA,仅相关作业;仅在失败/完成后查看日志。

输出习惯

报告:

  • 测试的边界
  • 确切的命令/环境形状(已编辑)
  • 观察到的信号,例如工具名称或第一个 SSE 事件时间
  • 修复位置
  • 缩小范围的证明 + 剩余风险

Individual skills in this repo

This repo contains 20 individual skills — each has its own dedicated page.

1password

Set up and use 1Password CLI for sign-in, desktop integration, and reading or injecting secrets.

acp-router

Route plain-language requests for Claude Code, Cursor, Copilot, OpenClaw ACP, OpenCode, Gemini CLI, Grok Build, Qwen, Kiro, Kimi, iFlow, Factory Droid, Kilocode, or explicit ACP harness work into either OpenClaw ACP runtime sessions or direct acpx-driven sessions ("telephone game" flow). For coding-agent thread requests, read this skill first, then use only `sessions_spawn` for thread creation. Codex chat binding defaults to the native Codex app-server plugin unless ACP is explicit or background spawn needs ACP.

add-model-provider

Add and live-prove a model provider with non-interactive config one-liners, without exposing credentials.

agent-transcript

Requested GitHub PR/issue agent transcripts: redact, trim, preview, and insert safely.

apple-notes

Create, view, edit, delete, search, move, or export Apple Notes via the memo CLI on macOS.

apple-reminders

List, add, edit, complete, or delete Apple Reminders and reminder lists via remindctl.

auto-qa

Run OpenClaw-wide autonomous QA and live/stress campaigns across independent subsystem lanes, with verified fixes and a resumable evidence report.

autoreview

Structured code review through the shared OpenClaw agent-skills installation.

bear-notes

Create, search, and manage Bear notes via grizzly CLI.

blacksmith-testbox

Run Blacksmith Testbox for CI-parity checks, secrets, hosted services, migrations, or builds local cannot reproduce.

block-kit

Use proactively for structured or interactive Slack replies, and when asked to author or validate native Slack Block Kit JSON.

blogwatcher

Monitor blogs and RSS/Atom feeds for updates using the blogwatcher CLI.

blucli

BluOS CLI (blu) for discovery, playback, grouping, and volume.

bluebubbles

Send and manage iMessages via BlueBubbles, including attachments, tapbacks, edits, replies, and groups.

browser-automation

Use when controlling web pages with the OpenClaw browser tool, especially multi-step flows, login checks, tab management, or recovery from stale refs/timeouts.

camsnap

Capture frames or clips from RTSP/ONVIF cameras and local webcams, including USB pan/tilt/zoom control.

canvas

Present HTML on connected OpenClaw node canvases, navigate/eval/snapshot, and debug canvas host URLs.

channel-message-flows

Use when running QA Lab channel message flow evidence.

clawdtributor

Clawtributor PRs here, last week or another window: discover conversation refs, recheck GitHub, rank by impact.

clawhub

Search ClawHub for plugins by default, or skills and agent Templates when requested; add Templates; install, verify, update, uninstall, publish, or sync skills.

相关技能