Skip to content

Troubleshooting

nathan nelson edited this page Nov 23, 2026 · 10 revisions

Troubleshooting

Current as of v1.3.1. First step for any issue: run longhand doctor. It reports database, hook, MCP, and index health in one shot.

Ingest

"No sessions found"

Confirm ~/.claude/projects/ exists and actually contains .jsonl files — Longhand reads that directory by default (pass a path to longhand ingest <path> to point elsewhere). Discovery skips anything under a subagents/ directory and pytest temp-directory leftovers by design, so a directory of only those will also come back empty. If you've genuinely never completed a Claude Code session, there's nothing yet to ingest.

Ingest is slow on first run

Expected. ChromaDB has to generate an embedding for every event on first ingest — that's a one-time CPU cost. longhand ingest --skip-analysis (or setup --skip-analysis) defers episode/segment extraction to a later longhand analyze --all, but events are still embedded either way, so it saves analysis time, not embedding time. Subsequent longhand ingest runs are incremental — a file already indexed at its current size is skipped.

Ingest crashes midway

A crash mid-pipeline leaves that session's ingestion_log stage at pending rather than analyzed. longhand reconcile reports it under "partially indexed (ingest crashed mid-pipeline)"; longhand reconcile --fix re-ingests it from scratch using current logic. No manual file surgery needed — the source JSONL is untouched (Longhand never writes back to ~/.claude/projects/), so re-ingesting is always safe to retry.

doctor's "Transcript format" row names a Claude Code entry type

Claude Code added an entry type Longhand has not dispositioned yet. The entries are preserved as unknown events with their raw JSON intact — nothing is lost. pip install -U longhand is doctor's own suggestion only when a newer release is already cached; otherwise it asks you to report the type on the issue tracker so it can be dispositioned in a future release. (Claude Code 2.1's request-telemetry types, such as api-request and api-request-blob, went through exactly this: 1.3.2 dispositions them, and upgrading clears the warning for rows already stored — no re-ingest needed.)


Hooks

SessionEnd hook didn't fire

Run longhand doctor — it has separate rows for the SessionEnd and Stop hooks, and flags a stale pre-0.5.2 hook that still references the removed $CLAUDE_TRANSCRIPT_PATH environment variable (silently failing on every session end); longhand hook install auto-upgrades it. Even when SessionEnd genuinely doesn't fire, two backstops exist: the Stop hook already tailed the session live (so it's not fully invisible, just not analyzed), and the reconciler (longhand schedule install-reconciler, macOS launchd, every 30 minutes) or a manual longhand reconcile --fix will catch it up. Doctor's "Hook errors (7d)" row reads logs/hook-errors-*.log in the data directory and gives class-aware advice — but only the ingest-failed class of error, plus (since 1.3.1) a busy-lock retry's lock-timeout and retry-spawn-failed, is something reconcile can heal; other classes need the underlying cause fixed first.

A session's last turn is missing from search

Fixed in 1.3.1. Before it, a Stop hook that found the ingest lock busy skipped that turn and waited for the next Stop — which never came when the session ended on that turn — and reconcile counted the transcript as indexed because it already had a row. Now a locked-out Stop or SessionEnd hook starts a background retry that waits up to 10 minutes for the lock (each retry logs to logs/live-retry-*.log or logs/session-retry-*.log), and reconcile re-ingests any transcript that grew after its last full ingest once it has been quiet for 30 minutes. If you suspect a gap, longhand doctor's "Recent ingest (7d)" row says how many quiet transcripts changed since their last full ingest, and longhand reconcile --fix (or the scheduled reconciler) heals them. That includes sessions that lost a turn before you upgraded, as long as the transcript on disk is bigger than it was at its last full ingest.

UserPromptSubmit hook injecting too much / too little

Tune hook.min_relevance (default 2.5 — raise it to inject less often) and hook.max_inject_chars (default 2000 — lower it to inject less per prompt) via longhand config --set. See Configuration for exactly how the relevance score is computed and where the defaults live.


MCP

Claude doesn't see Longhand's tools

