datcrazy
v0.1.1 · On npm · MIT · Node 20+

datcrazy-handoff

Hands a long Pi session off to a fresh one and keeps working. The summary and continuation are written to disk first, so the work resumes whether the session is replaced, restarted, or continued by a successor process.

Tool handoff · command /datcrazy-handoff

Install

pi install npm:datcrazy-handoff

Already installed? Run pi update npm:datcrazy-handoff, then /reload in existing sessions.

Or straight from the public repo:

pi install git:github.com/puru991/datcrazy-handoff

Run it once without installing:

pi -e npm:datcrazy-handoff

Package page: pi.dev/packages/datcrazy-handoff · npm: npmjs.com/package/datcrazy-handoff · source is public and MIT-licensed.

Why it exists

A Pi session has one context window. When it fills up — or when work should run in a clean frame — the usual answer is "summarize, then start a new session by hand and paste the summary". That breaks unattended work: an agent running a long task stops and waits for a human.

handoff closes that gap. The session replaces itself with a fresh one that starts on the continuation prompt, and the handoff record stays on disk for review.

How it works

  1. A real command context. Replacing a session needs ctx.newSession, which Pi only hands to command handlers. The tool dispatches its own command through the user-message path, which Pi runs immediately — so it works even in a session where no slash command was ever typed.
  2. An idle moment. Replacing a session aborts and waits for the running turn; doing that from inside that turn would deadlock. The swap is armed, then executed on an idle tick after the turn settles.
  3. A durable record. The artifact and the continuation seed are written before any swap attempt. A failed or cancelled swap re-writes the seed; a delivered one consumes it.

Commands

CommandWhat it does
/datcrazy-handoff statusPending swap, seed and last artifact
/datcrazy-handoff listRecent handoff artifacts for this folder
/datcrazy-handoff resumeArm a swap now from the pending seed or a named artifact
/datcrazy-handoff cancelDrop the pending swap and clear the seed

Artifacts and seeds live in ~/.pi/datcrazy/handoff/; successor logs in ~/.pi/datcrazy/handoff/logs/.

If it cannot swap in place

A handoff never dead-ends. In order of preference:

Normal session

Fresh session, same process

A real command context is acquired and the session is replaced once the turn settles.

No session to replace

Successor process

pi -p, --mode text|json, or a host that does not run extension commands: a detached pi starts in the same folder with the continuation as its prompt. Model, thinking level and tool setup carry over; the parent's session does not. Chains cap at 25 restarts and log to disk.

Embedded host

Durable seed

The continuation waits on disk: /datcrazy-handoff resume, or the next session in that folder picks it up.

Notes

Handoffs stay inside the session's own folder — a root pointing elsewhere is refused instead of silently moving work. Folder identity is canonicalised, so C:/x/proj and C:\x\proj resolve to the same continuation.