an open-source alternative to the dots, bots and muses of the world, run an office of claude code/codex like agents on your laptop, sandboxes or anywhere, uses your existing subscriptions
HTML agent-harnessagent-orchestrationagentsai-agentsautonomous-agentsclaude-codecodexcoding-agentsdesktop-appdeveloper-toolselectrongemini-cliharnessharness-engineeringlocal-firstmemorymulti-agentopencodeorchestrationtypescript
<!doctype html>
<html lang="en">
<head>
<!-- Google tag (gtag.js), Google Ads AW-18388216863. Loaded only when Do Not Track is
off, so it follows the same rule as the PostHog block on this site. -->
<script>
window.dataLayer = window.dataLayer || [];
function gtag(){ dataLayer.push(arguments); }
if (navigator.doNotTrack !== '1') {
var gtagScript = document.createElement('script');
gtagScript.async = true;
gtagScript.src = 'https://www.googletagmanager.com/gtag/js?id=AW-18388216863';
document.head.appendChild(gtagScript);
gtag('js', new Date());
gtag('config', 'AW-18388216863');
}
</script>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Recovering From Agent Failures: Resilience Patterns for a Hive — Munder Difflin Blog</title>
<meta name="description" content="How multi-agent systems survive partial failure: retry with stale-lock recovery, poison-message quarantine, hop-cap circuit breaking, idempotent handling." />
<link rel="canonical" href="https://munderdiffl.in/blog/recovering-from-agent-failures/" />
<link rel="icon" type="image/png" href="https://munderdiffl.in/logo.png" />
<link rel="apple-touch-icon" href="https://munderdiffl.in/logo.png" />
<meta name="theme-color" content="#F5F2E8" />
<!-- Open Graph -->
<meta property="og:site_name" content="Munder Difflin Blog" />
<meta property="og:type" content="article" />
<meta property="og:title" content="Recovering From Agent Failures: Resilience Patterns for a Hive — Munder Difflin Blog" />
<meta property="og:description" content="How multi-agent systems survive partial failure: retry with stale-lock recovery, poison-message quarantine, hop-cap circuit breaking, idempotent handling." />
<meta property="og:url" content="https://munderdiffl.in/blog/recovering-from-agent-failures/" />
<meta property="og:image" content="https://munderdiffl.in/blog/assets/media/recovering-from-agent-failures/hero.png" />
<meta property="og:image:width" content="1600" />
<meta property="og:image:height" content="900" />
<meta property="og:image:alt" content="Illustration: Recovering From Agent Failures: Resilience Patterns for a Hive" />
<meta property="og:locale" content="en_US" />
<meta property="article:published_time" content="2026-06-04T00:00:00.000Z" />
<meta property="article:author" content="Chaitanya Giri" />
<meta property="article:tag" content="Internals" />
<meta property="article:tag" content="Concurrency" />
<meta property="article:tag" content="Multi-Agent" />
<meta property="article:tag" content="Messaging" />
<!-- Twitter -->
<meta name="twitter:card" content="summary_large_image" />
<meta name="twitter:title" content="Recovering From Agent Failures: Resilience Patterns for a Hive — Munder Difflin Blog" />
<meta name="twitter:description" content="How multi-agent systems survive partial failure: retry with stale-lock recovery, poison-message quarantine, hop-cap circuit breaking, idempotent handling." />
<meta name="twitter:image" content="https://munderdiffl.in/blog/assets/media/recovering-from-agent-failures/hero.png" />
<meta name="twitter:image:alt" content="Illustration: Recovering From Agent Failures: Resilience Patterns for a Hive" />
<link rel="alternate" type="application/atom+xml" title="Munder Difflin Blog" href="https://munderdiffl.in/blog/feed.xml" />
<link rel="preconnect" href="https://fonts.googleapis.com" />
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin />
<link href="https://fonts.googleapis.com/css2?family=Fraunces:opsz,[email protected],500;9..144,600;9..144,700;9..144,900&family=Source+Serif+4:opsz,[email protected],400;8..60,600;8..60,700&family=Space+Grotesk:wght@500;600;700&family=JetBrains+Mono:wght@400;600&display=swap" rel="stylesheet" />
<link rel="stylesheet" href="/blog/assets/blog-press.css" />
<script type="application/ld+json">
{
"@context": "https://schema.org",
"@type": "BlogPosting",
"headline": "Recovering From Agent Failures: Resilience Patterns for a Hive",
"description": "How multi-agent systems survive partial failure: retry with stale-lock recovery, poison-message quarantine, hop-cap circuit breaking, idempotent handling.",
"image": ["https://munderdiffl.in/blog/assets/media/recovering-from-agent-failures/hero.png"],
"datePublished": "2026-06-04T00:00:00.000Z",
"dateModified": "2026-06-04T00:00:00.000Z",
"author": { "@type": "Person", "name": "Chaitanya Giri" },
"publisher": {
"@type": "Organization",
"name": "Munder Difflin",
"logo": { "@type": "ImageObject", "url": "https://munderdiffl.in/logo.png" }
},
"mainEntityOfPage": { "@type": "WebPage", "@id": "https://munderdiffl.in/blog/recovering-from-agent-failures/" },
"keywords": "recovering from agent failures, multi-agent resilience, ai agent failure recovery, idempotent agent messaging, fault tolerance ai agents",
"articleSection": "Internals",
"inLanguage": "en-US",
"url": "https://munderdiffl.in/blog/recovering-from-agent-failures/"
}
</script>
<script type="application/ld+json">
{
"@context": "https://schema.org",
"@type": "BreadcrumbList",
"itemListElement": [
{ "@type": "ListItem", "position": 1, "name": "Home", "item": "https://munderdiffl.in/" },
{ "@type": "ListItem", "position": 2, "name": "Blog", "item": "https://munderdiffl.in/blog/" },
{ "@type": "ListItem", "position": 3, "name": "Recovering From Agent Failures: Resilience Patterns for a Hive", "item": "https://munderdiffl.in/blog/recovering-from-agent-failures/" }
]
}
</script>
<script type="application/ld+json">
{
"@context": "https://schema.org",
"@type": "FAQPage",
"mainEntity": [
{ "@type": "Question", "name": "What happens when an AI agent in a multi-agent system fails?", "acceptedAnswer": { "@type": "Answer", "text": "In a well-built hive, a single failure stays local. A crashed step doesn't take down the router; a malformed message is quarantined instead of retried forever; a runaway loop is dropped by a hop cap; and shared state is protected by retries so one stalled write doesn't block the rest. The system keeps running and the failure is recoverable, not fatal." } },
{ "@type": "Question", "name": "How do you make agent message handling idempotent?", "acceptedAnswer": { "@type": "Answer", "text": "Make 'already handled' a cheap, observable fact. In a file-based hive, an agent moves a message to inbox/.done/ once handled, and re-reading a done message is a no-op. Delivery is at-least-once; handling is idempotent — so a duplicate or replayed message does nothing the second time. The same idea drives an append-only event log: re-reading a line you've already processed changes nothing." } },
{ "@type": "Question", "name": "How do you stop AI agents from looping forever?", "acceptedAnswer": { "@type": "Answer", "text": "Put a circuit breaker on the message path. Every message carries a hop count; once it exceeds a cap, the router drops it and logs the drop rather than letting two agents ping-pong indefinitely. It's a blunt instrument on purpose — it guarantees termination, and the dropped, logged message tells you where to look." } }
]
}
</script>
<script>
// Anonymous blog analytics (PostHog) — same posture as the main site and the
// app's TELEMETRY.md: public write-only token ('' = inert), anonymous-only
// (person_profiles 'never'), no autocapture/recording, DNT respected.
(function () {
var PH_KEY = 'phc_qJzsokwcbtTGHemnvywR3nSqivNNgMjHeNVEWkZNydFB';
if (!PH_KEY || navigator.doNotTrack === '1') return;
var s = document.createElement('script');
s.async = true;
s.src = 'https://us-assets.i.posthog.com/static/array.js';
s.onload = function () {
if (!window.posthog) return;
window.posthog.init(PH_KEY, {
api_host: 'https://us.i.posthog.com',
person_profiles: 'never',
autocapture: false,
before_send: function (event) {
// PostHog fills $ip from the connection unless the event carries one.
// Null it here and disable the GeoIP lookup so no IP, city, postal
// code or lat/long is ever derived or stored for this page view.
if (event && event.properties) {
event.properties.$ip = null;
event.properties.$geoip_disable = true;
}
return event;
},
disable_session_recording: true,
respect_dnt: true
});
};
document.head.appendChild(s);
})();
</script>
</head>
<body class="theme-press">
<a class="skip-link" href="#main">Skip to content</a>
<nav id="nav">
<a class="brand" href="https://munderdiffl.in" aria-label="Munder Difflin home">
<img class="brand-logo" src="https://munderdiffl.in/logo.png" width="1318" height="840" alt="Munder Difflin, Inc. — Multi-Agent Harness" />
</a>
<span class="spacer"></span>
<div class="links">
<a href="/blog/">Latest</a>
<a href="/blog/topics/">Topics</a>
<a href="/blog/about/">About</a>
<a href="https://munderdiffl.in">↗ Product</a>
</div>
<div class="nav-actions">
<a class="btn sm" href="https://munderdiffl.in/blog/feed.xml" aria-label="RSS feed">⤵ RSS</a>
<a class="btn sm primary" href="https://munderdiffl.in/#install">⤓ Download</a>
</div>
</nav>
<main id="main">
<article class="t-internals">
<header class="post-head wrap">
<nav class="crumbs" aria-label="Breadcrumb">
<a href="/blog/">Blog</a>
<span>/</span>
<a href="/blog/topics/internals/">Internals</a>
</nav>
<h1>Recovering From Agent Failures: Resilience Patterns for a Hive</h1>
<p class="dek">How multi-agent systems survive partial failure: retry with stale-lock recovery, poison-message quarantine, hop-cap circuit breaking, idempotent handling.</p>
<div class="byline">
<span class="av" aria-hidden="true">CG</span>
<strong>Chaitanya Giri</strong>
<span class="dot" aria-hidden="true">·</span>
<time datetime="2026-06-04">Jun 4, 2026</time>
<span class="dot" aria-hidden="true">·</span>
<span>6 min read</span>
<span class="tag kind">Internals</span>
</div>
</header>
<div class="hero-wrap wrap"><figure class="fig fig-hero"><img src="/blog/assets/media/recovering-from-agent-failures/hero.png" alt="Illustration: Recovering From Agent Failures: Resilience Patterns for a Hive" loading="lazy" decoding="async" /></figure></div>
<div class="post-wrap wrap">
<div class="prose">
<div class="callout tldr"><span class="ic">TL;DR</span><p>In a multi-agent system, <strong>partial
failure is the default</strong>, not the exception — a crashed committer, a contended lock, a malformed
message, a routing loop. Resilience isn't avoiding those; it's making each one <strong>local,
recoverable, and idempotent</strong>. A handful of small patterns do most of the work: <strong>retry with
backoff + stale-lock recovery</strong> for shared writes, <strong>quarantine</strong> for poison messages,
a <strong>hop-cap circuit breaker</strong> for runaway loops, <strong>idempotent handling</strong> so
replays are no-ops, and <strong>error isolation</strong> so one bad step never takes down the loop.</p></div>
<p>Run one agent and failures are simple: it works or it doesn’t. Run a <em>hive</em> of them sharing files and a
message bus, and you inherit the unglamorous reality of distributed systems — things fail halfway, two
writers collide, a message arrives twice or malformed, a conversation loops. The goal isn’t a system that
never fails; it’s one where any single failure is contained and the team keeps moving. Here are the
patterns that get you there, grounded in how a real <a href="/#what">multi-agent harness</a> handles each.</p>
<h2 id="partial-failure-is-the-default" tabindex="-1">Partial failure is the default <a class="anchor" href="#partial-failure-is-the-default" aria-hidden="true">#</a></h2>
<p>The mental shift is to stop treating failure as exceptional. With many agents writing files concurrently
and a router draining their outboxes, on any given tick <em>something</em> can be mid-write, locked, or garbage.
A resilient design assumes that and answers four questions up front: when a shared write collides, then
what? When a message won’t parse, then what? When a conversation loops, then what? When one step throws,
does the whole loop die? Good answers to those four are most of fault tolerance.</p>
<h2 id="make-shared-writes-survivable" tabindex="-1">Make shared writes survivable <a class="anchor" href="#make-shared-writes-survivable" aria-hidden="true">#</a></h2>
<p>The hive commits all coordination to one git repo with a <a href="/blog/single-committer-git-pattern/">single committer</a>.
That removes interleaved writes, but the committer can still race itself or inherit a lock from a crashed
run. So the commit isn’t a single shot — it’s a small retry loop with backoff and <strong>stale-lock recovery</strong>:</p>
<pre class="language-ts"><code class="language-ts"><span class="token comment">// src/main/hive.ts — commit under contention</span>
<span class="token keyword">for</span> <span class="token punctuation">(</span><span class="token keyword">let</span> attempt <span class="token operator">=</span> <span class="token number">0</span><span class="token punctuation">;</span> attempt <span class="token operator"><</span> <span class="token number">5</span><span class="token punctuation">;</span> attempt<span class="token operator">++</span><span class="token punctuation">)</span> <span class="token punctuation">{</span>
<span class="token keyword">this</span><span class="token punctuation">.</span><span class="token function">clearStaleLock</span><span class="token punctuation">(</span>root<span class="token punctuation">)</span><span class="token punctuation">;</span> <span class="token comment">// a crashed run? clear a >10s-old index.lock</span>
<span class="token keyword">const</span> commit <span class="token operator">=</span> <span class="token keyword">this</span><span class="token punctuation">.</span><span class="token function">git</span><span class="token punctuation">(</span><span class="token punctuation">[</span><span class="token string">'commit'</span><span class="token punctuation">,</span> <span class="token string">'-q'</span><span class="token punctuation">,</span> <span class="token string">'-m'</span><span class="token punctuation">,</span> message<span class="token punctuation">]</span><span class="token punctuation">,</span> root<span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token keyword">if</span> <span class="token punctuation">(</span>commit<span class="token punctuation">.</span>ok<span class="token punctuation">)</span> <span class="token keyword">return</span><span class="token punctuation">;</span>
<span class="token keyword">if</span> <span class="token punctuation">(</span><span class="token regex"><span class="token regex-delimiter">/</span><span class="token regex-source language-regex">nothing to commit</span><span class="token regex-delimiter">/</span><span class="token regex-flags">i</span></span><span class="token punctuation">.</span><span class="token function">test</span><span class="token punctuation">(</span>out<span class="token punctuation">)</span><span class="token punctuation">)</span> <span class="token keyword">return</span><span class="token punctuation">;</span> <span class="token comment">// benign — done</span>
<span class="token keyword">if</span> <span class="token punctuation">(</span><span class="token regex"><span class="token regex-delimiter">/</span><span class="token regex-source language-regex">index\.lock</span><span class="token regex-delimiter">/</span><span class="token regex-flags">i</span></span><span class="token punctuation">.</span><span class="token function">test</span><span class="token punctuation">(</span>commit<span class="token punctuation">.</span>err<span class="token punctuation">)</span><span class="token punctuation">)</span> <span class="token punctuation">{</span> <span class="token comment">// contended — back off and retry</span>
<span class="token function">sleepSync</span><span class="token punctuation">(</span><span class="token number">50</span> <span class="token operator">*</span> <span class="token punctuation">(</span>attempt <span class="token operator">+</span> <span class="token number">1</span><span class="token punctuation">)</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token keyword">continue</span><span class="token punctuation">;</span>
<span class="token punctuation">}</span>
<span class="token keyword">return</span><span class="token punctuation">;</span> <span class="token comment">// a non-lock failure: bail quietly; the next mutation retries</span>
<span class="token punctuation">}</span></code></pre>
<p>Three resilience ideas are packed into those lines. <strong>Backoff:</strong> each retry waits longer (<code>50 * (attempt+1)</code>
ms), so a transient collision clears instead of hammering. <strong>Stale-lock recovery:</strong> a <code>.git/index.lock</code>
older than ten seconds is from a committer that died, so it’s safe to remove — otherwise one crash would
wedge the repo forever. And <strong>graceful give-up:</strong> a non-lock error doesn’t throw or block; it returns,
because the <em>next</em> mutation will stage and commit the same pending changes anyway. Nothing is lost by
bailing early.</p>
<figure class="fig fig-inline"><img src="/blog/assets/media/recovering-from-agent-failures/note-1.png" alt="Hand-drawn sketch from “Recovering From Agent Failures: Resilience Patterns for a Hive”" loading="lazy" decoding="async" /></figure>
<h2 id="dont-choke-on-a-poison-message" tabindex="-1">Don’t choke on a poison message <a class="anchor" href="#dont-choke-on-a-poison-message" aria-hidden="true">#</a></h2>
<p>A file-based mailbox will eventually contain a half-written or malformed JSON file. The naive router
reads it, throws, and — if it retries the same file — spins on it forever. The fix is to <strong>quarantine</strong>:</p>
<pre class="language-ts"><code class="language-ts"><span class="token keyword">try</span> <span class="token punctuation">{</span>
<span class="token keyword">const</span> msg <span class="token operator">=</span> <span class="token keyword">this</span><span class="token punctuation">.</span><span class="token function">normalize</span><span class="token punctuation">(</span><span class="token constant">JSON</span><span class="token punctuation">.</span><span class="token function">parse</span><span class="token punctuation">(</span><span class="token function">read</span><span class="token punctuation">(</span>full<span class="token punctuation">)</span><span class="token punctuation">)</span><span class="token punctuation">,</span> id<span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token keyword">this</span><span class="token punctuation">.</span><span class="token function">routeMessage</span><span class="token punctuation">(</span>msg<span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token function">renameSync</span><span class="token punctuation">(</span>full<span class="token punctuation">,</span> <span class="token function">join</span><span class="token punctuation">(</span>outbox<span class="token punctuation">,</span> <span class="token string">'.sent'</span><span class="token punctuation">,</span> f<span class="token punctuation">)</span><span class="token punctuation">)</span><span class="token punctuation">;</span> <span class="token comment">// archive, don't reprocess</span>
<span class="token punctuation">}</span> <span class="token keyword">catch</span> <span class="token punctuation">{</span>
<span class="token function">renameSync</span><span class="token punctuation">(</span>full<span class="token punctuation">,</span> <span class="token function">join</span><span class="token punctuation">(</span>outbox<span class="token punctuation">,</span> <span class="token string">'.sent'</span><span class="token punctuation">,</span> <span class="token template-string"><span class="token template-punctuation string">`</span><span class="token string">bad-</span><span class="token interpolation"><span class="token interpolation-punctuation punctuation">${</span>f<span class="token interpolation-punctuation punctuation">}</span></span><span class="token template-punctuation string">`</span></span><span class="token punctuation">)</span><span class="token punctuation">)</span><span class="token punctuation">;</span> <span class="token comment">// quarantine so we don't spin on it</span>
<span class="token punctuation">}</span></code></pre>
<p>A message that won’t parse is moved aside with a <code>bad-</code> prefix and the router moves on. One corrupt file
can’t stall the bus, and the quarantined file is still on disk for you to inspect. (Successful messages
get archived too — moved out of the outbox so they’re never routed twice.)</p>
<h2 id="circuit-break-the-runaways" tabindex="-1">Circuit-break the runaways <a class="anchor" href="#circuit-break-the-runaways" aria-hidden="true">#</a></h2>
<p>Two agents can get into a polite infinite loop — A asks B, B asks A, forever. Protocol etiquette helps
(only <code>request</code>/<code>query</code>/<code>propose</code> expect a reply; <code>inform</code>/<code>done</code> are terminal), but you still want a hard
backstop. Every message carries a <strong>hop count</strong>, and the router drops anything past the cap:</p>
<pre class="language-ts"><code class="language-ts"><span class="token keyword">if</span> <span class="token punctuation">(</span>msg<span class="token punctuation">.</span>hops <span class="token operator">></span> <span class="token constant">HOP_CAP</span><span class="token punctuation">)</span> <span class="token punctuation">{</span>
<span class="token keyword">this</span><span class="token punctuation">.</span><span class="token function">appendLog</span><span class="token punctuation">(</span><span class="token punctuation">{</span> kind<span class="token operator">:</span> <span class="token string">'drop'</span><span class="token punctuation">,</span> reason<span class="token operator">:</span> <span class="token string">'hop-cap'</span><span class="token punctuation">,</span> from<span class="token operator">:</span> msg<span class="token punctuation">.</span>from<span class="token punctuation">,</span> to<span class="token operator">:</span> msg<span class="token punctuation">.</span>to<span class="token punctuation">,</span> id<span class="token operator">:</span> msg<span class="token punctuation">.</span>id <span class="token punctuation">}</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token keyword">return</span><span class="token punctuation">;</span>
<span class="token punctuation">}</span></code></pre>
<p>It’s deliberately blunt: it guarantees the conversation terminates. And because the drop is <em>logged</em>, a
runaway leaves a breadcrumb instead of a silent hang — you can read the log and see exactly which thread
ran away.</p>
<figure class="fig fig-inline"><img src="/blog/assets/media/recovering-from-agent-failures/note-2.png" alt="Hand-drawn sketch from “Recovering From Agent Failures: Resilience Patterns for a Hive”" loading="lazy" decoding="async" /></figure>
<h2 id="idempotent-by-construction" tabindex="-1">Idempotent by construction <a class="anchor" href="#idempotent-by-construction" aria-hidden="true">#</a></h2>
<p>The cheapest way to survive duplicates and replays is to make re-handling a no-op. In the hive, an agent
moves a message to <code>inbox/.done/</code> once it’s handled, and the protocol is explicit: <em>re-reading a message
you already moved to <code>.done/</code> is a no-op — don’t reprocess.</em> Delivery is <strong>at-least-once</strong>; handling is
<strong>idempotent</strong>. So a redelivered message, a crash-and-resume, or a curious re-read all do nothing the
second time. The same property underwrites the <a href="/blog/append-only-event-log-agents/">append-only event log</a>:
each consumer tracks how far it has read, and re-reading a line it already processed changes no state.
Idempotency turns “did this run twice?” from a bug into a shrug.</p>
<h2 id="keep-the-loop-alive-keep-a-record" tabindex="-1">Keep the loop alive, keep a record <a class="anchor" href="#keep-the-loop-alive-keep-a-record" aria-hidden="true">#</a></h2>
<p>The last pattern is error isolation: a failure in one step must not kill the whole system. The hive’s
router wraps each pass so a single bad tick can’t bring it down —</p>
<pre class="language-ts"><code class="language-ts"><span class="token keyword">try</span> <span class="token punctuation">{</span> <span class="token keyword">this</span><span class="token punctuation">.</span><span class="token function">routeOnce</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">;</span> <span class="token punctuation">}</span> <span class="token keyword">catch</span> <span class="token punctuation">{</span> <span class="token comment">/* keep the loop alive */</span> <span class="token punctuation">}</span></code></pre>
<p>— and lifecycle handlers are written to “never crash” on a best-effort path. Pair that with two recovery
affordances and you can always get back to a known state: the <strong>append-only <code>log.jsonl</code></strong> lets you replay
the system’s history to find exactly where it diverged, and <strong>agent archival</strong> means closing an agent
keeps its memory and history intact rather than deleting them — a stopped agent is recoverable, not gone.
This is the same timeline you’d reach for when <a href="/blog/debugging-multi-agent-systems/">debugging a multi-agent system</a>;
resilience and debuggability come from the same record.</p>
<h2 id="a-resilience-checklist" tabindex="-1">A resilience checklist <a class="anchor" href="#a-resilience-checklist" aria-hidden="true">#</a></h2>
<p>For any multi-agent system you build:</p>
<ol>
<li><strong>Retry shared writes</strong> with backoff, and recover stale locks — never let one crash wedge shared state.</li>
<li><strong>Quarantine</strong> unparseable messages instead of retrying them forever.</li>
<li><strong>Cap the hops</strong> on your message path so conversations can’t loop infinitely.</li>
<li><strong>Make handling idempotent</strong> — “already done” should be a cheap, observable fact (a moved file, a cursor).</li>
<li><strong>Isolate failures</strong> so one thrown step doesn’t take down the loop.</li>
<li><strong>Keep an append-only record</strong> so any state is reconstructable and any agent is recoverable.</li>
</ol>
<p>None of these are exotic — they’re the boring distributed-systems hygiene that turns a flaky pile of
agents into a system you can trust to run unattended. Build them in once, at the
<a href="/#how">orchestration layer</a>, and every agent inherits them for free.</p>
<p>Want to see these patterns in a hive you can actually watch recover? You can
<a href="/#install">download Munder Difflin</a> free — it’s open source, and the whole coordination layer is right
there to read.</p>
<section class="faq" aria-label="Frequently asked questions">
<h2 id="faq">FAQ</h2>
<div class="qa">
<p class="q">What happens when an AI agent in a multi-agent system fails?</p>
<p class="a">In a well-built hive, a single failure stays local. A crashed step doesn't take down the router; a malformed message is quarantined instead of retried forever; a runaway loop is dropped by a hop cap; and shared state is protected by retries so one stalled write doesn't block the rest. The system keeps running and the failure is recoverable, not fatal.</p>
</div>
<div class="qa">
<p class="q">How do you make agent message handling idempotent?</p>
<p class="a">Make 'already handled' a cheap, observable fact. In a file-based hive, an agent moves a message to inbox/.done/ once handled, and re-reading a done message is a no-op. Delivery is at-least-once; handling is idempotent — so a duplicate or replayed message does nothing the second time. The same idea drives an append-only event log: re-reading a line you've already processed changes nothing.</p>
</div>
<div class="qa">
<p class="q">How do you stop AI agents from looping forever?</p>
<p class="a">Put a circuit breaker on the message path. Every message carries a hop count; once it exceeds a cap, the router drops it and logs the drop rather than letting two agents ping-pong indefinitely. It's a blunt instrument on purpose — it guarantees termination, and the dropped, logged message tells you where to look.</p>
</div>
</section>
<hr />
<div class="share">
<span class="lbl">Tags</span>
<a class="tag" href="/blog/tags/internals/">Internals</a><a class="tag" href="/blog/tags/concurrency/">Concurrency</a><a class="tag" href="/blog/tags/multi-agent/">Multi-Agent</a><a class="tag" href="/blog/tags/messaging/">Messaging</a>
</div>
</div>
<aside class="toc-rail" aria-label="Table of contents">
<div class="tt">On this page</div>
<ol>
<li class="lvl-2"><a href="#partial-failure-is-the-default">Partial failure is the default</a></li><li class="lvl-2"><a href="#make-shared-writes-survivable">Make shared writes survivable</a></li><li class="lvl-2"><a href="#dont-choke-on-a-poison-message">Don’t choke on a poison message</a></li><li class="lvl-2"><a href="#circuit-break-the-runaways">Circuit-break the runaways</a></li><li class="lvl-2"><a href="#idempotent-by-construction">Idempotent by construction</a></li><li class="lvl-2"><a href="#keep-the-loop-alive-keep-a-record">Keep the loop alive, keep a record</a></li><li class="lvl-2"><a href="#a-resilience-checklist">A resilience checklist</a></li>
</ol>
</aside>
</div>
<footer class="post-foot wrap"><div class="prevnext">
<a class="pn prev" href="/blog/scheduling-autonomous-agent-missions/"><span class="k">← Older</span><span class="t">Make a Hive Work While You Sleep: Scheduling Autonomous Agent Missions</span></a>
<a class="pn next" href="/blog/prompt-caching-for-ai-agents/"><span class="k">Newer →</span><span class="t">Prompt Caching for AI Agents: Stop Paying for the Same Tokens Twice</span></a>
</div>
<section class="related">
<h2>Related in Internals</h2>
<div class="post-grid">
<article class="card t-internals">
<a class="thumb t-internals" href="/blog/the-spend-counter-that-went-back-to-zero/" aria-hidden="true" tabindex="-1"><img src="/blog/assets/media/the-spend-counter-that-went-back-to-zero/hero.png" alt="" loading="lazy" decoding="async" /></a>
<div class="body">
<div class="meta">
<time datetime="2026-08-22">Aug 22, 2026</time>
<span class="dot" aria-hidden="true"></span>
<span>10 min</span>
</div>
<h3><a href="/blog/the-spend-counter-that-went-back-to-zero/">The Spend Counter That Went Back to Zero</a></h3>
<p class="dek">Our own floor was under reporting what it cost by 59 percent. The counter was cumulative since process start, the app restarts, and the session id stayed the same. Here is how a monotonic invariant let us recover the real number from an append-only log.</p>
<div class="foot">
<span class="tag kind">Internals</span>
<a class="more" href="/blog/the-spend-counter-that-went-back-to-zero/" aria-label="Read: The Spend Counter That Went Back to Zero">Read →</a>
</div>
</div>
</article>
<article class="card t-internals">
<a class="thumb t-internals" href="/blog/the-newline-that-silenced-windows-agents/" aria-hidden="true" tabindex="-1"><img src="/blog/assets/media/the-newline-that-silenced-windows-agents/hero.png" alt="" loading="lazy" decoding="async" /></a>
<div class="body">
<div class="meta">
<time datetime="2026-08-19">Aug 19, 2026</time>
<span class="dot" aria-hidden="true"></span>
<span>4 min</span>
</div>
<h3><a href="/blog/the-newline-that-silenced-windows-agents/">The Newline That Silenced Every Windows Agent</a></h3>
<p class="dek">A cmd.exe parsing rule from the 1980s meant Windows agents received exactly one line of their multi-line startup protocol — and nothing errored. The anatomy of our worst silent failure, and the fix.</p>
<div class="foot">
<span class="tag kind">Internals</span>
<a class="more" href="/blog/the-newline-that-silenced-windows-agents/" aria-label="Read: The Newline That Silenced Every Windows Agent">Read →</a>
</div>
</div>
</article>
<article class="card t-internals">
<a class="thumb t-internals" href="/blog/why-our-auto-update-never-ran/" aria-hidden="true" tabindex="-1"><img src="/blog/assets/media/why-our-auto-update-never-ran/hero.png" alt="" loading="lazy" decoding="async" /></a>
<div class="body">
<div class="meta">
<time datetime="2026-08-08">Aug 8, 2026</time>
<span class="dot" aria-hidden="true"></span>
<span>5 min</span>
</div>
<h3><a href="/blog/why-our-auto-update-never-ran/">Our Auto-Update Never Ran Once: A CommonJS Export That Vanished Into an ESM Namespace</a></h3>
<p class="dek">Munder Difflin shipped auto-update in v0.3.4 and it silently never worked in a single packaged build. The cause was one destructuring assignment across the CommonJS/ESM boundary — and a catch block that threw the evidence away. Here's how we found it, and what v0.3.7 changes.</p>
<div class="foot">
<span class="tag kind">Internals</span>
<a class="more" href="/blog/why-our-auto-update-never-ran/" aria-label="Read: Our Auto-Update Never Ran Once: A CommonJS Export That Vanished Into an ESM Namespace">Read →</a>
</div>
</div>
</article>
</div>
</section>
</footer>
</article>
</main>
<footer class="site-foot">
<div class="wrap">
<div class="foot-top">
<a class="foot-brand brand" href="https://munderdiffl.in" aria-label="Munder Difflin home">
<img class="brand-logo" src="https://munderdiffl.in/logo.png" width="1318" height="840" alt="Munder Difflin, Inc. — Multi-Agent Harness" />
</a>
<div class="foot-links">
<a href="/blog/">Latest</a>
<a href="/blog/topics/">Topics</a>
<a href="/blog/about/">About</a>
<a href="https://munderdiffl.in/blog/feed.xml">RSS</a>
<a href="https://github.com/chaitanyagiri/munder-difflin">GitHub</a>
<a href="https://munderdiffl.in">munderdiffl.in ↗</a>
</div>
</div>
<div class="foot-meta">
© 2026 Munder Difflin · Local-first · MIT-licensed ·
Built on <a href="https://munderdiffl.in">Electron, React, Pixi.js, xterm.js & node-pty</a>.
Run an office of agents while you sleep.
</div>
</div>
</footer>
<script>
// sticky-nav border on scroll
(function () {
var nav = document.getElementById('nav');
if (!nav) return;
var onScroll = function () { nav.classList.toggle('scrolled', window.scrollY > 8); };
onScroll(); window.addEventListener('scroll', onScroll, { passive: true });
})();
// YouTube click-to-load: thumbnail button → youtube-nocookie iframe
(function () {
document.addEventListener('click', function (e) {
var btn = e.target.closest('.yt-load');
if (!btn) return;
var box = btn.closest('.yt');
var id = box && box.getAttribute('data-yt');
// Only an 11 character YouTube video id may reach the iframe URL.
if (!id || !/^[A-Za-z0-9_-]{11}$/.test(id)) return;
var frame = document.createElement('iframe');
frame.src = 'https://www.youtube-nocookie.com/embed/' + encodeURIComponent(id) + '?autoplay=1';
frame.title = box.getAttribute('data-title') || 'YouTube video';
frame.allow = 'accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share';
frame.setAttribute('allowfullscreen', '');
box.replaceChildren(frame);
});
})();
</script>
</body>
</html>