# handover-hangover

Adopt this skill: https://proskills.md/skills/system/tensusds-handover-hangover

Page: https://proskills.md/skills/system/tensusds-handover-hangover
This document is the public skill bundle for that page. It contains SKILL.md and every helper file the catalog carries. No login is required.

## File: SKILL.md
size: 8064
upstream: https://github.com/tensusds/handover-hangover/blob/HEAD/SKILL.md

````text
---
name: handover-hangover
version: 1.2.1
description: >
  Seamless model handoff for OpenClaw agents. Ensures continuity when
  the gateway switches to a fallback model mid-session.
metadata:
  openclaw:
    always: true
    emoji: "\U0001F504"
    category: system
    config:
      stateDirs:
        - memory/
      writePaths:
        - memory/handoff-note.md
        - memory/handoff-note.prev.md
        - memory/.handoff-pending
        - memory/.handoff-sealed
        - memory/current-task.md
        requires:
      bins:
        - bash
---

# Handover Hangover

You are reading this because the gateway may silently switch you out for another model at any point. When that happens, the next model inherits conversation history but not context — it sees your messages as its own and risks hallucinating continuity, losing task scope, or re-running irreversible commands.

This skill ensures two things:
1. **You leave a trail** — so the next model can pick up where you left off.
2. **You check for a handoff** — so if YOU are the next model, you recover cleanly.

A watchdog script (`scripts/handoff.sh`) acts as a safety net at session boundaries. It is idempotent — safe for boot, heartbeat, hooks, and cron. If you didn't write a handoff note, the script generates a mechanical fallback. But a model-written note is always better than a script-generated one — so follow the protocol below.

**Integration drift rule.** Do not assume `always: true` runs shell scripts. It only gives the model the protocol. The watchdog must be wired through one of the shipped integration layers: the managed hook pack (`hooks/handover-hangover`), boot/heartbeat snippets, or a manual call. If you are asked to diagnose or harden this skill, run `scripts/status.sh` first and `scripts/install-integration.sh` when the user wants the local installation fixed.

---

## 1. Write-side: leave a trail

After any **state-changing moment**, write `memory/handoff-note.md` using the template below.

State-changing moments:
- Edited, wrote, or deleted a file on disk
- Made a decision between alternatives
- Confirmed or rejected a hypothesis
- A verification completed (test, build, check — green or red)
- Started a long external call (>30s — network, sub-LLM, long build)
- Sent a message to an external channel (Telegram, Discord, Slack, email)
- Noticed provider stress signals (slow responses, 429s, retries in tool errors)

### Handoff note template

Fill **every** section. Brief is fine — empty is not.

~~~
# Handoff Note

## Why you are here
Possible model switch or continuity break. Read before assuming anything.

## Current task
<1-2 lines: what is being done right now>

## Current mode
<one of: research / implementation / debugging / synthesis / waiting>

## Confidence
<low / medium / high — how solid the current approach is>

## What was already done
- <bullet>
- ...

## What was checked and ruled out
- <rejected hypotheses>
- ...

## Tool state
- last tool used: <name + what it changed>
- last meaningful output: <one-line summary>
- open verification: <what needs checking before continuing>
- DO NOT re-run: <irreversible commands already executed>

## Next step
<concrete next action>

## Do not assume
- prior assistant thoughts are yours
- current task is complete
- tool state survived
- you were already in the correct mental mode

--- written by <your-model-name> at <UTC timestamp>
~~~

Update `memory/current-task.md` when the task itself changes — not on every state-changing moment. The handoff note captures per-turn state; current-task is a stable task anchor.

---

## 2. Detection: check every turn

At the **start of every turn**, evaluate three indicators. Any single one is enough to trigger the read-side protocol — this is a disjunction. Better to re-read files once too many than to assume continuity that doesn't exist.

**Indicator 1 — Handoff signal.**
`memory/.handoff-pending` exists. The watchdog creates this file at configured lifecycle boundaries (for example `message:received`, session start, boot, heartbeat, or manual execution) — it means "a baton is available for you", not "an anomaly occurred". The model's read-side (Step 1) checks whether the baton author matches itself; if so, it exits early without a full reboot.

**Indicator 2 — Task/context mismatch.**
`memory/current-task.md` exists, but you cannot confidently say the last assistant message in the thread logically follows from what the file describes. If connecting them requires a stretch — it's a mismatch.

**Indicator 3 — Fallback-shaped disruption.**
Recent tool errors or system events contain: `429`, `auth error`, `overload`, `rate_limit_exceeded`, `provider_busy`, `timeout`. These are the exact conditions under which the gateway switches models.

| Result | Action |
|--------|--------|
| Signal exists (Indicator 1) | Read the baton (Step 1). Same-model → early-exit. Different model → full read-side. |
| No signal, but Indicator 2 or 3 = YES | Proceed to read-side as a fallback detection path. |
| No signal, Indicators 2+3 = NO | Normal turn. Skip read-side. Write-side still applies. |

---

## 3. Read-side: you just arrived

