google/capsem/dev-session-debug
Claude Code and agent skill by google/capsem
- vendor
Checking that the SKILL.md file is still in the repository.
Debugging session.db and the telemetry pipeline. Use when inspecting a session ledger, diagnosing missing telemetry, or correlating events across tables.
Install
npx vskill@latest install google/capsem/dev-session-debugSKILL.md
The same SKILL.md was published earlier as google/capsem/dev-session-debug.
Session Database Debugging
Every Capsem VM session produces a ledger in its session directory: ~/.capsem/run/sessions/<id>/ for an ephemeral VM, ~/.capsem/run/persistent/<name>/ for a named one. The ledger is two files that only make sense together:
session.db-- SQLite, every telemetry table plus the index of captured bodies.session.bodies-- the append-only body archive: HTTP, model, tool, exec and
security payloads, written as streaming zstd level 3 blocks of about 1 MiB. Readers retain raw-deflate support for older blocks. SQLite never holds body bytes, and native codec execution stays inside capsem-ledger.
Copy, fork or delete them as a pair; either one alone is useless. The host ledger ~/.capsem/sessions/host.db records what happened to every session (created, stopped, with its final counters) as a hash-chained event log.
The session ledger has no migrations. A session.db written by an older build fails to open, loudly and by name, rather than being upgraded in place.
Session identity invariant
<id> is the opaque VM/session id used for route paths, DB-handle keys, session-directory names, CAPSEM_VM_ID, and UI tab routing. Human names such as co-work1 or code-vm1 are display aliases only and must live in name fields. User surfaces may accept a name (capsem resume co-work1), but they must translate it to the VM id before calling /vms/{id}/.... Never use a persistent registry name as SandboxInfo.id, never look up telemetry routes with registry.get(&id) unless the id has first been resolved to the registry key, and never key session_db_handles by display name.
If a UI shows telemetry for the wrong provider/model, check this boundary first: /vms/list and /vms/{id}/info must expose id = session id and name = display name, and /vms/{id}/stats/detail must open the DB under the resolved session directory for that id. A session named co-work1 showing another session's ollama rows while its own DB has AGY/Google rows is a route identity bug until proven otherwise.
Quick inspection
Listing sessions
Python here means the build-system environment: uv run --project build_system --frozen python ... (a bare python3 may be a system interpreter without the packages these need).
Sessions come from the host ledger, so they're listed after the session directory is gone. GET /stats folds every finished session's counters with the live counters of running ones.
Deep inspection
The commands below open ledger files directly. Use them only on preserved test evidence or a coherent copy after its ledger worker has stopped. Live and stopped product-session reads go through the service's typed ledger routes; debug tooling must not become a second product reader outside capsem-ledger.
Checks: SQLite page integrity (PRAGMA quick_check, first -- a damaged file ends the report), table existence, row counts, body archive integrity (below), file-monitor overflow windows, tool lifecycle integrity (orphaned tool_calls/tool_responses), AI provider correlation (net_events vs model_calls), and NULL detection in critical fields. It exits 1 when the ledger is damaged.
Route readiness (DbHandle::ready) checks the schema's shape only, once per schema_version, and never scans pages: that scan cost 1.8 s per failed poll on a million-row ledger (google/capsem#230). Page damage surfaces as a malformed error on the query that reads it, at the ledger copy's quick_check, and here.
The body archive check compares the index with the file without trusting either: every event_body_blobs.block_offset exists in body_blocks; every body_offset + body_len fits in its block's raw_len; session.bodies is at least as long as the largest block_offset + disk_len (a block's committed extent, headers included) and starts with the archive's file header. --verify-bodies then reads every body, inflating each segment once, and checks it against body_hash.
Session database tables (session.db)
The model/tool contract is intentionally one ledger:
model_callsis one row per model exchange: request sent to the provider and response received from it.model_itemsis the ordered item ledger for request, reasoning/thinking, response, tool_call, and tool_response content inside those exchanges.tool_callsis the canonical user/security tool-call ledger for all origins (native,mcp,builtin,local). User-facing tool counts and CEL tool evidence come from this table.tool_responsesrecords tool result content sent back to a model. A response row must match atool_calls.call_idin the same trace.- MCP protocol facts are typed security events. MCP-origin
tools/callactivity must appear intool_callswithorigin = 'mcp'. - One
model_calls.idcan emit manytool_calls.call_idvalues. The tool response must reuse the samecall_id; MCP can enrich that same logical call, but it does not create a second product ledger.
Identity Graph
Use this graph when correlating model, tool, and security rows:
Definitions:
event_ididentifies one emitted ledger event row. Security rows, body blobs,
and event detail routes join back through this id.
trace_idgroups runtime work caused by one causal operation across tables:
HTTP, DNS, model, tool, file, process, credentials, and security.
turn_idgroups all work caused by one user-visible agent turn: the user's
input, every provider exchange needed to answer it, every tool request and response, and every emitted HTTP/DNS/file/process/security row caused by it.
model_call_idis themodel_calls.idvalue for exactly one provider
request/response exchange inside a turn. It owns that exchange's request, reasoning/thinking, response, model-emitted tool-call items, token counts, and provider metadata. It is not the whole user turn; a single turn_id can contain multiple model_call_id values.
tool_call_ididentifies one logical tool invocation across model-native
tools, MCP transport, Capsem built-ins, and local tools. In SQLite it is stored as tool_calls.call_id and tool_responses.call_id.
Provider response ids, message ids, and transport request ids are provider or transport metadata. They are not Capsem's join contract.
One turn_id is the user-input scope. It can contain multiple model_call_id values when an agent calls the model, executes tools, then calls the model again with tool results. One model_call_id is one provider-exchange scope and carries that exchange's request, reasoning/thinking, response, token counts, and ordered model_items. It can emit zero or more tool_call_id values; this is the canonical one-to-many relationship for model-visible tools. Stated as the debugging invariant: one model_call_id can emit N tool_call_id values, and each emitted tool response must reuse that tool_call_id. A tool response must carry the same tool_call_id as the tool request.
MCP is not a second user-facing tool ledger. MCP-origin tools/call activity must resolve to a tool_calls row with origin = 'mcp' or enrich an existing logical tool_call_id. An MCP call observed without a corresponding logical tool call is an integrity/security finding, not a separate product counter.
Key cardinalities:
- One session has many
trace_idvalues. - One
trace_idhas one or moreturn_idvalues. - One
turn_idhas one or moremodel_call_idvalues. - One
model_call_idhas one provider request and one provider response. - One
model_call_idhas manymodel_itemsrows: request, reasoning,
response, tool_call, and tool_response items in observed order.
- One
model_call_idcan emit manytool_call_idvalues. - One
tool_call_idhas one tool request and zero or more observed response
rows, all with the same tool_call_id.
- One
event_ididentifies one emitted row and joins its security, body, and
display details.
net_events -- one row per HTTP request through MITM proxy
model_calls -- one row per AI API request+response cycle
This is the start of the file. Read the full SKILL.md on GitHub.
Security
- Security scanPassed, 100 of 100Pattern checks on the skill's files. Certified 1 Nov 2026.
- Model reviewPassed
Quality evaluation
- Task evaluationNot runNo evaluation yet. Run one in Skill Studio.
Source
- SKILL.md in the repositoryCheckingskills/dev-session-debug/SKILL.md
Popularity
- Repository stars
- 169
- Repository forks
- 23
- 7-day trend score
- 21
Stars and forks are for the whole GitHub repository, not this skill alone. Refreshed 17 Jul 2026, 4 months ago.
Works with
Any agent vskill installs to: 56 targets in all. These 39 have a page on this site.
- Claude Code
- Cursor
- GitHub Copilot
- Windsurf
- Codex
- Gemini CLI
- Cline
- Amp
- Roo Code
- Goose
- Continue
- Kilo Code
- Junie
- Trae
- OpenHands
- Qwen Code
- AI Agent
- Tabnine Chat
- Sourcegraph Cody
- Amazon Q
- Firebase Genkit
- Sweep
- Devin
- Phind
- Mentat
- Claude Desktop
- Aider
- GPT Pilot
- Plandex
- bolt.new
- v0
- Replit Agent
- Anse
- TypingMind
- BetterChatGPT
- LibreChat
- Warp AI
- Pieces
- Fig AI
Embed badge
[](https://verified-skill.com/skills/google/capsem/dev-session-debug)