Files
openclaw/docs/help/debugging.md

163 lines
4.2 KiB
Markdown
Raw Permalink Normal View History

2026-01-09 03:45:14 +00:00
---
summary: "Debugging tools: watch mode, raw model streams, and tracing reasoning leakage"
read_when:
- You need to inspect raw model output for reasoning leakage
- You want to run the Gateway in watch mode while iterating
- You need a repeatable debugging workflow
title: "Debugging"
2026-01-09 03:45:14 +00:00
---
# Debugging
This page covers debugging helpers for streaming output, especially when a
provider mixes reasoning into normal text.
2026-01-09 16:38:52 +01:00
## Runtime debug overrides
Use `/debug` in chat to set **runtime-only** config overrides (memory, not disk).
`/debug` is disabled by default; enable with `commands.debug: true`.
2026-01-30 03:15:10 +01:00
This is handy when you need to toggle obscure settings without editing `openclaw.json`.
2026-01-09 16:38:52 +01:00
Examples:
```
/debug show
2026-01-30 03:15:10 +01:00
/debug set messages.responsePrefix="[openclaw]"
2026-01-09 16:38:52 +01:00
/debug unset messages.responsePrefix
/debug reset
```
`/debug reset` clears all overrides and returns to the on-disk config.
2026-01-09 03:45:14 +00:00
## Gateway watch mode
For fast iteration, run the gateway under the file watcher:
```bash
pnpm gateway:watch --force
```
This maps to:
```bash
tsx watch src/entry.ts gateway --force
```
Add any gateway CLI flags after `gateway:watch` and they will be passed through
on each restart.
2026-01-09 15:47:11 +01:00
## Dev profile + dev gateway (--dev)
Use the dev profile to isolate state and spin up a safe, disposable setup for
debugging. There are **two** `--dev` flags:
2026-01-30 03:15:10 +01:00
- **Global `--dev` (profile):** isolates state under `~/.openclaw-dev` and
2026-01-09 15:47:11 +01:00
defaults the gateway port to `19001` (derived ports shift with it).
- **`gateway --dev`: tells the Gateway to auto-create a default config +
workspace** when missing (and skip BOOTSTRAP.md).
2026-01-10 03:26:32 +01:00
Recommended flow (dev profile + dev bootstrap):
2026-01-09 15:47:11 +01:00
```bash
2026-01-10 03:26:32 +01:00
pnpm gateway:dev
2026-01-30 03:15:10 +01:00
OPENCLAW_PROFILE=dev openclaw tui
2026-01-09 15:47:11 +01:00
```
2026-01-30 03:15:10 +01:00
If you dont have a global install yet, run the CLI via `pnpm openclaw ...`.
2026-01-20 07:42:21 +00:00
2026-01-09 15:47:11 +01:00
What this does:
2026-01-31 21:13:13 +09:00
1. **Profile isolation** (global `--dev`)
2026-01-30 03:15:10 +01:00
- `OPENCLAW_PROFILE=dev`
- `OPENCLAW_STATE_DIR=~/.openclaw-dev`
- `OPENCLAW_CONFIG_PATH=~/.openclaw-dev/openclaw.json`
- `OPENCLAW_GATEWAY_PORT=19001` (browser/canvas shift accordingly)
2026-01-09 15:47:11 +01:00
2026-01-31 21:13:13 +09:00
2. **Dev bootstrap** (`gateway --dev`)
2026-01-09 15:47:11 +01:00
- Writes a minimal config if missing (`gateway.mode=local`, bind loopback).
- Sets `agent.workspace` to the dev workspace.
- Sets `agent.skipBootstrap=true` (no BOOTSTRAP.md).
- Seeds the workspace files if missing:
`AGENTS.md`, `SOUL.md`, `TOOLS.md`, `IDENTITY.md`, `USER.md`, `HEARTBEAT.md`.
- Default identity: **C3PO** (protocol droid).
2026-01-30 03:15:10 +01:00
- Skips channel providers in dev mode (`OPENCLAW_SKIP_CHANNELS=1`).
2026-01-09 15:47:11 +01:00
Reset flow (fresh start):
```bash
2026-01-10 03:26:32 +01:00
pnpm gateway:dev:reset
```
Note: `--dev` is a **global** profile flag and gets eaten by some runners.
If you need to spell it out, use the env var form:
```bash
2026-01-30 03:15:10 +01:00
OPENCLAW_PROFILE=dev openclaw gateway --dev --reset
2026-01-09 15:47:11 +01:00
```
`--reset` wipes config, credentials, sessions, and the dev workspace (using
`trash`, not `rm`), then recreates the default dev setup.
Tip: if a nondev gateway is already running (launchd/systemd), stop it first:
```bash
2026-01-30 03:15:10 +01:00
openclaw gateway stop
2026-01-09 15:47:11 +01:00
```
2026-01-30 03:15:10 +01:00
## Raw stream logging (OpenClaw)
2026-01-09 03:45:14 +00:00
2026-01-30 03:15:10 +01:00
OpenClaw can log the **raw assistant stream** before any filtering/formatting.
2026-01-09 03:45:14 +00:00
This is the best way to see whether reasoning is arriving as plain text deltas
(or as separate thinking blocks).
Enable it via CLI:
```bash
pnpm gateway:watch --force --raw-stream
```
Optional path override:
```bash
2026-01-30 03:15:10 +01:00
pnpm gateway:watch --force --raw-stream --raw-stream-path ~/.openclaw/logs/raw-stream.jsonl
2026-01-09 03:45:14 +00:00
```
Equivalent env vars:
```bash
2026-01-30 03:15:10 +01:00
OPENCLAW_RAW_STREAM=1
OPENCLAW_RAW_STREAM_PATH=~/.openclaw/logs/raw-stream.jsonl
2026-01-09 03:45:14 +00:00
```
Default file:
2026-01-30 03:15:10 +01:00
`~/.openclaw/logs/raw-stream.jsonl`
2026-01-09 03:45:14 +00:00
## Raw chunk logging (pi-mono)
To capture **raw OpenAI-compat chunks** before they are parsed into blocks,
pi-mono exposes a separate logger:
```bash
PI_RAW_STREAM=1
```
Optional path:
```bash
PI_RAW_STREAM_PATH=~/.pi-mono/logs/raw-openai-completions.jsonl
```
Default file:
`~/.pi-mono/logs/raw-openai-completions.jsonl`
> Note: this is only emitted by processes using pi-monos
> `openai-completions` provider.
## Safety notes
- Raw stream logs can include full prompts, tool output, and user data.
- Keep logs local and delete them after debugging.
- If you share logs, scrub secrets and PII first.