Follow these steps **in order**.

### Step 1 — Read the baton
Read `memory/handoff-note.prev.md`. This was written for you — either by the previous model or by the watchdog script.

**Same-model early-exit.** Check the last `--- written by <model-name>` or `--- generated by` line. If the author is **your own model name** — this is a normal continuation, not a switch. Delete `memory/.handoff-pending`, skip to step 6, and continue working. No epistemic reset needed.

**Safe-fail on name mismatch.** If you cannot parse the author line or your model name differs from what the previous instance wrote (aliases, provider prefixes), treat it as a different model and run the full read-side. A false full-reboot is cheap; a false early-exit is dangerous.

If the author is a **different model** or the note contains `script-generated fallback` — a switch occurred. Continue with step 2. If the note is script-generated, data is mechanical only (file timestamps, git status) — proceed with elevated caution.

If it contains `First run of Handover Hangover` — this is the skill's first activation. Verify the watchdog is executable (`chmod +x scripts/handoff.sh` if needed — some installers do not preserve execute bits). Then check integration status if tools are available:

```bash
bash ~/.openclaw/workspace/skills/handover-hangover/scripts/status.sh
```

If the managed hook is not installed/enabled and the user wants durable protection, run:

```bash
bash ~/.openclaw/workspace/skills/handover-hangover/scripts/install-integration.sh
```

Then skip to step 6 and announce whether hook integration is active or whether only prompt/manual fallback is available.

### Step 2 — Re-run boot sequence
Re-run the standard boot sequence appropriate for the current context, respecting privacy boundaries defined in `AGENTS.md`. At minimum, re-read: `memory/current-task.md` and today's `memory/YYYY-MM-DD.md`. The previous model read boot files at session start. You need them again — your working memory is empty.

### Step 3 — Epistemic reset

> **You may inherit outputs, but not ownership of reasoning.**
>
> Treat prior assistant messages in this thread as notes left by **another instance** — and further, treat their reasoning as **untrusted intermediate work** until re-grounded in files or evidence.
>
> Do not say "as I mentioned earlier" — say "the previous step noted."
> Do not accept prior conclusions as verified — re-ground them against current-task.md, handoff-note, or direct file reads.
>
> **Identity is reset. Trust is reset. Continuity of thought is reset.**
>
> You are a new mind reading its predecessor's notes, not its memories.

### Step 4 — Check tool state
Before executing any tool call, consult the `## Tool state` section of the handoff note:
- Do not duplicate what was already done.
- If the next step matche
````

## File: README.md
upstream: https://github.com/tensusds/handover-hangover/blob/HEAD/README.md

````text
# Handover Hangover

