OpenClaw 的调试辅助工具,包括流式输出检查、原始模型流日志和开发模式。

运行时调试覆盖

使用 /debug 命令设置仅运行时的配置覆盖(内存,不写磁盘)。 需先启用:commands.debug: true

/debug show
/debug set messages.responsePrefix="[openclaw]"
/debug unset messages.responsePrefix
/debug reset

Session 追踪输出

使用 /trace 查看插件拥有的追踪/调试行,无需开启完整 verbose 模式:

/trace
/trace on
/trace off

插件生命周期追踪

OPENCLAW_PLUGIN_LIFECYCLE_TRACE=1 openclaw plugins install tokenjuice --force

输出示例:

[plugins:lifecycle] phase="config read" ms=6.83 status=ok command="install"
[plugins:lifecycle] phase="slot selection" ms=94.31 status=ok command="install"

CLI 启动性能分析

pnpm test:startup:bench:smoke
pnpm tsx scripts/bench-cli-startup.ts --preset real --case status --runs 3
OPENCLAW_RUN_NODE_CPU_PROF_DIR=.artifacts/cli-cpu pnpm openclaw status

Gateway Watch 模式

快速迭代时使用文件监视器运行 Gateway:

pnpm gateway:watch

默认启动/重启名为 openclaw-gateway-watch-main 的 tmux session。

# 前台模式(不使用 tmux)
pnpm gateway:watch:raw
# 禁用自动附加
OPENCLAW_GATEWAY_WATCH_ATTACH=0 pnpm gateway:watch
# CPU 性能分析
pnpm gateway:watch --benchmark

Dev Profile(开发隔离)

pnpm gateway:dev
OPENCLAW_PROFILE=dev openclaw tui

Dev profile 隔离状态到 ~/.openclaw-dev,Gateway 端口默认 19001。

重置:

pnpm gateway:dev:reset

原始流日志

pnpm gateway:watch --raw-stream
# 或
OPENCLAW_RAW_STREAM=1
OPENCLAW_RAW_STREAM_PATH=~/.openclaw/logs/raw-stream.jsonl

默认文件:~/.openclaw/logs/raw-stream.jsonl

VSCode 调试

  1. 打开 Run and Debug 面板(Ctrl+Shift+D)
  2. 选择 Rebuild and Debug Gateway 配置
  3. 点击 Start Debugging

手动方式:

export OUTPUT_SOURCE_MAPS=1
pnpm clean:dist && pnpm build
# 然后在 IDE 中选择 "Debug Gateway"

安全注意事项

  • 原始流日志可能包含完整提示词、工具输出和用户数据
  • 调试后及时删除日志
  • 分享日志前清除敏感信息和 PII

相关链接