|
1 | 1 | --- |
2 | 2 | name: openclaw-debugging |
3 | | -description: Debug OpenClaw model, provider, tool-surface, code-mode, streaming, and live/Crabbox behavior by choosing the right logs, probes, and proof path before changing code. |
| 3 | +description: Debug OpenClaw model, provider, tool-surface, code-mode, streaming, and live/Crabbox behavior by choosing the right logs, probes, and proof path before changing code, including fetching stored sessions, transcripts, and attachments as evidence. |
4 | 4 | --- |
5 | 5 |
|
6 | 6 | # OpenClaw Debugging |
@@ -77,6 +77,56 @@ openclaw logs --follow |
77 | 77 | before saying live proof is blocked. Env checks are presence-only; never print |
78 | 78 | secrets. |
79 | 79 |
|
| 80 | +## Fetching Sessions and Transcripts |
| 81 | + |
| 82 | +Use these paths when a bug report references a chat session and you need the |
| 83 | +actual transcript, sender attribution, or attachments as evidence. |
| 84 | + |
| 85 | +CLI first (needs a configured install; safe against a live gateway): |
| 86 | + |
| 87 | +```bash |
| 88 | +openclaw sessions list --agent <agentId> --json |
| 89 | +openclaw sessions tail |
| 90 | +openclaw sessions export-trajectory |
| 91 | +``` |
| 92 | + |
| 93 | +Docs: `docs/reference/database-schemas.md` for the store layout, |
| 94 | +https://docs.openclaw.ai/cli/sessions for the CLI. |
| 95 | + |
| 96 | +Raw store (when the CLI is unavailable, e.g. inspecting a remote host over |
| 97 | +SSH, or you need event-level detail): |
| 98 | + |
| 99 | +- Per-agent data plane: `~/.openclaw/agents/<agentId>/agent/openclaw-agent.sqlite`. |
| 100 | + Canonical schema: `src/state/openclaw-agent-schema.sql`. |
| 101 | +- Web chat URLs end in a session-id fragment: `/chat/<agentId>/<slug>-<hex>`. |
| 102 | + Resolve it in `session_nodes`: `session_key LIKE '%<hex>%'` → |
| 103 | + `current_session_id`, `display_name`. Key shape is |
| 104 | + `agent:<agentId>:<surface>:<uuid>`; subagent sessions use surface `subagent`. |
| 105 | +- Transcript: `transcript_events` (`session_id`, `seq`, `event_json`). |
| 106 | + `event_json.message` has `role` (`user`/`assistant`/`toolResult`) and |
| 107 | + `content` (string, or parts of type `text`/`toolCall`/`image`). |
| 108 | +- Sender provenance: real user messages carry `message.__openclaw` |
| 109 | + (`senderId`, `senderName`, `senderIsOwner`); runtime-synthesized inputs do |
| 110 | + not. Use this to separate operator-authored text from injected prompts. |
| 111 | +- Full-text search across transcripts: `session_transcript_fts`. |
| 112 | +- Attachments: `media://inbound/<file>` URLs map to |
| 113 | + `~/.openclaw/media/inbound/<file>`. |
| 114 | + |
| 115 | +Hosts without a `sqlite3` binary still have Node: `node:sqlite` needs no |
| 116 | +dependencies. |
| 117 | + |
| 118 | +```bash |
| 119 | +node -e 'const {DatabaseSync}=require("node:sqlite"); |
| 120 | +const db=new DatabaseSync(process.argv[1],{readOnly:true}); |
| 121 | +console.log(JSON.stringify(db.prepare( |
| 122 | + "SELECT seq,event_json FROM transcript_events WHERE session_id=? ORDER BY seq" |
| 123 | +).all(process.argv[2])))' <db-path> <session-id> |
| 124 | +``` |
| 125 | + |
| 126 | +Always open live stores `readOnly: true`; never write a running gateway's |
| 127 | +state (see Validation rules in the root `AGENTS.md`). For realistic-data |
| 128 | +work, copy the DB into a dev state dir first. |
| 129 | + |
80 | 130 | ## Code Pointers |
81 | 131 |
|
82 | 132 | - Model payload + Responses stream: |
|
0 commit comments