v0.1.1 · Zero-LLM · Python 3.11+ stdlib

Verify AI agent handoffs against their transcripts.

AI coding agents and subagents routinely cite path:line ranges they never read, alter quoted snippets, or claim “no other callers” after a truncated grep. handoff-verify checks every claim deterministically against the local JSONL tool-call transcript — zero LLM calls, zero third-party runtime dependencies.

Try now (uvx)
uvx handoff-verify check --latest

Run against your newest Claude Code session with zero install.

Local transcript check
0.60 ms median
$ handoff-verify check evals/cases/fail_06_claude_truncated_grep.jsonl
FAIL: 1 finding (1 error; 4 claims checked, 0 files read, 0.7ms)
[ERROR] TRUNCATED_SEARCH_OUTPUT: Claimed `no other matches`, but search output was truncated: Grep#0 (result limit (5) reached).
Claim (absence): no other matches
Next step: Re-run the search without head_limit/truncation before claiming absence or completeness.
Scope receipt:
Searched roots: .
Truncated outputs (1): [0] Grep (result limit (5) reached)
PASS: 0 findings (6 claims checked, 1 file read, 1.0ms)exit 0
Silent on clean passes with --quiet-on-passExplore all 4 outputs
Interactive Transcript Explorer

Real CLI outputs from the bundled eval suite

Inspect exact plain-text, Markdown, and machine-readable JSON (schema_version: "1.0") receipts returned by handoff-verify check.

Truncated Grep

exit 1--format text

Agent claimed 'no other matches' after running Grep with head_limit=5. Scope receipt records the exact truncated search event.

Command
$ handoff-verify check evals/cases/fail_06_claude_truncated_grep.jsonl
Output (text)
FAIL: 1 finding (1 error; 4 claims checked, 0 files read, 0.7ms)
  [ERROR] TRUNCATED_SEARCH_OUTPUT: Claimed `no other matches`, but search output was truncated: Grep#0 (result limit (5) reached).
    Claim (absence): no other matches
    Evidence: truncated_searches=[{event_index=0, tool_name=Grep, query=deprecated_v1_client, reason=result limit (5) reached}]
    Next step: Re-run the search without head_limit/truncation before claiming absence or completeness.
Scope receipt:
  Searched roots: .
  Truncated outputs (1): [0] Grep (result limit (5) reached)
What this demonstrates
  • Exit code 1 — error-level finding detected
  • Pinpoints exact event_index=0 and head_limit=5 reason
  • Emits a scope receipt with searched roots and truncated outputs
Exit codes: 0 pass · 1 findings · 2 usage/parse error
Three Deterministic Checks

Every claim cross-checked against observed tool evidence

Instead of grading prose with another model, handoff-verify extracts structured claims from the final turn and reconciles them against file reads, edits, searches, command outputs, and pagination cursors.

path:line · #L10-L20

File Pointers & Read Windows

Confirms every cited path:line, path:start-end, or GitHub-style #L10-L20 anchor was actually read inside observed offset/limit windows.

  • Verifies transcript read coverage across Read, grep -n, rg -n, git diff, and shell reads
  • Flags post-edit line shifts when a file was edited or deleted without re-reading
  • Optional --repo check validates live file existence, line count bounds, and on-disk drift
UNREAD_FILELINE_OUT_OF_READ_WINDOWSTALE_FILE_READFILE_NOT_FOUNDLINE_OUT_OF_BOUNDS
inline · fenced blocks

Verbatim Code & Output Quotes

Checks inline and fenced code snippets against what the agent actually read, wrote, or saw in shell command output.

  • Matches exact snippets as well as whitespace- and operator-normalized variants
  • Cross-checks observed file reads, edits, searches, and command stdout
  • Detects file misattribution when a real snippet was observed in file B but cited as file A
QUOTE_NOT_FOUNDQUOTE_MISMATCH
search · pagination

Absence & Completeness Scope Receipts

