Hey folks, this is Grish, a principal software engineer at Microsoft. Outside my job, I build open source tools for AI agents. One of them is MCP Pacemaker, a supervised bridge that keeps MCP servers running. Before we start, a small disclosure. The views in this talk are my own and don't represent my employer. So sub-agents are a distributed system. Over the past year, I have been using agents and sub-agents on real engineering work. Devops, code reviews, instant tracing, and more. This talk is about what happens when one agent hands work to another.
So here's an architecture. The orchestrator splits the task and hands the pieces to three different sub-agents. They all run at the same time. They all read from the same shared state: configuration, memory files, repos, working trees, issues, vector stores. And they don't just think. They make tool calls to real systems, which touch databases, APIs, CI tools, deployment pipelines. And the results come back. An orchestrator merges them into a single answer. An orchestrator workers with shared mutable state and the results merge from concurrent executions. This represents a classic distributed system.
I have known how to reason with distributed systems for decades. But none of this setup came with it. What you get is a function that takes a string and returns a string. Failures we hit are not new, are not specific to AI agents. They are classic distributed system failures. Partial failure. A normal call that fails halfway through and returns an exception or error code. In a sub-agent case, it returns text that looks successful. Dirty reads. Normally we have isolation and versions. Here, every worker reads one shared context, including things another worker only guessed.
Unbounded fanout. A busy service pushes back with queues, 429s, 503s. In agents, the orchestrator doesn't see any of this. It just starts a worker. Retries. In normal distributed systems, we build idempotency to make retries reliable. In agents, a retried sub-agent runs the whole task again, with side effects included. For each of these cases, I will name the concept it already is. Then I will put them together as a consistency model I am proposing and walk through why each part is there. Start with the failure model, because everything else depends on it.
The friendly case is a crash stop. The process that was running correctly stops and stays stopped. The sub-agent that throws an error fits in this box. It's easy to handle. Next, no reply. The call is lost or it's very late. We'll come back to this one. The hot case is the one from Byzantine Generals Problem. A component that gives conflicting information. The process answers and the answer is wrong. A half-finished sub-agent sits closest to this box. It is not malicious, but from the outside it looks the same. It doesn't crash. It answers fluently.
Let's jump into this. A sub-agent that half-finished doesn't raise an error. It returns normal-looking text with the same type signature as success.
I talked about one version of this in one of my talks. We pointed an agent at a model. Here's an illustration I used there with three different paths which gave the same answer. The first one pulled the telemetry and compared it with a non-benign set. It actually did the work. The second one matched against the title it had seen before and gave the response. The third one didn't do anything. It just resonated. All three are categorized as benign with the same level of confidence. We have three statements. And nothing downstream can tell these apart. The orchestrator can read the conclusion. It cannot read how much work was behind it.
Now the call gets no reply. The orchestrator sent work and a timeout fired. From here three cases look the same. The sub-agent is still working. It crashed and the reply was lost. It's a hard limit, not a Turing problem. The FLP paper from 1985 showed that in an asynchronous system with even one faulty process, agreement can fail to finish. Chandra and Toueg's answer in 1996 was failure detectors that can make mistakes. They suspect, they don't know.
I hit both directions in my own open source project, MCP Pacemaker Supervised Bridge. A server whose first run downloads itself hit the 30 second call timeout and looked broken. It was slow, not dead. We fixed it by giving initialization its own timeout. Now the other way. A server crashed during a call. The call then timed out. And the timeout overwrote the exit code that explained the crash. We fixed it by recording the timeout only when it was alive. So timeout is a suspicion. Record it as unknown and keep the real cause.
And now make failure a value. Let's take this illustration. Partial is a normal answer here. The protocols already have a slot for this. In A2A, a task can end as completed, failed, cancelled, rejected, or stopped and ask for input. In MCP, a tool result can say, is error true. But a sub-agent can still say completed while its text says something else. And a loop that only reads the text never sees the difference.
Another split. Checking a condition and getting no is a different fact from not being able to check at all. My own individual internet draft on evaluation states talks about this. Collapse the two and you change what gets retried, who gets paged, and what the team says later. Next, dirty reads. Let's take this made up example from one of my talks. The sub-agent, the search, it writes into a shared context saying that error rate fell by 80%. It didn't measure that. It inferred it.
Now two other sub-agents read from the same shared context. The second sub-agent writes a review note and picks the same sentence up. The third agent writes a runbook and uses it as a reason to proceed. The orchestrator merges all three. Three artifacts agree. It's an unsupported sentence read three different times. The 1995 critique of SQL isolation levels defines a dirty read as you read a value before the writer commits or rolls back. In a shared context, a guess is readable the moment it is written. And nothing marks it as unchecked.
A regular fix is to ask three sub-agents and get a quorum. Quorums do work for a specific reason. In weighted voting from 1979, the read quorum plus write quorum is greater than total. So every read overlaps the latest write. The overlap is the guarantee. The three sub-agents that read the same shared context doesn't give you that. They are not independent copies. They read the same guess. Their agreement is one source counted three different times. Let's pick a consistency model. In databases we have a spectrum for this. Linearizable. Every operation appears to happen at one point in real-time order. Sequential. One total order that respects each process's own order.
Causal. Operations that are causally related appear in the same order everywhere. Session guarantees. There are promises to one client, like read your writes and monotonic reads. Eventually, if no new updates are made, reads eventually return the last file. A shared context gives you none of these. There is no standard guarantee at all. And you don't need the top consistency models. The strongest models cannot stay available when the network splits. Causal and session guarantees can, as long as each client sticks to one place. For sub-agents, that place is the orchestrator. So here's a consistency model I use for sub-agents. I call it SAFE Handoffs.
S stands for Source Reads. Every fact a worker hands on carries its source, version, time and revision. And decisions read only fresh source facts. A. At Most Once Effects. Every write has an identity and a single use approval for that exact action. An outcome is read back, never replayed. If the fanout budget is exceeded, each downstream gets a gate and a bounded wait. And refusal counts as a failure. E stands for Explicit Outcomes. Every handoff ends in a named state. And a timeout is unknown, with its cause kept.
This consistency model is the one I use for my own sub-agents. It's not a universal model. It's based on my own public work. Some of it is in my MCP Pacemaker Bridge. And some is based on my other docs and my own internet draft. Now let's see what's behind each letter. S. Source Reads. It's the answer to dirty reads. Where one worker's guess becomes another worker's fact. What helps is to treat every fact as a record, not a sentence. Lamport's 1978 paper defined when one event happened before another. The fact's provenance is that record. What it was read from and when.
Let's take this made up example. The record names the claim and its revision. The source and its version. The scope at three different times: when the data was current, when we read it, and when we used it. Freshness is checked when the fact is used. In this illustration, the data ends at 9:05. We read it at 9:06. And we decided at 9:07. In this case, we picked a five minute limit. So the data decision at 9:07 is fine.
Now at 9:15, the second decision came in. Because our freshness limit is five minutes, this is still recorded. We reject it. We reject it. And we say that the next decision needs another read. This is how you separate an observation from an inference. An observation has a source and a read time. An inference has none.
A. At Most Once Effects is about retries. This is an illustration from my article about MCP Pacemaker Bridge. The orchestrator delegates a task. The sub-agent calls a tool which does a real write, like creating a PR. The reply is lost. The orchestrator knows one thing: the outcome is unknown. So it retries the whole task. The write happens again. This is a classic problem. In the 1984 RPC paper, it says that if the call returns, the procedure ran precisely once. If you get an exception, it ran once or not at all. And you are not told which. So you pick a delivery semantic. At most once, don't retry. And accept the fact that you may lose data.
At least once, retry. And accept that duplicates are possible. Exactly once. It happened at least once. And there is a way you can deduplicate, maybe by using an idempotency key. In MCP, idempotent hint is only a hint. If you need it, you build it. Here is a small design from my bridge on how I handle it. When a client comes back after restart, the bridge replaces the client's record and initializes against a fresh server. That's safe. It's just a handshake. And it doesn't restore tool state. What it never replaces is an uncertain tool call. When a shared server is recycled, the bridge drains it. And calls still unanswered at the deadline fail as potentially executed.
That status is honest. It tells the caller to go and check. What helped is giving every side effect an identity. Approval binds to that exact action. It's only used once. After the call, read back by that identity. Submitted is not confirmed. Confirm means you observe that effect. The last part of A is when work pauses and resumes.
A lease is a lock with a timeout. Martin Kleppman's post about distributed locking shows this problem. A client pauses while holding it. The lease expires. Someone else takes over. And the first client wakes up and writes anyway. The fix he proposed is a fencing token. A number that goes up every time the lock is granted. The storage remembers the highest token it has seen. And rejects any write with a lower token. Sub-agents pause and resume all the time. In my other talk, I put it this way: restore context, not side effects. So treat an approval like a fencing token. One action, one use, checked at the gate, not remembered in the prompt or conversation.
My bridge fixed the same class of bug. A stale exit or a deleted resume can no longer remove or bring back a replacement session. F. Fanout Budgets is about unbounded fanout. This is flow control or the lack of it. I hid this issue in my own MCP Bridge before it had a limit on cold starts. Many sessions start their service at the same time through NPX. They share one package cache. Every one of them failed with NPM's lock contention error. Nothing in any single request was wrong. The failure was the concurrency itself.
And when a downstream does push back, it can arrive as plain text. This is MCP spec's one example of tool execution error: a rate limit as one sentence. The model reads the sentence. The orchestrator code may never look. The next worker starts anyway. So I introduced a quota budget in my bridge. Cold starts that use a package manager go through a gate. Two at a time by default. Everyone else waits. And the wait is bounded to 15 seconds. Past that, the start goes ahead without a gate. And I documented why. A corrupted cache is a risk. While a hung client request is certainty. That is a choice for availability, made on purpose and written down.
And I also built a cap on sessions. At the cap, a new session waits up to 10 seconds. And then it's refused. That refusal now counts as a failure in health checks. Another book. Capacity has to be reserved before the synchronous start, not after. Otherwise queued starts overbook the cap. That is a check-then-act race. For sub-agents, give the orchestrator a number per downstream. A bounded wait and a refusal or cancel.
Now E. Explicit Outcomes. Every handoff ends in a named state, like stale or unknown, not just text. The last piece is, who decided that state? Treat the agent output as untrusted input, the same way you treat a request body from the internet. The orchestrator owns the checks, in code. Does the result match the schema? Is the evidence there? Is it fresh enough? Do the numbers hold when you recompute them? If a check fails, the step returns a refusal with a reason. It doesn't pass the text along with a warning paragraph underneath. If the same model can skip a check and declare it passed, you have a suggestion, not a boundary.
Here is a made up example from another talk. A sub-agent says the error rate fell. Before, it was 10 errors in 1000 requests. After, it was 6 errors in 600 requests. It went from 10 to 6, and it claimed that the error rate fell. But when we computed the rate, it's both 1%. We recomputed it, and then the claim is refused. A supported answer is fine. A deliberate handoff to a person is fine. A confident guess is not. So limitations. Because the consistency model is only useful when you know where we should start. So here's what SAFE model doesn't do. It doesn't make facts true. A source fact is checkable, not correct.
It doesn't give you exactly once delivery. A lost reply stays unknown until you read it back. It doesn't undo anything back. Undoing a partial task is a compensation step you design, like the SAGAS paper from 1987. And finally, there's no global order across workers, only causal order, perfect.
And it has a price. CAP theorem says that when the network splits, you trade off availability against consistency. My bridge shows availability for cold starts on purpose. For writes, SAFE picks consistency over availability. It refuses rather than guesses. PACELC adds that even without failures, you trade latency for consistency. Every freshness check is another read. And every refusal needs an owner.
So where it doesn't fit. If a sub-agent only drafts text that a person reads before anything happens, most of this is overkill. It also assumes that there's one single orchestrator. If you have more, this doesn't fit. Peer agents with no single place to stick to need something else. This is the consistency model I use for my own agents that touch actual production systems. It's not universal. So wrapping up, here are three key takeaways.
Treat every handoff to a sub-agent as a network call. It can fail halfway, it can be slow, and it can come back twice. Return status, not just text. If the result can't say partial, stale, or unknown, the orchestrator will read it as done. And start with a SAFE consistency model and enforce it in code. Keep what fits and change what doesn't. We already know how to build distributed systems. We just have to notice that we are building one.
So these are some of the sources behind this talk. On the left side, it's my own work: my open source projects, my articles, internet drafts, and my talks. On the right side, specs and standards. And a bunch of papers behind each concept. Thank you. Read three different times. The 1995 critique of SQL isolation levels define a dirty read as, you read a value before the writer commits or rolls back. In a shade context, a guess is readable the moment it is written. And nothing marks it as unchecked. A regular fix is to ask three sub-agents and get a quorum. Quorums do work for a specific reason.
In weighted voting from 1979, the read quorum plus write quorum is greater than total. So every read overlaps the latest write. The overlap is the guarantee.
The three sub-agents that read the same shade context does not give you that. They are not independent copies. They read the same guess. Their agreement is one source counted three different times. Let's pick a consistency model. In databases, we have a cavalry for this. Linearizable. Every operation appears to happen at one point in real-time order. Sequential. One total order that respects each process's own order. Causal. Operations that are causally related appear in the same order everywhere. Session guarantees. There are promises to one client. Like read your writes and monotonic reads. Eventually, if no new updates are made, reads eventually return the last file.
A shared context gives you none of these. There is no standard guarantee at all. And you don't need the top consistency models. The strongest models cannot stay available when the network splits. Causal end-session guarantees can, as long as each client sticks to one place. For sub-agents, that place is the orchestrator. So, here's a consistency model I use for sub-agents. I call it, save handoffs. S stands for source feeds. Every fact a worker hands on carries its source version as of time and revision. And decisions read only fresh source facts. A. At most months effects. Every write has an identity and a single use approval for that exact action.
An outcome is read back, never replayed. If fanout budgets. Each downstream gets a gate and a bounded weight. And refusal counts as a failure. E stands for explicit outcomes. Every handoff ends in a named state. And a timeout is unknown. With its cost kept. This consistency model is the one I use for my own sub-agents. It's not a universal model. It's based off my own public work. Some of it is in my FCP pacemaker bridge. And some are based on my other docs and my own internet draft. Now, let's see what's behind each letter. Yes, source reads. It's the answer to 30 reads. Where one worker's guess becomes another worker's fact.
What helps is to treat every fact as a record, not a sentence. Lampard's 1978 paper defined when one event happened before another. The fact's provenance is that record. What it was read from and when. Let's take this made up example. The record names, the claim and its revision. The source and its version. The scope and three different times. When the data was current, when we read it and when we used it. Freshness is checked when the fact is used. In this illustration, the data ends at 9.05. We read it at 9.06. And we decided at 9.07. In this case, we picked a five minute limit. So the data decision at 9.07 is fine. Now, at 9.15, the second decision came in.
Because our freshness limit is five, this is still recorded. We reject it. We reject it. And we say that the next decision needs another read. This is how you separate an observation from an inference. An observation has a source and a read time. An inference has none. Yay! At most of it is about retries. This is an illustration from my article about MCP Pacemaker Bridge. The orchestrator delegates a task. The sub-agent calls a tool which does a real write. Like creating a PR. The reply is lost. The orchestrator knows one thing. The outcome is unknown. So, it retries the whole task. The write happens again. This is a classic problem.
In 1984, RPC paper, it says that if the call returns, the procedure ran precisely once. If you get an exception, it ran once or not at all. And you are not told which. So, you pick a delivery semantic. At most once, don't retry. And accept the fact that you may be lost. At least once, retry. And accept that duplicates are possible. Exactly once. It happened at least once. And there is a way you can deduplicate. Maybe by using an idempotency key. In MCP, idempotent hint is only a hint. And Dt false or false. If you need it, you build it. Here is the small design from my bridge on how I handle it. When a client comes back after restart,
the bridge replaces the client's record initialize against a fresh server. That's safe. It's just a handshake. And it does not restore tool state. What it never replaces is an uncertain tool call. When a shared server is recycled, the bridge drains it. And calls still unanswered at the deadline fail as potentially excluded. That status is honest. It tells the caller to go and check. What helped is giving every side effect an identity. Approval binds to that exact action. It's only used once. After the call, read back by that identity. Submitted is not confirmed. Confirm means you observe that effect. The last part of A. It shows up when work passes and resumes.
A lease is a lock with a timeout. Martin Kleppman's post about distributed locking shows this problem. A client passes while holding it. The lease expects. Someone else takes over. And the first client wakes up and writes anyway. The fix he proposed is a fencing token. A number that goes up every time the lock is granted. The storage remembers the highest token it has seen. And rejects any right with a holdover. Sub-agents pause and resume all the time. In my other talk, as I put it, Restore context, not side effects. So treat an approval like a fencing token. One action, one use. Checked at the gate. Not remembered in the prompt or conversation.
My bridge fixed the same class of bug. A stale exit or a deleted resume can no longer remove or bring back a replacement session. If Fanout Budgets is about unbounded fanout. This is flow control or the lack of it. I hid this issue in my own MCP bridge before it had a limit on cold starts. Many sessions start their service at the same time through NPX. They share one package cache. Every one of them failed with NPM's lock compromise error. Nothing in any single request was wrong. The failures was the concurrency itself. And when a downstream does push back, it can arrive as a plain text. This is MCP specs one example of tool execution error. A rate limit as one sentence.
The model reads the sentence. The orchestrator code may never look. The next worker starts anyway. So I introduced a quota budget in my bridge. Cold starts that use a package manager go through a gate. Two at a time by default. Everyone else waits. And the wait is bounded 15 seconds. Past that, the start goes ahead without a gate. And I documented why. A corrupted cache is a risk. While a hunk client request is certainty. That is a choice for availability. Made on purpose and written down. And I also built a cap on sessions. At the cap, a new session waits up to 10 seconds. And then it's refused. That refusal now counts as a failure in health. Another book.
Capacity has to be reserved before the synchronous start. Not after. Otherwise, Cued starts overbook the cap. That is a check then act race. For sub-agents, give the orchestrator a number per downstream. A bounded wait and a refusory cancel. Now, E. Explicit Outcomes. Every hand of ends in a named state. Like stale or unknown. Not just text. The last piece is, Who decided that state? Treats of the agent output as untrusted input. The same way you treat a request body from the internet. The orchestrator owns the checks. In code. Does the result match the schema? Is the evidence there? Is it fresh enough? Do the numbers hold when you recompute them? If a check fails,
the step returns a refusal with a reason. It does not pass the text along with a warning paragraph underneath. If the same model can skip a check and declare it passed, you have a request, not a boundary. Here is a made up example from another talk. A sub-agent says the error rate fell. Before, it was 10 errors in 1000 requests. After, it was 6 errors in 600 requests. It went from 10 to 6, and it claimed that the error rate fell. But, when we computed the rate, it's both 1%. We recomputed it, and then the claim is refused. A supported answer is fine. A deliberate handoff to a person is fine. A confident guess, it's not. So limitations.
Because the consistency model is only useful when you know where we should start. So, here's what SAFE model does not do. It does not make facts true. A source fact is checkable, not correct. It does not give you exactly one's delivery. A lost reply stays unknown until you read it back. It does not draw anything back. Undoing a partial task is a compensation step you design. Like the SAGAS paper from 1987. And, finally, there's no global order across workers. Only causal order, perfect. And, it has a price. CAP theorem says that, when the network splits, you trade off availability against consistency. MyBridge shows availability for cold starts, on purpose.
For rights, SAFE picks consistency over availability. It refuses rather than guesses. PACLAC adds that, even without failures, you trade latency for consistency. Every freshness check is another read. And, every refusal needs an owner. So, where it does not fit. If a sub-agent only drafts text that a person reads before anything happens, most of this is a work-out. It also assumes that there's one single orchestrator. If you have more, this does not fit. Peer agents with no single place to stick to need something else. This is the consistency model I use for my own agents, that touch actual real production systems. It's not universal.
So, wrapping up, here's three key takeaways. Treat every handoff to a sub-agent as a network call. It can fail halfway, it can be slow, and it can come back twice. Return status, not just text. If the result cannot say partial, stale, or unknown, the orchestrator will read it as done. And, start with our SAFE consistency model, and enforce it in code. Keep what fits, and change what does not. We already know how to build distributed systems. We just have to notice that we are building one. So, these are some of the sources behind this talk. On the left side, it's my own work, my open source projects, my articles, internet drafts, and my talks. On the right side,
specs and standards. And, a bunch of papers behind each concept. Thank you.