Skip to main content

agent-handover

Session handover engine for AI coding agents: checkpointed, resumable, backend-agnostic persistent memory.

AI coding agents (Claude Code, Codex, OpenCode, Cline, ...) are stateless between sessions. Every new session starts with re-explaining the project, the decisions already made, and what was left half-done. agent-handover is the small piece of infrastructure that fixes this: at the end of a session the agent writes a structured handover; at the start of the next one, it resumes from it — even if the previous handover crashed halfway.

Extracted from a personal "AI Team OS" that has run daily handovers across multiple machines and agents since 2025.

The problem

  • Context loss: the next session doesn't know what the last one decided.
  • Half-written state: a handover that dies mid-run silently corrupts memory. The next session boots from a state that is partly updated — worse than stale.
  • Remote memory is fragile: vector DBs and hosted notebooks go down. If your agent's memory has no local fallback, your agent has no memory.

Design

┌─ session ends ──────────────────────────────────────────────┐
│  HandoverEngine(steps, checkpoint, pause_file)              │
│    step 1: collect session facts          ── checkpointed   │
│    step 2: MemoryStore.write(layer=1...)  ── checkpointed   │
│    step 3: MemoryStore.write(layer=2...)  ── checkpointed   │
│    step 4: GitBackend.publish(...)        ── checkpointed   │
└──────────────────────────────────────────────────────────────┘
┌─ next session starts ───────────────────────────────────────┐
│  $ agent-handover check    # 0=clean  1=RESUME  2=completed │
│  read layer2/current-state.md  →  agent has context again   │
└──────────────────────────────────────────────────────────────┘

Three memory layers, all plain Markdown (git-friendly, diff-able, readable by humans and any agent that can read a file):

Layer File pattern Semantics
1 layer1/YYYY-MM/<tag>-<date>.md session notes (append, dated)
2 layer2/current-state.md "where are we now" (always overwritten)
3 layer3/YYYY-MM-<tag>-archive.md monthly compaction of old notes

Three rules learned in production:

  1. Every step is checkpointed. An interrupted handover is detected (agent-handover check → exit 1) and resumed without re-running done steps.
  2. A PAUSE file is an absolute kill-switch. Agents that write to your repos need a brake a human can pull with touch PAUSE.
  3. The filesystem is the source of truth. Remote layers (NotebookLM, vector stores) are optional accelerators; the local copy is always enough to boot.

Install

pip install agent-handover   # or: pip install -e . from a clone

Usage

from pathlib import Path
from agent_handover import Checkpoint, HandoverEngine, MemoryStore, Step, GitBackend

store = MemoryStore("memory/")
cp = Checkpoint(".agent-handover/checkpoint.json")
git = GitBackend(".", paths=["memory/"])

engine = HandoverEngine(
    steps=[
        Step("session_note", lambda: store.write(1, notes, tag="refactor")),
        Step("current_state", lambda: store.write(2, snapshot)),
        Step("publish", lambda: git.publish("handover: session sync")),
    ],
    checkpoint=cp,
    pause_file=Path.home() / ".agent_handover" / "PAUSE",
)
engine.run()  # resumes pending steps automatically after a crash

In your agent's bootstrap (CLAUDE.md / AGENTS.md):

agent-handover check   # exit 1 → finish the interrupted handover first

Declarative handover (agent-handover run)

Don't want to write Python? Describe the handover in a TOML file and run it from the CLI — same checkpointed engine, as data:

agent-handover run --config .agent-handover/handover.toml --note "what happened"
# local only (no git push):
agent-handover run --config .agent-handover/handover.toml --note "wip" --no-push

CLI flags (--note, --current-state, --no-push, --checkpoint) override the file, so one config serves every session. See examples/run/ for a starter handover.toml.

Use with Codex CLI

A first-class adapter for the OpenAI Codex CLI. Install the bootstrap block into your repo's AGENTS.md (idempotent, preserves your other rules) and write a handover at the end of each session:

from agent_handover.adapters.codex import install_agents_md, build_codex_handover_engine