First figure out which Claude you mean — Longhand's mcp install/setup only write Claude Desktop's config. For Claude Code, install the Longhand plugin (which bundles its own .mcp.json) or run claude mcp add longhand -s user -- longhand mcp-server — restarting Claude Desktop, or reloading Claude Code's MCP servers, picks up either change. longhand doctor has separate "Claude Desktop MCP" and "Claude Code MCP" rows; the Claude Code row checks ~/.claude.json directly and can miss a server that came from a plugin instead (#100) — a green plugin install with a "not installed" doctor row for Claude Code is that gap, not a real problem.

MCP server crashes on startup

Confirm longhand --version works at all first (a broken install fails the same way regardless of MCP). The mcp package ships as a Longhand dependency — pip install --upgrade longhand reinstalls it if it's somehow missing. Check the command Claude Desktop's claude_desktop_config.json (or Claude Code's .mcp.json/claude mcp list) is actually invoking; which longhand should match it.


Recall

recall returns nothing

Confirm the sessions you expect are actually ingested — longhand sessions (or longhand stats) should show a nonzero count. If they're there but recall still comes up empty, try a broader query or drop any time phrase (only the fixed set on the Getting Started page is recognized — "in March" and similar calendar-date phrases are not, so they're treated as plain query text and can over-narrow the match). longhand doctor's "Sessions needing analysis" row catches sessions that were ingested but never analyzed (no episodes/segments yet) — run longhand analyze --all to fix that.

recall_project_status says "No session history" but you remember working on the project

Run longhand reconcile to check for drift between ~/.claude/projects/ and the sessions table. Two common causes:

  • SessionEnd hook didn't fire — the transcript is on disk but was never ingested (hook failure, Claude Code exit path that skipped hooks, transcript predates longhand hook install).
  • Project inference attributed to $HOME — sessions launched from your home directory with $HOME as the first-event cwd got project_id = NULL on pre-0.6.0 ingest. Fixed at ingest time in v0.6.0 for new sessions.

Both are resolved by longhand reconcile --fix. The reconciler is idempotent — it checks the sessions table, each session's analysis stage, and (since 1.3.1) whether the transcript grew after its last full ingest before deciding what needs re-ingesting, so re-running it against unchanged on-disk state is always a safe no-op.

