A remote hop without a local checkpoint is a dropped loop. The agent should write state to disk first. Only then may a remote path see a sanitized slice.
The pattern is older than current language models. Databases flush a write-ahead log before replicas. An agent loop needs that same habit on every exit.
Industry talk still paints agents as deep planners. Many production loops are tool calls wrapped around hope. Hope is not a recovery plan for hops.
This article stays local-first on every hop. It uses a checkpoint, a probe, and a short lease. The remote side is optional overflow, not the source of truth.
Cafe networks punish chat-shaped agents without local state. The first tool call stays local and cheap. The next call wants a model the laptop does not host.
The process posts a prompt and dies mid-flight. The outbound prompt vanishes with the broken socket. Partial tool output vanishes with the dying process.
Secrets in the buffer may already sit on the wire. That failure is not an intelligence gap at all. It is a storage and routing gap instead.
Treat the loop like a small database, not a chat window. Keep three records beside the repository root. The checkpoint stores the goal, the step index, and last output.
The lease stores a nonce and an expiry for one in-flight hop. The queue stores sanitized work that has not earned a hop. Think of the lease as a library card at the desk.
The book may leave while the card remains. The desk waits for a return or a timeout. Crash recovery should read those files before any new plan.
Replay starts from checkpoint.json, never from chat history. Chat history is a UI buffer and it lies after a kill. The checkpoint is the only record the next process should trust.
The JavaScript below is a proposal, not a shipped runtime. Comments mark example constants that you must replace. Do not treat the timeouts as measured SLAs.
Redaction stays blunt on purpose in this sketch. A regex will miss odd encodings and binary blobs. A blunt local filter still beats a raw paste into a remote form.
Fingerprint the redacted body before the hop. The hash is not a security proof by itself. It only blocks a second lease for the same payload after a crash.
Truncating SHA-256 to twelve hex characters is an example. Collisions are unlikely for a laptop queue. Raise the length if the queue lives longer than a day.
Atomic writes use a temp file then a replace. Node's writeFileSync on the dest is a simple stand-in. On POSIX you would rename the temp file over the dest.
Do not trust last week's cafe as health. Probe the host you intend to use. A short TCP connect with a hard timeout suffices here.
The 150 millisecond figure is an example threshold. A transoceanic path will fail that probe every time. That failure is a signal to stay on disk.