Audits sweeping claims like 'no other callers', 'not used anywhere', or 'reviewed all pages' against recorded search and cursor events.

  • Catches missing searches and truncated outputs (head_limit, | head, partial reads)
  • Flags repo-wide claims backed only by subdirectory searches or unacknowledged excluded dirs
  • Tracks MCP and API tool responses with unread has_more or nextCursor tokens
NO_SEARCH_EVIDENCETRUNCATED_SEARCH_OUTPUTNARROW_SEARCH_SCOPEUNREAD_PAGINATION_CURSOREXCLUDED_SEARCH_DIRS
Stable Finding Codes

All 12 deterministic finding codes

Every finding emits a stable code, severity, extracted claim, transcript evidence, and next-step suggestion. Pass --strict to treat warnings as failures.

UNREAD_FILE
error

Cited file or path:line was never read/observed in the transcript.

File Pointers
LINE_OUT_OF_READ_WINDOW
error

Cited line range falls outside the transcript's observed Read line windows.

File Pointers
STALE_FILE_READ
errorwarning

File was edited or deleted after the last read (or changed on disk with --repo) without re-reading.

File Pointers
FILE_NOT_FOUND
error

Cited file does not exist on disk in --repo.

File Pointers
LINE_OUT_OF_BOUNDS
error

Cited line number exceeds the live file's line count in --repo.

File Pointers
QUOTE_NOT_FOUND
error

Quoted code or command output snippet does not appear in observed evidence.

Verbatim Quotes
QUOTE_MISMATCH
error

Quoted snippet was attributed to file A, but was only observed in file B.

Verbatim Quotes
NO_SEARCH_EVIDENCE
error

Absence/completeness claim made with no matching repository search.

Scope Receipts
TRUNCATED_SEARCH_OUTPUT
error

Absence/completeness claim backed only by truncated search or partial read output.

Scope Receipts
NARROW_SEARCH_SCOPE
error

Repo-wide (or wider) absence claim backed only by a subdirectory search.

Scope Receipts
UNREAD_PAGINATION_CURSOR
error

Completeness/absence claim made while a tool returned has_more / nextCursor that was never followed.

Scope Receipts
EXCLUDED_SEARCH_DIRS
warning

Search explicitly excluded non-trivial directories not acknowledged in the claim.

Scope Receipts
Hooks & Multi-Harness Support

Automatic Stop & SubagentStop hooks for Claude Code

Run handoff-verify init --write to merge hooks safely into .claude/settings.json (or pass --settings ~/.claude/settings.json for every project), then run handoff-verify doctor to verify PATH, Python 3.11+, and hook config.

Generated .claude/settings.json

init --write
.claude/settings.json
{
  "hooks": {
    "SubagentStop": [
      {
        "hooks": [
          {
            "type": "command",
            "command": "handoff-verify hook claude-code --mode advise"
          }
        ]
      }
    ],
    "Stop": [
      {
        "hooks": [
          {
            "type": "command",
            "command": "handoff-verify hook claude-code --mode advise"
          }
        ]
      }
    ]
  }
}
Quick setup commands
handoff-verify init --write
handoff-verify doctor

Optional flags: --mode block or --command "uvx handoff-verify".

Hook safety guarantees

Strict SubagentStop isolation

Reads only agent_transcript_path on SubagentStop and never falls back to the parent session's transcript_path.

last_assistant_message race handling

Waits up to 1s for the transcript flush (skipping re-parses when size and mtime are unchanged), then falls back to verifying the payload text against on-disk tool evidence.

Silent on clean & warning-only passes

Exits 0 with empty stdout and stderr when clean or warning-only (unless --include-warnings or --strict is passed).

advise (default) vs block modes

advise exits 0 with structured systemMessage + hookSpecificOutput.additionalContext; block writes concise feedback to stderr and exits 2.

stop_hook_active infinite-loop guard

When Claude Code sets stop_hook_active: true, never exits 2 and never emits additionalContext — capping retries at one.

Fail-open with visible diagnostics

Parse, I/O, or internal errors log one line to stderr and exit 1 (non-blocking) instead of bricking a session; pass --fail-closed to exit 2.

Claude Code JSONL

--parser claude_code

Main session and sidechain subagent logs: Read, Grep, Glob, LS, Bash, Edit, MultiEdit, Write, NotebookEdit, WebFetch, and mcp__* paginated tools. Auto-discovered via --latest.

~/.claude/projects/<cwd>/<session-id>.jsonl

Codex CLI JSONL

--parser codex

Modern rollout logs (session_meta, turn_context, response_item with function_call / function_call_output, custom_tool_call / apply_patch, local_shell_call, event_msg) plus legacy flat logs.

~/.codex/sessions/YYYY/MM/DD/rollout-*.jsonl

Generic JSONL

--parser generic

Documented line-delimited JSON schema for integrating any custom agent harness or orchestration pipeline with auto-detection.

meta · file_read · file_edit · search · command · pagination · tool_call / tool_result · assistant
Measured Performance & Calibration

Sub-millisecond checks on small transcripts, calibrated on 1,571 real sessions

Measured on macOS (arm64, Python 3.13.14) across the bundled 32-case seeded evaluation suite (16 clean / 16 planted failures via handoff-verify eval), synthetic multi-megabyte transcripts, and a real-world corpus.

Seeded Precision16 TP · 0 FP
100.0%
Target 100.0% · 32-case suite
Seeded Recall16 / 16
100.0%
Target ≥ 90.0% · 100% code match
False Positive Rate0 / 16 clean
0.0%
Target 0.0% on seeded clean cases
Median LatencyP95 1.38 ms
0.60 ms
Target < 50.0 ms · max 1.56 ms

Scaling & CLI wall-clock latency

up to 94.7 MB/s
WorkloadSizeParseVerifyMedianNotes
Small session (25 reads × 100 lines)115 KB1.28 ms1.22 ms2.50 ms44.8 MB/s
Medium session (250 reads × 100 lines)1.14 MB9.98 ms2.73 ms12.74 ms89.4 MB/s
Large session (1,250 reads × 100 lines)5.76 MB48.53 ms10.03 ms60.77 ms94.7 MB/s
End-to-end CLI (clean_01 --quiet-on-pass, 15 runs)1.6 KB——56.8 ms~54.7 ms Python startup

Reproduce locally with uv run handoff-verify eval --format markdown. The 32-case suite is a deterministic regression benchmark authored alongside the verifier, not a held-out production corpus.

Real-session calibration

1,571 transcripts

Run over 1,571 real Claude Code sessions from one developer's machine (972 main sessions, 599 subagents):

Initial PyPI 0.1.0
32.6%
512 / 1,571 flagged
After shell-read & scratch-copy fixes
21.8%
343 / 1,571 flagged
Follow-up false-alarm classes fixed:
  • Shell output redirected to a temp/log file (> /tmp/x.log, | tee ...) and read back
  • grep -n / rg -n context lines (-C / -A / -B file-line-content) and adjacent lines
  • Parent agents relaying Agent/Task subagent path:line ranges under alternate spellings or unambiguous basenames
  • Negated existence mentions (e.g., "src/app.py:99 does not exist", "there is no foo.py:42")
  • Non-code absence phrases ("no usage limit", "no open issue", "no open PRs", "no errors", "no warnings", "no changes")

Honest boundaries & caveats

Start with advise mode
  • Checks grounding against the transcript, not whether code is correct or tests pass.
  • Treat any finding as “the transcript does not show this”, not “this is false”.
  • Reads via arbitrary inline scripts (e.g. python - <<EOF slicing or generating files) cannot always be mapped back to exact line numbers.
  • --latest currently discovers Claude Code session directories; pass Codex CLI rollout paths explicitly.
FAQ

Practical questions

How deterministic verification fits alongside Claude Code hooks, Codex CLI rollouts, and CI pipelines.

All of the ground truth — every file read window, edit, grep output, shell command, and pagination cursor — is already stored locally in the agent's JSONL transcript. Checking claims deterministically in pure Python stdlib runs in sub-millisecond time (0.60 ms median on the 32-case suite), incurs zero token cost, works offline, and produces reproducible findings with exact evidence pointers.