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.
uvx handoff-verify check --latestRun against your newest Claude Code session with zero install.
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 textAgent claimed 'no other matches' after running Grep with head_limit=5. Scope receipt records the exact truncated search event.
$ handoff-verify check evals/cases/fail_06_claude_truncated_grep.jsonlFAIL: 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)- 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
0 pass · 1 findings · 2 usage/parse errorEvery 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.
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_BOUNDSVerbatim 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_MISMATCHAbsence & 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_DIRSAll 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_FILECited file or path:line was never read/observed in the transcript.
LINE_OUT_OF_READ_WINDOWCited line range falls outside the transcript's observed Read line windows.
STALE_FILE_READFile was edited or deleted after the last read (or changed on disk with --repo) without re-reading.
FILE_NOT_FOUNDCited file does not exist on disk in --repo.
LINE_OUT_OF_BOUNDSCited line number exceeds the live file's line count in --repo.
QUOTE_NOT_FOUNDQuoted code or command output snippet does not appear in observed evidence.
QUOTE_MISMATCHQuoted snippet was attributed to file A, but was only observed in file B.
NO_SEARCH_EVIDENCEAbsence/completeness claim made with no matching repository search.
TRUNCATED_SEARCH_OUTPUTAbsence/completeness claim backed only by truncated search or partial read output.
NARROW_SEARCH_SCOPERepo-wide (or wider) absence claim backed only by a subdirectory search.
UNREAD_PAGINATION_CURSORCompleteness/absence claim made while a tool returned has_more / nextCursor that was never followed.
EXCLUDED_SEARCH_DIRSSearch explicitly excluded non-trivial directories not acknowledged in the claim.
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{
"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"
}
]
}
]
}
}handoff-verify init --write
handoff-verify doctorOptional 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_codeMain session and sidechain subagent logs: Read, Grep, Glob, LS, Bash, Edit, MultiEdit, Write, NotebookEdit, WebFetch, and mcp__* paginated tools. Auto-discovered via --latest.
Codex CLI JSONL
--parser codexModern 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.
Generic JSONL
--parser genericDocumented line-delimited JSON schema for integrating any custom agent harness or orchestration pipeline with auto-detection.
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.
Scaling & CLI wall-clock latency
up to 94.7 MB/s| Workload | Size | Parse | Verify | Median | Notes |
|---|---|---|---|---|---|
| Small session (25 reads × 100 lines) | 115 KB | 1.28 ms | 1.22 ms | 2.50 ms | 44.8 MB/s |
| Medium session (250 reads × 100 lines) | 1.14 MB | 9.98 ms | 2.73 ms | 12.74 ms | 89.4 MB/s |
| Large session (1,250 reads × 100 lines) | 5.76 MB | 48.53 ms | 10.03 ms | 60.77 ms | 94.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 transcriptsRun over 1,571 real Claude Code sessions from one developer's machine (972 main sessions, 599 subagents):
- 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 - <<EOFslicing or generating files) cannot always be mapped back to exact line numbers. --latestcurrently discovers Claude Code session directories; pass Codex CLI rollout paths explicitly.
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.