Agent-memory demos usually show what the agent remembers. This one shows the other half: whether the state it hands to the next session is consistent — and what happens when two files disagree.
You need Node.js 20+ and npm 7+. No API key, no model call, no install step.
1. Two lines
npx agent-handoff-cli init demo
cd demo && npx agent-handoff-cli check
init prints the path it wrote to and the next step. check then prints:
PASS CORE_FILES core files present
PASS HANDOFF_SCHEMA frontmatter is valid
PASS HANDOFF_TIME timestamps are ordered
PASS LEASE PAUSED has no residual lease
PASS VERIFY_COMMAND verification command recorded
PASS HANDOFF_BODY 8 sections and next action are present
PASS HANDOFF_FRESH sections 4-6 are fresh (0 days)
PASS INDEX_MAP INDEX is a map and its links resolve
PASS PROJECT_SYNC derived status matches HANDOFF
PASS MEMORY_LINKS memory index and links are closed
PASS SECRETS no high-confidence secret pattern found
SKIP GIT_STATE not a git repository
[ahp] 0 FAIL / 0 WARN / 11 PASS / 1 SKIP
[ahp] check passed
The SKIP is honest: GIT_STATE needs a repository, and this directory is not one yet. Everything else is green.
2. What those seven files are
init writes seven files. Four are the contract:
| File | Role |
|---|---|
AGENTS.md |
the entry point: boundaries and the handoff contract |
INDEX.md |
the file map; no dynamic state |
PROJECT.md |
durable decisions, plus a status block derived from HANDOFF.md
|
HANDOFF.md |
the current work unit, pause point, next action, and last verification |
The other three are memory/MEMORY.md, one lesson body, and ahp.config.json (paths, statuses, freshness).
Only HANDOFF.md carries dynamic state. The status block in PROJECT.md is generated by ahp sync, which is why it cannot quietly drift from the handoff.
3. Break it
Open HANDOFF.md. Its frontmatter contains:
current_file: "none"
and §3 contains:
## 3. Current working set
- Current file: none.
Change only the frontmatter to current_file: "src/auth.ts" and run check again:
FAIL HANDOFF_BODY current_file=src/auth.ts contradicts section 3 ("none")
[ahp] 1 FAIL / 0 WARN / 10 PASS / 1 SKIP
[ahp] check failed
Look at what the gate did not do: it did not decide which value is true. It found two claims about the same fact that disagree, named both, and failed. That is the failure class this protocol is built for — a handoff that is structurally complete and internally contradictory.
4. Fix it
Change the value back to "none" and run check:
[ahp] 0 FAIL / 0 WARN / 11 PASS / 1 SKIP
[ahp] check passed
A second failure worth trying: set status: "ACTIVE" and leave lease_until: "none". LEASE fails, because an active unit must own a future lease — otherwise two sessions can take it.
5. What this proves, and what it does not
It proves three things:
- the four files agree with each other, or the check names the disagreement;
-
checkis read-only: it creates, deletes and modifies nothing; - every failure has a gate ID and a line you can point at.
It does not prove that a fact is true in the world, that an action is authorized, or that the stated next action is the right one. Those are external facts; no file check can establish them. docs/limits.md lists them one by one.
And the dangerous case is the one this demo cannot show: every gate green, and the prose still contradicts itself. Structure is necessary, not sufficient. That is why the protocol pairs the gates with a cold read — a fresh session that answers "what is the state, what is next, and what contradicts?" — and why the project publishes its own limits instead of a security guarantee.
Run it on a real repository
ahp init refuses a non-empty directory unless you pass --force, so it will not overwrite an existing AGENTS.md. Run it in a fresh directory, edit the four files to describe your project, then commit: GIT_STATE stops being skipped once the directory is a repository.
If you want a second pair of eyes
I review how one coding agent hands state to the next and send back one page with up to five findings, each tied to a file and line. Free for the first three repositories, with the limits stated up front: the assessment offer.
The repository is MIT-licensed: cheah505-cyber/agent-handoff-protocol. The 13-item checklist the demo is distilled from is in docs/memory-security-checklist.en.md.
Top comments (0)