Debug OpenClaw model, provider, tool-surface, code-mode, streaming, and live/Crabbox behavior by choosing the right logs, probes, and proof path before changing
复制下面这句话,粘贴给 Claude Code、Codex、Cursor 等 AI 编程工具,它会读取安装说明并在你确认后完成安装。
请阅读 https://ai.atlankj.com/install/asset/gh-openclaw-debugging-24444cee1f96 ,按照其中的说明把「openclaw-debugging」安装到你(当前 AI 工具)中。执行前先告诉我将运行的命令和写入的位置,等我确认。
查看 AI 将读取的安装说明正在读取 GitHub 原文…
内容来自 GitHub 原始文件,由原作者维护。在 GitHub 查看
Use this skill when OpenClaw behavior differs between local tests, live models, providers, code mode, Tool Search, Crabbox, or CI, and the next move should be a debug signal rather than a guess.
docs/logging.md for log files, openclaw logs, and targeted debug flags.docs/reference/test.md for local test commands.docs/tools/code-mode.md for code-mode exec/wait and tool catalog rules.$openclaw-testing for choosing test lanes.$crabbox for broad, Docker, package, Linux, live-key, or CI-parity proof.Use targeted env flags instead of global debug when the model request shape or stream timing matters:
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
Useful flags:
OPENCLAW_DEBUG_MODEL_TRANSPORT=1: request start, fetch response, SDK
headers, first SSE event, stream done, and transport errors at info.OPENCLAW_DEBUG_MODEL_PAYLOAD=summary: bounded payload summary.OPENCLAW_DEBUG_MODEL_PAYLOAD=tools: all model-facing tool names.OPENCLAW_DEBUG_MODEL_PAYLOAD=full-redacted: capped, redacted JSON payload.
Use only while debugging; prompts/message text may still appear.OPENCLAW_DEBUG_SSE=events: first-event and stream-completion timing.OPENCLAW_DEBUG_SSE=peek: first five redacted SSE events.OPENCLAW_DEBUG_CODE_MODE=1: code-mode tool-surface diagnostics.Watch logs with:
openclaw logs --follow
exec and wait only after it
actually activates.pnpm build when touching workers, dynamic imports,
package exports, lazy runtime boundaries, or published paths.Use these paths when a bug report references a chat session and you need the actual transcript, sender attribution, or attachments as evidence.
CLI first (needs a configured install; safe against a live gateway):
openclaw sessions list --agent <agentId> --json
openclaw sessions tail
openclaw sessions export-trajectory
Docs: docs/reference/database-schemas.md for the store layout,
https://docs.openclaw.ai/cli/sessions for the CLI.
Raw store (when the CLI is unavailable, e.g. inspecting a remote host over SSH, or you need event-level detail):
~/.openclaw/agents/<agentId>/agent/openclaw-agent.sqlite.
Canonical schema: src/state/openclaw-agent-schema.sql./home/openclaw/.openclaw/...), not root's — root may carry a separate
stray install with different agents. If the expected agent dir is missing,
locate the real DB: find / -maxdepth 6 -name openclaw-agent.sqlite./chat/<agentId>/<slug>-<hex>.
Resolve it in session_nodes: session_key LIKE '%<hex>%' →
current_session_id, display_name. Key shape is
agent:<agentId>:<surface>:<uuid>; subagent sessions use surface subagent.transcript_events (session_id, seq, event_json).
event_json.message has role (user/assistant/toolResult) and
content (string, or parts of type text/toolCall/image).message.__openclaw
(senderId, senderName, senderIsOwner); runtime-synthesized inputs do
not. Use this to separate operator-authored text from injected prompts.session_transcript_fts.media://inbound/<file> URLs map to
<state-dir>/media/inbound/<file>.image content parts. They ride the message
envelope: message.__openclaw.media[] entries with url
(media://inbound/<file>), contentType, kind, fileName. A parts-only
extractor misses every image — grep raw event_json for media://. On a
remote host, scp the files locally (one remote path per scp argument) and
read them there.Hosts without a sqlite3 binary still have Node: node:sqlite needs no
dependencies.
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>
Always open live stores readOnly: true; never write a running gateway's
state (see Validation rules in the root AGENTS.md). For realistic-data
work, copy the DB into a dev state dir first.
src/agents/openai-transport-stream.tssrc/agents/provider-transport-fetch.tssrc/llm/providers/stream-wrappers/openai.tssrc/agents/embedded-agent-runner/run/attempt.tssrc/agents/code-mode.ts
src/agents/code-mode.worker.tssrc/agents/tool-search.tspnpm check:docs and git diff --check.pnpm build.$crabbox.Report: