Debugging helpers for streaming output, especially when a provider mixes reasoning into normal text.Documentation Index
Fetch the complete documentation index at: https://docs.openclaw.ai/llms.txt
Use this file to discover all available pages before exploring further.
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.
This is handy when you need to toggle obscure settings without editing openclaw.json.
Examples:
/debug reset clears all overrides and returns to the on-disk config.
Session trace output
Use/trace when you want to see plugin-owned trace/debug lines in one session
without turning on full verbose mode.
Examples:
/trace for plugin diagnostics such as Active Memory debug summaries.
Keep using /verbose for normal verbose status/tool output, and keep using
/debug for runtime-only config overrides.
Plugin lifecycle trace
UseOPENCLAW_PLUGIN_LIFECYCLE_TRACE=1 when plugin lifecycle commands feel slow
and you need a built-in phase breakdown for plugin metadata, discovery, registry,
runtime mirror, config mutation, and refresh work. The trace is opt-in and writes
to stderr, so JSON command output remains parseable.
Example:
node dist/entry.js ... after pnpm build; pnpm openclaw ...
also measures source-runner overhead.
CLI startup and command profiling
Use the checked-in startup benchmark when a command feels slow:OPENCLAW_RUN_NODE_CPU_PROF_DIR:
.cpuprofile for the
command. Use this before adding temporary instrumentation to command code.
For startup stalls that look like synchronous filesystem or module-loader work,
add Node’s sync I/O trace flag through the source runner:
pnpm gateway:watch leaves this flag disabled by default for the watched
Gateway child. Set OPENCLAW_TRACE_SYNC_IO=1 when you explicitly want Node
sync I/O trace output in watch mode.
Gateway watch mode
For fast iteration, run the gateway under the file watcher:openclaw-gateway-watch-main (or a profile/port-specific variant such as
openclaw-gateway-watch-dev-19001) and auto-attaches from interactive terminals.
Non-interactive shells, CI, and agent exec calls stay detached and print attach
instructions instead. Attach manually when needed:
--benchmark before invoking the Gateway and writes
one V8 .cpuprofile per Gateway child exit under
.artifacts/gateway-watch-profiles/. Stop or restart the watched gateway to
flush the current profile, then open it with Chrome DevTools or Speedscope:
--benchmark-dir <path> when you want profiles somewhere else.
Use --benchmark-no-force when you want the benchmarked child to skip the
default --force port cleanup and fail fast if the Gateway port is already in
use.
Benchmark mode suppresses sync-I/O trace spam by default. Set
OPENCLAW_TRACE_SYNC_IO=1 with --benchmark when you explicitly want both CPU
profiles and Node sync-I/O stack traces. In benchmark mode those trace blocks
are written to gateway-watch-output.log under the benchmark directory and
filtered from the terminal pane; normal Gateway logs remain visible.
The tmux wrapper carries common non-secret runtime selectors such as
OPENCLAW_PROFILE, OPENCLAW_CONFIG_PATH, OPENCLAW_STATE_DIR,
OPENCLAW_GATEWAY_PORT, and OPENCLAW_SKIP_CHANNELS into the pane. Put
provider credentials in your normal profile/config, or use raw foreground mode
for one-off ephemeral secrets.
If the watched Gateway exits during startup, the watcher runs
openclaw doctor --fix --non-interactive once and restarts the Gateway child.
Use OPENCLAW_GATEWAY_WATCH_AUTO_DOCTOR=0 when you want the original startup
failure without the dev-only repair pass.
The managed tmux pane also defaults to colored Gateway logs for readability;
set FORCE_COLOR=0 when starting pnpm gateway:watch to disable ANSI output.
The watcher restarts on build-relevant files under src/, extension source files,
extension package.json and openclaw.plugin.json metadata, tsconfig.json,
package.json, and tsdown.config.ts. Extension metadata changes restart the
gateway without forcing a tsdown rebuild; source and config changes still
rebuild dist first.
Add any gateway CLI flags after gateway:watch and they will be passed through on
each restart. Re-running the same watch command respawns the named tmux pane, and
the raw watcher still keeps its single-watcher lock so duplicate watcher parents
are replaced instead of piling up.
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:
- Global
--dev(profile): isolates state under~/.openclaw-devand defaults the gateway port to19001(derived ports shift with it). gateway --dev: tells the Gateway to auto-create a default config + workspace when missing (and skip BOOTSTRAP.md).
pnpm openclaw ....
What this does:
-
Profile isolation (global
--dev)OPENCLAW_PROFILE=devOPENCLAW_STATE_DIR=~/.openclaw-devOPENCLAW_CONFIG_PATH=~/.openclaw-dev/openclaw.jsonOPENCLAW_GATEWAY_PORT=19001(browser/canvas shift accordingly)
-
Dev bootstrap (
gateway --dev)- Writes a minimal config if missing (
gateway.mode=local, bind loopback). - Sets
agent.workspaceto 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: C3-PO (protocol droid).
- Skips channel providers in dev mode (
OPENCLAW_SKIP_CHANNELS=1).
- Writes a minimal config if missing (
--dev is a global profile flag and gets eaten by some runners. If you need to spell it out, use the env var form:--reset wipes config, credentials, sessions, and the dev workspace (using
trash, not rm), then recreates the default dev setup.
Raw stream logging (OpenClaw)
OpenClaw can log the raw assistant stream before any filtering/formatting. This is the best way to see whether reasoning is arriving as plain text deltas (or as separate thinking blocks). Enable it via CLI:~/.openclaw/logs/raw-stream.jsonl
Raw chunk logging (pi-mono)
To capture raw OpenAI-compat chunks before they are parsed into blocks, pi-mono exposes a separate logger:~/.pi-mono/logs/raw-openai-completions.jsonl
Note: this is only emitted by processes using pi-mono’s
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.
Debugging in VSCode
Source maps are required to enable debugging in VSCode-based IDEs because many of the generated files end up with hashed names as part of the build process. The includedlaunch.json configurations target the Gateway service, but can be adapted quickly for other purposes:
- Rebuild and Debug Gateway - Debugs the Gateway service after creating a new build
- Debug Gateway - Debugs the Gateway service of a pre-existing build
Setup
The default Rebuild and Debug Gateway configuration is batteries-included, it will automatically delete the/dist folder and rebuild the project with debugging enabled:
- Open the Run and Debug panel from the Activity Bar or press
Ctrl+Shift+D - In the IDE, ensure Rebuild and Debug Gateway is selected in the configuration dropdown and then press the Start Debugging button
- Open a terminal and enable source maps:
- Linux/macOS:
export OUTPUT_SOURCE_MAPS=1 - Windows (PowerShell):
$env:OUTPUT_SOURCE_MAPS="1" - Windows (CMD):
set OUTPUT_SOURCE_MAPS=1
- Linux/macOS:
- In the same terminal, rebuild the project:
pnpm clean:dist && pnpm build - In the IDE, select the Debug Gateway option in the Run and Debug configuration dropdown and then press the Start Debugging button
src/ directory) and the debugger will correctly map breakpoints to the compiled JavaScript via source maps. You’ll be able to inspect variables, step through code, and examine call stacks as expected.
Notes
- If using the “Rebuild and Debug Gateway” option - each time the debugger is launched it will completely delete the
/distfolder and run a fullpnpm buildwith source maps enabled before starting the Gateway - If using the “Debug Gateway” option - debug sessions can be started and stopped at any time without affecting the
/distfolder, but you must use a separate terminal process to both enable debugging and manage the build cycle - Modify the
launch.jsonsettings forargsto debug other sections of the project - If you need to use the built OpenClaw CLI for other tasks (i.e.
dashboard --no-openif your debug session spawns a new auth token), you can execute it in another terminal asnode ./openclaw.mjsor create a shell alias likealias openclaw-build="node $(pwd)/openclaw.mjs"