As of v0.6.0, recall_project_status also surfaces a stale: true flag with a stale_reason string whenever it detects on-disk transcripts not ingested for the queried project. If an agent sees that flag, the correct move is to call the MCP reconcile tool with fix: true (that's what the staleness message itself now says) — not to fall back to reading raw JSONLs.

First recall is slow, subsequent are fast

Expected. ChromaDB lazy-loads its ONNX embedding model on the first query in a process; that one call pays the load cost (well under a second in practice), and every call after it in the same process is fast. A CLI invocation is a fresh process every time, so this "first slow, rest fast" pattern resets each time you run longhand recall from the shell — it's a bigger win for the long-lived MCP server process, which loads the model once and reuses it for every tool call in the session.

Project matching returns the wrong project

From the MCP side, call list_projects(match="<name>") (the old match_project) to see the scored candidates and why each one matched; from the CLI, longhand projects lists everything inferred. There's no command for hand-editing a project's aliases — if a session is filed under the wrong project outright (not just an ambiguous fuzzy match), fix the underlying attribution with longhand reattribute (dry run by default; --fix to apply), which re-derives project ownership from each session's actual events.


Storage

Database file is huge

The corpus grows forever by design — that's the point of a forensic archive — so this is expected, not a bug. longhand doctor's "Storage" row shows the current SQLite + Chroma byte sizes, and "Aux/unknown events" shows how many rows are stored as event_type = 'unknown'. longhand db vacuum reclaims disk SQLite is holding onto after deletes (needs free disk at least the size of the current DB file); longhand db vacuum --prune-aux deletes every unknown row first, then vacuums — that includes harness bookkeeping noise, but also the deliberately-preserved summary/pr-link/worktree-state/frame-link rows and any real upstream-drift records doctor was counting, so check the "Transcript format" row before pruning if you care about those. The source JSONLs remain the recovery path if you ever want that data back.

Embedding index seems stale

longhand analyze (with or without --all) will not rebuild event embeddings. Every analyze call re-embeds a session's project summary, its fixed episodes, its segments, and its session summary — but never the events themselves. Events only get (re-)embedded when a session goes through a fresh ingest: longhand ingest --force or longhand setup for every session, and longhand reconcile --fix, longhand restore, or (for Codex) codex-sync --semantic/the finalizer only for the sessions they pick up. For Codex threads that seem stuck without semantic recall specifically: finalization only happens while codex-sync or reconcile --fix is actually running — the scheduled reconciler, the launchd template, codex-sync --watch, or a one-off run — nothing finalizes a quiet thread on its own with no process invoked. longhand codex-sync --semantic forces it immediately — see Codex.


Codex

recall can't see a Codex session

Codex threads are captured exact-record-only while they are being written (ingestion stage archived): verbatim and keyword-searchable, not yet embedded. Since 1.2.0 a thread is finalized — embedded, with episodes and project inference — by the first codex-sync or reconcile --fix run after its rollout has been quiet 30 minutes (so one of them has to be scheduled); longhand codex-sync --semantic does it immediately, and analyze --all never will, because it never embeds events. doctor's "Codex finalizer" row is green while archived threads are still being written and yellow when one has been quiet past the bound with nothing finalizing it. One more thing to know: the semantic server keeps the index it opened with, so a Claude Code session that was already running when a thread was finalized will not see it until Claude Code restarts. The shared server's keyword search reads SQLite and always does.

doctor says Codex rollouts are "new or changed since capture"

Run longhand codex-sync. reconcile --fix (and therefore the scheduled reconciler) captures them too; the row just means a thread has grown since the last capture.

A Codex thread is missing entirely

Check longhand codex-sync --dry-run. subagent: true marks a thread Codex spawned for itself (its approval reviewer, for example) — skipped by default, --include-subagents captures it. within_size_limit: false means the rollout is over --max-file-kb; raise the bound and re-run.

doctor's "Transcript format" row names event_msg/<kind> or response_item/<kind>

Codex added a record kind Longhand has not dispositioned yet. The records are preserved as unknown events with their raw JSON intact — nothing is lost. pip install -U longhand is doctor's own suggestion only when a newer release is already cached; otherwise it asks you to report the kind on the issue tracker so it can be dispositioned in a future release. (This is exactly what happened with the compacted record type: older stored copies briefly counted as drift, and upgrading to 1.2.2 or later clears that warning retroactively — no re-ingest needed.)


Backup & restore

backup init says "No terminal to confirm on"

It takes the typed yes from a terminal and refuses without one. Read the consent text it printed, then re-run with --yes (the path for scripts and non-interactive shells).

backup says backups are disabled, or that the clone's origin is not backup.remote

Run longhand backup init --remote <url> again. An existing backup clone at the backup path is reused; if its origin is a different remote, init re-points it at <url>, and the next backup pushes there. Only a directory holding some other repository, or a non-empty directory that isn't a git repository, is refused.

backup says another backup is running

backup.lock in the data directory is held by a live process — a scheduled auto run or a second terminal. The second run stops at once rather than waiting (for now its message comes at the end of a Python traceback, exit 1); let the first finish, then run it again. A lock left behind by a dead process is taken over on the next run.

doctor's Backup row says "last run FAILED"

The last export or push failed. longhand backup status shows the error text; auto-mode failures also land in ~/.longhand/logs/backup.log. Run longhand backup by hand to watch it live. Usual causes: no credential helper or SSH key for the remote on this machine, no network, or a remote that was deleted. A remote made public after init does not fail a run, because visibility is checked only at init (#116) — make it private again, or run longhand backup disable. Errors that stop a run before it starts (no clone, an origin that isn't backup.remote, another run holding the lock) don't set this row; in auto mode they only reach backup.log.

restore reports fewer events than the original store had

Expected. restore re-parses the exported transcript lines with the current parser, exactly like analyze --all; entry types the current parser skips stay in the backup but do not become rows. A session whose sha256 this machine's backup-state.json already records is skipped; the store itself is not consulted.

restore lists a session under errors

Its transcript failed the sha256 check (a damaged clone — move the clone aside and run restore --from <url> again to clone it fresh, or git clone <url> <dir> and restore --from <dir>) or has a line over the parser's limit. The rest of the restore completes either way. See Backup & Restore.


Still stuck

Open an issue at github.com/Wynelson94/longhand/issues with the output of longhand doctor and whatever command you ran. Include your OS, Python version, and Claude Code version.

Clone this wiki locally

⌂ 换网址