install_agents_md("AGENTS.md")            # Codex runs `agent-handover check` on start

engine = build_codex_handover_engine(     # one call for the end-of-session hook
    session_note="reviewed PR #42; released v0.2.0",
    current_state="parser refactor merged; next: TOML step config",
)
engine.run()                              # writes memory/, publishes, checkpointed

See examples/codex-cli/ for a runnable end-of-session script and the AGENTS.md block.

Use with Cline

A first-class adapter for Cline, the autonomous coding agent for VS Code. Cline reads a directory of rule files (.clinerules/), so the adapter installs a dedicated, idempotent rule file that never touches your other rules:

from agent_handover.adapters.cline import install_clinerules, build_cline_handover_engine

install_clinerules(".clinerules")         # writes .clinerules/00-agent-handover.md

engine = build_cline_handover_engine(     # one call for the end-of-session hook
    session_note="reviewed PR #42; released v0.3.0",
    current_state="parser refactor merged; next: TOML step config",
)
engine.run()                              # writes memory/, publishes, checkpointed

See examples/cline/ for a runnable end-of-session script and the .clinerules/ rule file.

Use with OpenCode

A first-class adapter for OpenCode. OpenCode reads AGENTS.md as its rules file (the same mechanism as Codex), so this adapter shares its block and installer with the Codex adapter — only the example path and engine tag differ:

from agent_handover.adapters.opencode import install_agents_md, build_opencode_handover_engine

install_agents_md("AGENTS.md")            # OpenCode runs `agent-handover check` on start

engine = build_opencode_handover_engine(  # one call for the end-of-session hook
    session_note="reviewed PR #42; released v0.4.0",
    current_state="parser refactor merged; next: TOML step config",
)
engine.run()                              # writes memory/, publishes, checkpointed

See examples/opencode/ for a runnable end-of-session script and the AGENTS.md block.

Status & roadmap

  • checkpointed engine, 3-layer Markdown store, git backend, pause guardrail
  • adapter: Codex CLI (AGENTS.md bootstrap + end-of-session handover)
  • adapter: Cline (.clinerules/ rule file + end-of-session handover)
  • adapter: OpenCode (AGENTS.md bootstrap + end-of-session handover)
  • agent-handover run with declarative step config (TOML)
  • handover quality scoring (was the note actually useful next session?)
  • adapters: NotebookLM, sqlite-vec

Issues and PRs welcome — especially reports from other agent stacks (Codex CLI, Cline, OpenCode).

License

MIT

Metadata

Release files for agent-handover 0.5.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for agent-handover 0.5.1
File Size Uploaded
agent_handover-0.5.1.tar.gz 21.9 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for agent-handover 0.5.1
File Interpreter ABI Platform
agent_handover-0.5.1-py3-none-any.whl Python 3 none any Details

Total release size: 42.5 kB

Release files / agent_handover-0.5.1.tar.gz

Download URL agent_handover-0.5.1.tar.gz
Size 21.9 kB
Tags Source
SHA-256 checksum
How to use checksums
d4ba7ae939c2e116643c59e1a55e8bb5738ca8bb1873068159a6fc7090d788dd
BLAKE2b-256 checksum
How to use checksums
257319113c88bc8366ebd2d1aeb8a56d8224f02300b9544eb2382786ea46eb26
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.12

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Jul 13, 2026.

Transparency log

Release files / agent_handover-0.5.1-py3-none-any.whl

Download URL agent_handover-0.5.1-py3-none-any.whl
Size 20.6 kB
Tags Python 3
SHA-256 checksum
How to use checksums
dc072bbf202212e7170505e256ec4bc551f71939a2fb09d1f510189f4661f106
BLAKE2b-256 checksum
How to use checksums
c881e97cafbf7b3a1756e308f5e3bb25576a3cba9c3005baa0ed25862b71a098
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.12

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Jul 13, 2026.

Transparency log

Release history Release notifications | RSS feed

This release

0.5.1 This release

2 release files

0.5.0

2 release files

0.4.0

2 release files

0.3.0

2 release files

0.2.0

2 release files

0.1.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page