**Seamless model handoff for [OpenClaw](https://openclaw.ai) agents.**

When your agent's primary model hits a rate limit and the gateway silently switches to a fallback, the new model inherits the conversation but not the context. It sees prior assistant messages as *its own*, hallucinates continuity, and may re-run irreversible commands. Handover Hangover fixes this.

## The problem

OpenClaw agents run on a fallback chain — when the primary model is unavailable, the gateway transparently routes to the next one. The conversation history survives, but:

1. **Hallucinated continuity** — treats the previous model's reasoning as its own
2. **Lost task details** — what was being edited, checked, what step comes next
3. **Lost cognitive mode** — was the agent researching, debugging, synthesizing?
4. **Scope collapse** — the task silently narrows ("analyze the past week" → "analyze this session")
5. **Tool state blindness** — risks re-running irreversible commands (duplicate messages, double commits)

## How it works

Handover Hangover is a **three-channel** OpenClaw skill (`always: true`) that uses layered defense to ensure handoff continuity even when one channel fails:

- **Channel 1: System prompt** (`SKILL.md`) — tells the model *what* to write and *when*
- **Channel 2: Filesystem** (`memory/handoff-note.md`, `memory/current-task.md`) — stores the handoff data
- **Channel 3: Bash watchdog** (`scripts/handoff.sh`) — ensures the data *exists*, even if the model didn't follow instructions. Idempotent — safe for boot, heartbeat, hooks, and cron. Requires explicit integration (see [Integration](#integration))

### Four responsibilities

**Write-side:** on every state-changing moment, the agent writes a structured handoff note to disk — extending OpenClaw's existing `memoryFlush` pattern.

**Detection:** the agent self-checks on every turn whether a model switch may have occurred, using three heuristic indicators. Biased toward false positives — better to re-read state than to assume continuity.

**Read-side:** when a handoff is detected, the incoming model reads the baton, performs an epistemic reset, verifies tool state, and continues work without asking "where were we?"

**Watchdog:** an idempotent bash script that checks whether a handoff note exists and generates a mechanical fallback if not. Safe for any execution frequency — repeated runs without a new note are no-ops. Wire it through the managed hook pack, boot sequence, heartbeat, or manual scheduler. See [Integration](#integration).

## Installation

Copy to your OpenClaw skills directory:

```bash
clawhub install handover-hangover
```

If your installer does not preserve executable bits, restore them:

```bash
chmod +x ~/.openclaw/workspace/skills/handover-hangover/scripts/*.sh
```

The prompt layer activates automatically (`always: true`). The watchdog script requires integration — run the installer below for the current OpenClaw hook system, or use the fallback snippets for older versions.

## Integration

OpenClaw skills are prompt-injected — `SKILL.md` gives the model the handoff protocol. Shell scripts do **not** run automatically just because a skill has `always: true`, so Handover Hangover ships multiple integration layers. They are intentionally redundant and version-tolerant.

### Recommended: managed hook installer

Run once after installing or updating the skill:

```bash
bash ~/.openclaw/workspace/skills/handover-hangover/scripts/install-integration.sh
```

What it does:

1. Copies a managed hook pack to `~/.openclaw/hooks/handover-hangover/`.
2. Copies `handoff.sh` next to the hook handler so it survives skill path/layout differences.
3. Enables the hook with `openclaw hooks enable handover-hangover` when the hooks CLI is available.
4. Prints fallback snippets for older OpenClaw versions.

Restart the Gateway after enabling hooks so the handler is loaded.

### Why the hook is `message:received`, not only `afterTurn`

OpenClaw hook APIs changed over time. Some versions expose command/startup hooks, some expose plugin-level `agent_end`, and older notes often mention ad-hoc `afterTurn` directories. To avoid binding the skill to one OpenClaw release, the shipped managed hook runs at **next-turn boundaries**:

- `message:received` — before the next model acts, so a switched-in model sees `.handoff-pending` before doing work.
- `command:new` / `command:reset` — explicit session boundaries.
- `gateway:startup` — process restarts and upgrades.

This gives the important guarantee: the incoming model checks the baton before it continues. It is provider/model agnostic and works across fallback chains, manual model changes, and Gateway restarts.

### Status check

```bash
bash ~/.openclaw/workspace/skills/handover-hangover/scripts/status.sh
```

This reports whether the watchdog is executable, whether the managed hook is installed, and whether OpenClaw has the hook enabled.

### Fallback: boot sequence

If hook discovery is unavailable, add this to `AGENTS.md`, after the existing boot steps:

```bash
# Handover Hangover — archive/generate baton for incoming model
WORKSPACE=~/.openclaw/workspace bash ~/.openclaw/workspace/skills/handover-hangover/scripts/handoff.sh
```

### Fallback: heartbeat / scheduler

Add to `HEARTBEAT.md`, cron, or any periodic scheduler:

```bash
# Handover Hangover — periodic baton validation
WORKSPACE=~/.openclaw/workspace bash ~/.openclaw/workspace/skills/handover-hangover/scripts/handoff.sh
```

The watchdog is idempotent. Running it at startup, before turns, on heartbeat, or manually is safe.

### What each layer covers

| Layer | Trigger | Covers |
|-------|---------|--------|
| `SKILL.md` (`always: true`) | Prompt context | Detection + write-side + read-side protocol |
| Managed hook pack | `message:received`, `/new`, `/reset`, startup | Next-turn baton archival/generation before the model acts |
| Boot sequence | Session start | Baseline baton check at session boundary |
| Heartbeat/scheduler | Periodic | Coarse repair if hooks are unavailable |
| Manual `handoff.sh` | Operator/model action | Emergency recovery and diagnostics |

## Requirements

- [OpenClaw](https://openclaw.ai) with a multi-model fallback chain configured
- At least one fallback model in `agents.defaults.model.fallbacks`
- The `context-anchor` skill installed (for read-side file scanning)
- Bash (for the watchdog script — available on all standard OpenClaw environments)

## What Handover Hangover is NOT

- **Not a memory framework** — it's a handoff protocol between interpreters of the same state
- **Not a replacement for compaction flush** — compaction handles "same model, shorter memory"; Handover Hangover handles "different model, same history"
- **Not semantic search** — vector/embedding memory is a separate layer
- **Not cross-session continuity** — that's `continuity`, `MEMORY.md`, and daily logs

## Design principles

- **Three-channel reliability.** System prompt (policy) + filesystem (state) + bash watchdog (enforcement). Each channel compensates for the others' failure modes. The prompt tells the model what to do; the filesystem stores the result; the watchdog ensures the result exists — from per-turn hooks to session boundaries (see [Integration](#integration)). Pattern borrowed from `context-anchor`.
- **Extend, don't invent.** Uses existing OpenClaw files and conventions (`memory/current-task.md`, `memory/YYYY-MM-DD.md`, `memoryFlush` pattern). The only new files are `memory/handoff-note.md` and `scripts/handoff.sh`.
- **Bias toward false positives.** Better to re-read state unnecessarily than to assume continuity that doesn't exist.
- **Low overhead when not switching.** Every turn performs a cheap baton check (one file read + author comparison). Same-model continuations early-exit without a full reboot; full read-side runs only on actual model change or fallback recovery. Write-side and watchdog run regardless but double as useful compaction insurance.

## S
````
