把子智能体当作分布式系统:Girish Konda 的 SAFE 交接设计
原题Your Sub-Agents Are a Distributed System. Treat Them Like One. - Girish Konda, Microsoft
看前速览
Girish Konda 用分布式系统的经验解释,编排器如何处理子智能体超时、证据过期、重复写入和并发失控。
超时意味着结果未知
在 Konda 的桥接器中,服务可能只是初始化慢,也可能在调用途中崩溃。一概记成普通超时,会丢掉故障原因,还可能触发重复写入。
多份结果需要独立证据
三个子智能体可能只是复述了共享上下文里同一句未经验证的判断。给结论附上来源和版本,使用时检查时效,并区分实测和推断。
由编排器校验写入和结果
为获批的写入指定唯一身份,先按身份回读结果,再判断是否需要重试。给下游设并发预算,由代码拒绝无效或过期的证据。
完整摘要
子智能体可能只做了一半,却返回一份看似完整的结果。调用超时也可能对应几种不同结果。Konda 结合自己的 MCP 桥接器提出 SAFE 交接方式:记录来源并检查时效,给写入分配身份并回读,限制下游并发,由编排器代码判定结果状态。他也讨论了这一方案在多编排器和低风险文稿任务中的局限。
章节
文字稿
简要描述Brief Description
Girish Konda 将分布式系统的故障模型应用于子代理编排,借鉴了他自己的 MCP 桥接器实例,并介绍了他的 SAFE 交接模型。Girish Konda applies distributed-systems failure models to sub-agent orchestration, drawing on examples from his own MCP bridge and presenting his SAFE handoff model.
目录Table of Contents
- 子代理作为分布式系统工作Sub-agent work as a distributed system
- 部分失败和超时Partial failure and timeouts
- 脏读与一致性保证Dirty reads and consistency guarantees
- SAFE 交接与溯源SAFE handoffs and provenance
- 至多一次副作用与过期审批At-most-once effects and stale approvals
- 扇出预算与容量Fanout budgets and capacity
- 明确的结果和限制Explicit outcomes and limits
子代理工作作为一种分布式系统Sub-agent work as a distributed system
大家好,我是 Girish,微软的首席软件工程师。工作之余,我会为 AI 智能体构建开源工具。其中之一是 MCP Pacemaker,这是一个受监督的桥接工具,能让 MCP 服务器持续运行。开始之前,先做个简短的免责声明:本次演讲中的观点仅代表我个人,不代表我的雇主。 那么,子代理还是分布式系统?过去一年里,我一直在真实的工程工作中使用智能体和子代理,比如开发会话、代码评审、即时崩溃之类的各种任务。这次演讲要讲的是,一个智能体把工作交给另一个智能体时会发生什么。 下面是一个架构示意图:协调器将任务拆分,然后把各个部分交给三个不同的子代理。它们同时运行,并且都从同一份共享状态中读取数据,包括对话、记忆文件、代码仓库、工作树、问题单和向量存储。Hey folks, this is Girish, 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 do not represent my employer. So, sub agents or distributed system. Over the past year, I have been using agents and sub agents on real engineering work. Dev sessions, code reviews, instant crashing, what not. 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, conversation, memory files, repo, working trees, issues, vector stores.
而且它们不只是思考,还会调用真实系统中的工具,这些系统涉及数据库、API、CI 工具和部署流水线。然后结果会返回,由编排器将它们合并成一个答案。编排器和工作器共享可变状态,结果则由并发执行合并而来。这体现了一个经典的分布式系统。我几十年来一直知道如何分析分布式系统,但这里的设置却没有附带任何这方面的东西。你得到的只是一个接收字符串并返回字符串的函数。我们遇到的故障并不是什么新问题,也不是 AI 智能体特有的问题。它们都是经典的分布式系统故障。部分故障:一次普通调用执行到一半时失败,并返回异常错误代码。而在子智能体的情况下,它返回的文本看起来像是成功了。脏读。通常我们会有隔离级别。And they don't just think, they make tool calls to real systems which touch databases, APIs, CI tools, deployment pipelines. And their results come back and orchestrator merges them into a single answer. An orchestrator workers shared mutable state and 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 the 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 error code. In a sub agent case it returns text that looks like a success. Dirty reads. Normally we have isolations versions.
这里,每个工作器读取同一份共享上下文,其中包含其他工作器仅仅猜测过的信息。扇出没有上限。繁忙的服务会通过队列、429 和 503 状态码施加反压。在智能体系统中,编排器看不到这些情况。它只会启动工作器,然后重试。在常规分布式系统中,我们会构建幂等机制,让重试变得可靠。而在智能体系统中,重试时子智能体会把整个任务重新执行一遍,副作用也包括在内。对于这些情况,我会逐一说出它们的概念,然后把它们组合起来,作为我提议的一种一致性模型,并说明模型的每个部分为何存在。先从故障模型开始,因为其他一切都取决于它。一种比较友好的情况是崩溃停止:一个原本正常运行的进程停止后就一直保持停止状态。如果这个模型中的子智能体抛出错误,就很容易处理。Here every worker reads one shared context including things other worker only guessed. Unbounded fanout. A busy service pushes back with the queues 429s 503s. In agents orchestrator does not see any of this. It just starts in the worker. Retries. Normal distributed systems we build an idempotency to make retries reliable. In agents a retry sub agent runs the whole task again with side effects included. For each of these case I'll name the concept it all it is. Then I'll put them together as a consistency model I'm proposing. And walk through why each part is there. Start with the failure model because everything else depends on it. A friendly case is a crash down. A process that was running correctly stops and stays stopped. A sub agent that throws an error in this box it's easy to handle.
部分失败与超时Partial failure and timeouts
接下来,没有回复。调用丢失了,或者已经很晚了。我们很快会回到这个问题。最棘手的情况就是拜占庭将军问题中的那种情况:某个组件给出了相互矛盾的信息。进程作出了响应,但答案是错的。一个只完成了一半的子代理待在盒子旁边。它并非恶意,但从外部看起来一模一样。它不会崩溃。它能流畅地作答。我们来看看这个问题。这个只完成了一半的子代理不会报错。它返回格式看起来正常、类型与成功结果相同的文本。我曾在一次演讲中谈到过这种情况的一个版本。我们让一个代理去处理[不清楚]。这是我当时用的一个示意图,其中有三条不同的路径得出了相同的答案。第一条路径,它提取了遥测数据,并与一个非良性集合进行比较。它确实完成了这项工作。第二条路径,它根据自己以前见过的标题进行匹配,然后给出了响应。Next, no reply. The call is lost or it's very late. We'll come back to this soon. 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 close to the box. It is not malicious but from the outside it looks the same. It does not crash. It answers fluently. Let's jump into this. The sub agent that half finished does not raise. It returns normal looking text with the same type as success. I talked about one version of this in one of my talks. We pointed an agent at [unclear]. Here's an illustration I used there with three different paths which gave the same answer. The first one, it pulled a telemetry and compared with a non-benign set. It actually did the work. The second one, it matched against a title it has seen before and gave the response.
第三个警报,它什么也没做。[这句话其余部分不清楚。]这三种情况都被归类为良性,置信度也相同,下游没有任何东西能区分它们。编排器能读取结论,却无法读取得出结论背后付出了多少工作。现在,调用没有收到回复。编排器发出了任务,超时也已触发。从这里看,三种情况完全一样:子代理仍在工作;它崩溃了,回复也丢失了;这是硬性限制,而不是工具方面的缺陷。1985 年的 FLP 论文表明,在一个哪怕只有一个进程发生故障的异步系统中,协议也可能无法完成。Chandra 和 Toueg 在 1996 年用可能出错的故障检测器给出了回应。它们只能怀疑,无法确定。我在自己的开源项目 MCP Pacemaker supervised bridge 中,就遇到了这两个方向的问题。The third alert, it didn't do anything. [The rest of this sentence is unclear.] All three are categorized as benign with the same level of confidence and nothing down stream 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 the timeout fired. From here, three worlds look the same. The sub agent is still working. It crashed and the reply was lost. It's a hard limit, not a tooling gap. The FLP paper from 1985 showed that in an asynchronous system with even one faulty process, agreement can fail to finish. Chandra and Toueg answered in 1996 with failure detectors that can make mistakes. They suspect, they do not know. I hit both directions in my own open source project MCP Pacemaker supervised bridge.
一个首次运行时会自行下载的服务器,触发了 30 秒的调用超时,看起来像是坏了。其实它只是慢,并没有挂掉。我们通过为 initialize 设置专属超时解决了这个问题。 现在说另一种情况:服务器在调用过程中崩溃了。随后调用超时,而超时错误覆盖了能说明崩溃原因的退出代码。我们通过只在服务器仍在运行时才记录超时解决了这个问题。 所以,超时只是一种怀疑。把它记录为未知,同时保留真正的原因。 现在,让失败成为一种值。来看这个例子:子代理写下了状态、它做了什么、没做什么、证据以及任何副作用。Marshall 在这里是一个普通答案。协议已经为此预留了位置。在 A2A 中,任务可以以已完成、失败、已取消或已拒绝结束,也可以暂停并请求输入。在 MCP 中,工具结果可以表明 `isError: true`。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 initialize its own timeout. Now the other way, the server crashed during a call. The call then timed out and the timeout overrode the exit code that explained the crash. We fixed it by recording the time out 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. A sub agent written the status, what it did, what it did not do, the evidence and any side effects. Marshall is a normal answer here. The protocols already have a slot for this. In A task can end as completed, failed, canceled or rejected or stop and ask for input. In MCP a tool result can say is error true.
脏读与一致性保证Dirty reads and consistency guarantees
但子代理仍然可以说已完成,而它的文本却说的是别的事情。现在,只读取文本的循环就能看出区别。这又是另一种区分。检查某个条件并得到“否”,与根本无法检查,是两件不同的事。我自己关于评估状态的草稿就谈到了这一点。把两者合并,你就会改变哪些内容、哪些人获得报酬,以及之后审计报告会写些什么。接下来是脏读。我们来看一个我在一次演讲中编造的例子。一个子代理摧毁了它,写入共享上下文说错误率下降了 80%。它并没有测量这一点,而是推断出来的。现在,另外两个子代理从同一个共享上下文中读取信息。第二个子代理写下了这个,然后又选用了同一句话。第三个代理写下了这个,并把它当作继续执行的理由。编排器把这三者全都合并起来。But a sub agent can still say completed while its text says something else. And a loop that only reads the text now 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 draft on evaluation states talks about this. Collapse the two and you change what gets and who gets paid and what the audit says later. Next, dirty reads. Let's take this made up example from one of my talk. A sub agent destroys it writes into a shared context saying that error rate fell by 80 %. It did not measure that, it inferred it. Now two other sub agents read from the same shared context. The second sub agent writes the then picks the same sentence up. The third agent writes the and uses it as a reason to proceed. The orchestrator merges all the all these three.
三个产物达成了一致。其实,这只是同一条未经证实的句子被读了三遍。1995 年对 SQL 隔离级别的批评将脏读定义为:在写入者提交或回滚之前读取某个值。在共享上下文中,猜测一经写入就能被读取,没有任何标记表明它尚未核实。常见的解决办法是询问三个子代理,并以多数结果为准。多数法确实有效,但有一个特定原因。根据 1979 年的加权投票方案,读仲裁数与写仲裁数之和必须大于总数。因此,每次读取都会与最近一次写入的仲裁集重叠。这种重叠提供了保证。但对于子代理来说,三个读取同一共享上下文的子代理并不能提供这种保证。它们不是彼此独立的副本,而是读取同一个猜测。它们的共识,只不过是把同一来源算了三次。我们来选一种一致性模型。Three artifacts agree. It is once unsupported sentence 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. The shared context a guess is readable the moment it is written nothing marks it as unchecked. The regular fix to is to ask three sub agents and get a quorum. Quorums do work for a specific reason. In waited voting from 1979 the read quorum plus write quorum is greater than total. So every read overlaps the latest write. The overlap is a guarantee. In sub agent's case the three sub agents that read the same shared 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 range of models for this. Linearizable every operation appears to happen at one point in real time order. Sequential one total order that respects each process own order. Causal operations that are causally related appear in the same order everywhere. Session guarantees they are promises to one client like read your writes and monotonic reads. Eventual if no new updates are made reads eventually return the last value. A shared context gives you none of these. There's no stated 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 clients stick to one place. For sub agents that place is orchestrated. So, here's the consistency model I use for sub-agents. I call it safe handoff.
SAFE 交接与溯源SAFE handoffs and provenance
S 代表源数据流。工作人员传递的每条事实都带有其截至特定时间和修订版本的来源版本。而决策只读取最新的源事实。A 代表效果最多发生一次。每次写入都有唯一标识,并且针对该确切操作获得一次用户批准。结果会被读回,而不会重放。F 代表扇出预算。每个下游对象都有一个门控机制和一个有上限的权重。而拒绝也计作失败。E 代表明确的结果。每次交接都会以一个明确命名的状态结束。而超时意味着状态未知,并保留其成本。这就是我为自己的子代理采用的一致性模型。它不是通用模型,而是基于我自己的公开工作。其中一部分体现在我的 MCP Pacemaker bridge 中,另一些则基于我的其他演讲和我自己撰写的互联网草案。现在我们来看看每个字母背后的含义。S:源数据流。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 once effects. Every write has identity and a single user approval for that exact action. An outcome is read back never replayed. F 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 the 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 MCP Pacemaker bridge and some are based on my other talks and my own internet draft. Now let's see what's behind each letter. S source feeds.
这是解决脏读问题的办法:一个工作线程的猜测变成另一个工作线程的事实。有效的做法是把每个事实都视为一条记录,而不是一句话。Lamport 在 1978 年的论文中定义了一个事件何时发生在另一个事件之前。事实的溯源信息就是这条记录:它读取自哪里,以及何时读取。来看这个虚构的例子。这条记录列出了声明及其修订版本、来源及其版本、作用范围,以及三个不同的时间:数据何时是最新的、我们何时读取它,以及何时使用它。在使用事实时检查其新鲜度。在这个示例中,数据截至 9:05。我们在 9:06 读取,在 9:07 作出决定。在这种情况下,我们选择了 5 分钟的限制。因此,9:07 作出的数据决策没问题。现在,第二个决策在 9:15 到来。由于我们的新鲜度限制是 5 分钟,这仍然是一条记录。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 facts 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 with 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 5 minute limit. So the data decision at 9 07 it's fine. Now at 9 15 the second decision came in. Because our freshness limit is 5 this is still record.
至多一次的效果与过期的审批At-most-once effects and stale approvals
我们拒绝它,并认为下一步决策需要再次读取。这就是区分观察与推断的方式。观察有来源和读取时间,推断则没有。至多一次效果涉及重试。这是我在关于 MCP Pacemaker bridge 的文章中举的例子。编排器委派一项任务。子代理调用一个会执行实际写入操作的工具,例如创建 PR。回复丢失了。编排器只知道一件事:结果未知。于是它重试整个任务。写入操作再次发生了。这是一个经典问题。1984 年的一篇 RPC 论文指出,如果调用返回,就说明该过程恰好运行了一次。如果出现异常,那么它运行过一次,也可能一次都没运行。你无法得知是哪种情况。因此,你选择至多一次的交付语义。不重试,并接受操作可能丢失这一事实。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 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 outcomes are unknown. So it retries the whole task. The write happens again. This is a classic problem. In a 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 it may be lost.
至少一次重试,重复执行是可能的。恰好一次。它至少发生过一次,而这是一种去重方式。也许可以通过使用 MCP 来实现;幂等提示只是一个提示,默认值为 false。如果你需要它,就得自己构建。下面是我在桥接器中的一个小型设计,说明我是如何处理的。客户端重启后重新连接时,桥接器会将该客户端的记录替换为针对一台全新服务器初始化的记录。这是安全的。这只是一次握手,不会恢复工具状态。它绝不会替换的是结果未确定的工具调用。共享服务器被回收时,桥接器会将其排空;截至截止时间仍未收到响应的调用会失败,并标记为可能已经执行。这种状态如实反映了情况。它会告诉调用方去检查。对我们有帮助的是,为每个副作用赋予一个标识。审批会绑定到具体的操作。At least once retry and the duplicates are possible. Exactly once. It happened at least once and this is a way we can deduplicate. Maybe by using an In MCP, idempotent hint is only a hint and it defaults to false. If you need it, you build it. Here's a small design from my bridge on how I handle it. When a client comes back after a restart, the bridge replace the client's record initialized against a fresh server. That's safe. It's just a handshake and it does not restore tool state. What it never replace 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 us giving every side effect an identity. Approval binds the exact action.
它只使用一次。调用后,用该身份读回。已提交不代表已确认。确认意味着你观察到了效果。A 的最后一部分,会在工作交接并恢复时显现出来。租约是一种带超时的锁。Martin Kleppmann 关于分布式锁的文章展示了这个问题:客户端持锁时暂停了,租约过期,其他人接管了。然后第一个客户端醒来后,仍然照常写入。他提出的解决办法是 fencing token(栅栏令牌):每次授予锁时,令牌的数值都会递增。存储系统会记住它见过的最高令牌,并拒绝任何使用更旧令牌的写入。子代理经常暂停并恢复。正如我在另一场演讲中所说,要恢复上下文,而不是副作用。因此,把一次批准当作栅栏令牌:一个操作,只能使用一次。在关口处进行检查,而不是把它记在提示词或对话里。It's only used once. After the call, read back by that identity. Submitted is not confirmed. Confirmed means you observe the effect. The last part of A, it shows up when work passes and resumes. A lease is a lock with a timeout. Martin Kleppmann's post about distributed locking shows this problem. A client pauses while holding it. The lease expires. Someone else takes over. In the first client wakes up and writes anyway. The fix he proposes 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 older one. Sub agents pause and resume all the time. 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.
扇出预算与容量Fanout budgets and capacity
我的桥接程序修复了同一类错误。过期的退出操作或已删除的恢复操作,不再会移除或恢复一个替代会话。F 扇出预算针对的是无界扇出,也就是流量控制,或缺乏流量控制。我自己的 MCP 桥接程序在还没有为冷启动设置上限时,就遇到了这个问题。许多会话通过 NPX 同时启动服务。它们共用一个包缓存。结果每个会话都因 npm 的锁冲突错误而失败。任何单个请求都没有问题,问题就出在并发本身。而当下游确实施加反压时,它可能只会以纯文本的形式传来。这是 MCP 规范中工具执行错误的示例:用一句话说明速率限制。模型读到了一句话。编排器代码可能根本不会查看。下一个工作进程就启动了一个 EP。因此,我在自己的桥接程序中引入了配额预算。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 flow control or the lack of it. I hit 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 failure was the concurrency itself. And when a downstream does push back, it can arrive as plain text. This is MCP specs own example of a tool execution error. A rate limit as one sentence. The model reads a sentence. The orchestrator code may never look. The next worker starts an EP. So, I introduced a quota budget in my bridge.
使用包管理器的冷启动默认每次有两个通过闸门。其他所有启动都要等待。等待时间最多为 15 秒。超过这个时间,启动就会绕过闸门继续进行。我还记录了原因:缓存损坏是一种风险,而客户端请求挂起则是必然会发生的事。这是为了可用性而有意做出的选择,并且已经记录下来。 我还为会话数设置了上限。达到上限时,一个新会话最多等待 10 秒,然后会被拒绝。现在,这种拒绝会计入失败深度。还有一个错误:必须在同步启动之前预留容量,而不是之后。否则,排队等待的启动会导致超额占用上限。这是一个先检查、后执行的竞态条件。 对于子代理,要为编排器提供每个下游的数量、一个有界权重,以及一个它能够感知的拒绝信号。 现在,E,明确的结果。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 at 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 a new session waits up to 10 seconds and then it's refused. That refusal now counts as a failure depth. Another bug. 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 weight, and a refusal it can see. Now, E, the explicit outcomes.
明确的结果与限制Explicit outcomes and limits
每次交接都会以一个明确命名的状态结束,比如“过时”或“未知”,而不只是给出一段文本。最后一点是:由谁来决定这个状态。要把智能体的输出视为不可信输入,就像对待来自互联网的请求正文一样。编排器负责在代码中执行检查。结果是否符合架构?证据是否齐全?信息是否足够新?重新计算后,数字是否仍然成立?如果检查未通过,该步骤就会返回拒绝结果并说明原因,而不是把文本传下去,再在下面附上一段警告。如果同一个模型既能跳过检查,又能宣称检查已通过,那你得到的只是一个请求,而不是一道边界。下面是另一次演讲中的一个虚构例子。一个子智能体说错误率下降了。之前,1,000 个请求中有 10 个错误。之后,600 个请求中有 6 个错误。错误数从 10 降到了 6,于是它声称错误率下降了。Every handoff ends in a named state, like stale or unknown, not just text. The last piece is who decided that state. Treats an 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 your 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's a made-up example from another talk. A sub agent says the error rate fell. Before, it was 10 errors in 1,000 requests. After, it was 6 errors in 600 requests. It went from 10 to 6, and it claimed that our rate fell.
但我们计算这个比率时,两边都是 1%。我们重新计算了一遍,随后这项请求被拒绝了。有依据的回答没问题。明确地转交给人工处理也没问题。但自信地猜测就不行了。 所以,接下来谈谈局限性。因为只有知道应该在哪里停下来,一致性模型才有用。下面说说安全模型不会做什么:它不会让事实变成真的。来源事实是可以核查的,但不代表它就是正确的。它不能保证恰好一次送达。回复一旦丢失,在你读回它之前,结果就仍然是未知的。它也不会回滚任何操作。要撤销一个只完成了部分内容的任务,需要由你设计一个补偿步骤。比如这篇 1987 年的论文[字幕中标题不清楚]。最后,不同工作进程之间没有全局顺序,只有各条事实各自的因果顺序。而这也是有代价的。CAP 定理指出,当网络发生分区时,你必须在可用性和一致性之间做出取舍。But when we computed the rate, it's both 1 percent. 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 stop. 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-once delivery. A lost reply stays unknown until you read it back. It does not roll anything back. Undoing a partial task is a compensation step you design. Like this 1987 paper [title unclear in the captions]. And finally, there's no global order across workers. Only causal order per fact. And it has a price. CAP theorem says that when the network splits, you trade off availability against consistency.
我的桥接层有意在冷启动时选择可用性。对于写入,safe 选择一致性而非可用性。它宁可拒绝,也不猜测。PACELC 还指出,即使没有故障,你也要在延迟与一致性之间取舍。每次检查数据新鲜度,都意味着另一次读取。而每次拒绝都需要有序处理。那么,它不适用于什么情况?如果子代理只负责起草文本,由人阅读后才会采取任何行动,那么上述大部分机制都只是额外负担。它还假设只有一个编排器。如果你有多个编排器,这套方法就不适用了。没有单一固定落点的对等代理,需要采用别的方案。这就是我用于那些会接触真实生产系统的自有代理的一致性模型。它并非放之四海而皆准。最后,总结一下,以下是三个关键要点。把每次交接给子代理都当作一次网络调用。My bridge chose 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 order. So, where it does not fit? If a sub agent only drafts text that a person reads before anything happens, most of this is overhead. 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.
它可能会在中途失败,可能很慢,也可能返回两次。要返回状态,而不只是文本。如果结果无法表示“部分完成”“已过时”或“未知”,编排器就会把它当作已完成。并且要从我们安全的 consistency model 开始,在代码中强制执行它。保留适用的部分,修改不适用的部分。我们已经知道如何构建分布式系统,只需要意识到自己正在构建一个分布式系统。以上就是这场演讲的一些资料来源。左边是我自己的工作,包括我的开源项目、文章和草稿,以及演讲。右边是各项规范、标准,以及支撑每个概念的大量论文。谢谢。It can fail halfway. It can be slow and it can come back twice. Return a 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 and drafts and my talks. On right side specs and standards and bunch of papers behind each concept. Thank you.