空间孤岛与时间失忆:透视智能体的认知双重缺陷
在软件工程的实际场景中,引入 智能体(Agent: 能够自主感知并执行任务的 AI 系统)就如同召唤了一个被施加了魔法限制的编程天才。以行业传奇人物 John Carmack 为隐喻:虽然他拥有无与伦比的编程天赋,但如果每次对话都必须从零开始,且他只能接触到整个代码库的千分之一,那么协作过程将会变得极其低效。开发者不得不一遍又一遍地向其解释相同的上下文。当前大多数 AI 智能体正是处于这种既是“天才”又存在“认知缺陷”的尴尬状态。
这种低效在跨越多个代码库的系统级变更中尤为明显。假设一个系统包含 UI、模块一、模块二和平台四个代码库。当需要对 UI 组件进行一项看似简单的改动并将其传播到整个系统时,开发者需要经历极其繁琐的解释链条:
- 表达变更意图:首次向智能体解释并修改 UI 代码库;
- 发布与消费:进入模块一,向另一个或同一个智能体重新解释 UI 库发生的变更以完成包的升级;
- 修复兼容性冲突:如果发现新发布的 UI 库与模块一不兼容,必须返回 UI 库,向智能体重新解释最初的变更及当前遇到的问题;
- 迭代发布:修复后再次发布,并向模块一中的智能体重新解释新的变更;
- 横向传播:在模块二中重复上述解释与升级过程;
- 系统集成:最后在平台代码库中解释所有组件如何协同并完成最终整合;
- 回归修复:如果一周后生产环境出现 Bug,启动 UI 库的智能体时,还需再次向其解释一周前的变更背景及当下的生产问题。
在这一系列交互中,仅仅为了推进一个实质性的变更,就产生了多达七次重复解释。这种现象暴露了当前智能体架构的两个根本性制约因素:
- 空间维度:单仓限制(Repo-bound: 限制智能体感知和修改的单仓库文件系统边界)。智能体无法俯瞰包含数百或数千个仓库的完整系统,导致其在进行代码库对齐时不得不极度依赖人类进行前置调研。更糟糕的是,由于无法同时在下游消费端进行联动修改与验证,很容易导致 CI/CD 流程在发布后才被动报错,造成开发时间与 API 消耗(Tokens 燃烧)的双重浪费。
- 时间维度:情境失忆(Amnesia: 智能体缺乏在会话间留存历史上下文的缺陷)。由于智能体缺乏 情境记忆(Episodic Memory: 记录历史交互、决策链路及执行轨迹的时间维度记忆系统),每次会话都是一张白纸,迫使人类开发者不得不充当其“外挂硬盘”来维系上下文的连贯性。
在真实的软件组织中,代码的演进是由底部复杂的拓扑依赖图谱(Dependency Graph: 描述多个代码库之间调用与消费关系的拓扑网状模型)与顶部密集的智能体开发会话交织而成的网络。然而,智能体目前只能管窥其中的一个会话和极小碎片,这迫使开发者必须依靠个人的局部认知来填补智能体留下的时空空白。
Original English Source
Imagine you find a magic lamp in an antique store. You rub it, a genie appears, and asks how it can help. You burn it in the outline, so you say, "I need the best engineer to help with an impossible project at work." And the genie grants your wish. For me, the best engineer is probably John Carmack from his eight days, so you get Carmack. But the genie had a sense of humor and imposes restrictions, maybe for safety. Carmack can only see one small part of your code base, maybe 1/1000 of it. And he remembers nothing he did before. Every conversation starts fresh. So, that would be maddening, right? You would know there is a standard way to do stuff, and Carmack wouldn't. You would have to explain the same thing over and over and over again. You would have a genius on one side and something deeply deficient on the other. And that's what agents are. Let me walk you through an example of how many times we re-explain things in a simple interaction. We have four repos, UI, module one, module two, and platform. I want to change the UI and propagate the change through the system. Okay? First, we change the UI library. Say we, I don't know, change a button or whatever. That's the first explanation, unavoidable. We have to express the intent, okay? Then we publish it. We go to module one, and we have to re-explain what just has happened in the UI library, so it can consume the package here. Note that that's often a different person, right? Every box in this diagram can be done by a different person. And then we discover that the published UI library doesn't work with module one. So, we go back to UI, and we have to re-explain the original change and the issue. Right? Because it's a new agent, it doesn't know the original change. It obviously doesn't know about the issue. Let's say we fix it, right? And publish it again. We go and again we explain the new change in the context of module one, same module. I mean, do the same for module two again. And then we go to the platform repo and we explain everything fits together and we implement the change there. Let's imagine a week after release, a bug appears in the UI component and we have to fix it. So we start an agent in the UI repo. And we have to explain again the original change from a week ago and this production issue we're seeing. So we have seven explanations for what essentially is one change. And also it may not be one person making all these seven explanations, but they still occurred, right? So that's very very typical with agents. So how do we solve it? Well, there are many problems in here that contribute to this experience, but they roughly fall into two categories. The first one is that an agent essentially is repo bound. Agent sees and changes generally one repo at a time. It never sees the whole system, which can be hundreds or thousands of repos. So that's kind of the space component of the problem. Second is amnesia. Agent forget the work. Every session start with a blank slate. The human becomes the memory in this case. That's the time component of the problem. Look at the two closer. Take the repo boundary first. Without a model how repos fit together, the agent leans on the human to do the research. It can't align the code with the rest of the system. It couldn't align the UI change with module one. The human didn't explain it, so a bad version shipped. It can't reliably reference best practices and standards either because those often live in other repos. Worse than even worse, the agent writes to one repo at a time, it means it can't validate changes downstream. Modules one CI should have failed on the UI change, but it didn't. The agent can't update consumers at the same time even though, you know, while making the UI change, it has perfect information to do so. It knows exactly what it's doing. So, the user has to re-explain stuff imperfectly to each consumer. Changing something across 20 repos means re-explaining things 20 times. A lot of developer time spent, but also a lot of tokens burned. The second category is that the agent forgets. The agent has no episodic memory. Every session is a blank slate. And the human, in this case, becomes the memory. Here's what the graph of your work actually looks like. At the bottom, there is a repository graph. The artifacts your organization produces plus every open source repo you depend on. Maybe a thousand repos you own and tens of thousands of open source repos. At the top, there are all agentic sessions that create and modify that code. Sessions relate to each other, repos relate to each other. So, this graph is a faithful picture of the work in your organization. It describes what's there at the bottom and how it came to be at the top. That's what you want your agent to see. Here's what it actually sees. There is one session, one small fraction of the code base, no memory, okay? Because it sees so little, it leans on the one who understands the system, the developer. Every developer has a part of that graph, right? In their hand, at least in the domain they know. Agent generically speaking doesn't. If this doesn't sound crazy, right? Imagine an agent that could see one file at a time maximum and can only look five messages back. Sort of constraint again both in space, what can see, and time, how far in the past it could see. You would say that's impossible to work in. What we have now is similar to that crazy picture.
Polygraph:打破仓库边界的超维感知元协议
为了突破上述限制,研发团队开发了一种与底层模型无关的元装载器(Meta-Harness: 包裹并增强底层智能体能力的抽象框架系统),并命名为 Polygraph。其核心设计思想在于:如果一个开发者拥有访问企业成百上千个代码库(包括内部私有库和外部开源依赖)的权限,系统就可以在后台提取这些代码库的元数据,构建出一个无缝粘合的统一依赖图谱。
通过将这种全局的拓扑元数据持续输入给元装载器,Polygraph 为智能体创造了一种“单一庞大代码库”的幻觉,使其能够跨越物理仓库的阻隔,在任意位置执行无障碍的读写操作。例如,在一个包含 300 个自建仓库及数千个开源依赖的庞大网络中,Polygraph 能够精确计算每个项目生产和消费了哪些包、暴露与调用了哪些 API,并自动在后台将它们编织在一起。
这种空间局限性的打破,进一步赋能了跨仓库变更的自动化流转:
- 单向量集成验证:Polygraph 将跨越多个仓库的持续集成(CI)视为一个统一的向量进行管理。
- 智能冲突闭环:当智能体在多仓会话中同时修改 UI 组件与下游模块时,如果下游 CI 验证失败,Polygraph 会自动研判并定位故障源——是由于模块一需要对应的补丁,还是 UI 组件本身破坏了向后兼容性。一旦确认是 UI 组件的设计缺陷,它会自动指导智能体向所有相关组件推送全局修复方案。这种机制成功将复杂的跨仓重构简化为单一代码库的开发体验。
Original English Source
And the more complex the organization is, the more apparent it becomes. I'll show you how we solved it. Other organizations I talked to have similar solutions, so uh look at the problem and the solution conceptually, not the specific tool, although the tool is pretty cool. We built an agent agnostic meta harness called Polygraph. Okay, let me show you what it does and how it fixes the issues we just discussed. The first idea that we uh arrived at is that if a GitHub user, any user, has access to thousands of repos, some of them they own, many of them are open source, we can analyze them and extract a lot of metadata out of them to build unified dependency graph. Uh no line of code changes in those repos, that all happens kind of on a side, right? And then we can get this metadata and feed it to the meta harness and create an illusion of one big code base the agent can read and write anywhere. This is my personal graph. I want to have about 300 repos I own, right? And thousands of open source repos my projects depend on. Polygraph computes what each one produces, each repo, each project in each repo, what each project in each repo consumes package-wise, what API they produce and consume, and lots of other stuff, right? And this stitches this together uh into this like one big body of code that your agent can work with. So, let's see what it does, right? The first thing it it does is uh it lets you start a session to bring the relevant repositories in, right? So, what it needs to do, it needs to uh set up the source code, install dependencies, set up an agent for each repo, wire them up so they can work together, and provide a clean, beautiful GUI to make non-trivial changes without getting lost. I will show you how it all works in a second, right? So, that's kind of pull information in. Pulling information in is only one part of the story, all right? Honestly, it's an easy part. Making changes is harder. If you have 10 repos in one session, it means you can have 10 pull requests, all right? You need to run CI. You need to coordinate all of it, right? You need to do all this stuff, all right? What if one of them fails, right? Polygraph treats all the CI as one vector. Like if you look at the earlier example, uh when we run CI for UI module one and module two, if module one fails within a polygraph session, it will figure out who fixes it, whether module one needed a patch or the UI component itself is broken and incompatible with module one, at which point everyone will need a patch, right? Polygraph lets you treat complex multi-repo change as if it was a single repo change. The same machinery, by the way, fixes episodic memory. Because we capture your work, no matter how many repos are involved, we we your intent, the repository is involved, PRs. We also capture all agent traces. Because we capture all of this stuff, we can relate it. So, now we can say your work in one repo connects to another work in another repo. Right? And all of that lets us restore any session, any piece of work on any machine, or reference it from anywhere. And I will show you again how it works in a second. What you get is an agent with eidetic or photographic memory of your entire organization. It understands how repos are written, how they relate, how they put together, and remembers every session from every repo by basically every developer. Right? And that creates a completely different development experience.
群体智能:会话跨机漫游与多仓库演进实操
在实际工程操作中,Polygraph 的元数据架构将智能体与开发者的交互体验重塑为无缝的协作网络。启动一个多仓会话非常直白:开发者只需在 CLI 中键入会话创建命令,从列表中选择后端与前端代码库并命名会话,即可根据本地已安装的智能体环境(例如 Claude 或 Cortex)进行挂载。在此过程中,元装载器在后台透明地检出正确分支、编排多仓智能体,并在统一的图形界面中展示其生成的变更方案与交互动画。
通过将智能体的运行日志、交互细节以及 PR 关联性完整记录在元数据网络中,Polygraph 成功克服了“时间上的失忆”:
- 记忆跨机漫游:由于所有决策链都被捕获为结构化的交互轨迹,开发者可以将一个未完成的会话无缝流转给团队成员。接收者只需在自己的终端执行会话恢复命令,系统就会像《星际迷航》中的传送器一样,在对方机器上零成本重建完全一致的依赖环境、代码分支(SHA 状态)以及智能体历史记忆。
- 异构智能体接力:原作者即使使用的是 Claude 开展工作,接收方也完全可以无缝切换为 Cortex 智能体继续编写代码,因为它们共享了底层被捕获的逻辑轨迹和演进状态。
- 极简的代码评审:在日常的代码评审中,资深开发人员无需再耗费时间向提交者口头询问意图,只需将该会话直接恢复到本地,即可拉取包含所有决策链路的完整上下文。评审者能直接与本地智能体对话,追溯当时的架构权衡。
此外,依赖图谱也使得全局智能化检索与规范复制变得轻而易举。开发者可以直接向智能体下达模糊指令,例如“在 PR 归档中检索与向量索引相关的历史会话,并以此为规范,对当前涉及该库的所有项目进行升级”。智能体会自动在组织的全局图谱中检索高价值的历史轨迹,模仿其他优秀工程师编写的既有代码模式,从而实现跨仓库代码风格的强一致性。甚至在工作进行到一半时,如果发现需要参考外部开源框架,开发者可以直接通过指令将 Vitest 等外部开源仓库动态挂载到当前 NX 仓库的会话中,使智能体得以长驱直入地探索底层源码,精准定位并修复难以察觉的兼容性故障。
这种以元装载器为纽带的架构设计,实质上在组织内部构建了一个共享的蜂群思维(Hive Mind)。每一个开发人员和每一次智能体会话都在不断为这个庞大的全局记忆网络贡献语料和上下文,使未来的每一次开发迭代都能站在历史全局认知的高度上。
Original English Source
Let me show you. First, let's look at how we create a session, something simple. You run a command, and you pick some repositories from a list. Here's a tiny GitHub work with only three repos because it's a demo. I pick back end and a front end. Let's say I need to make a change that, you know, changes the API and has to update both the API and how stuff is being displayed. I need to give my session a name. I need to pick an agent from the ones I have installed. I picked Claude. But any installed agent works same way. Remember, Polygraph isn't an agent. It's a meta harness around an agent that makes them uh more capable. And in a second, uh the agent boots. And here I could interact with it as if I was in a single repo, even though multiple repos are involved, right? I could give it instructions. It's going to uh plan out the change. There is some cool animations in the UI as well. Eventually, [snorts] it figures out how the two repos relate and what the change is. I can ask it to implement the change. My interaction with this uh exactly same as if it I was working in a single repo. The fact that there are multiple repos involved is not really important, right? Uh the only uh part where it becomes important that I have multiple pull requests, right? Uh but I also get a polygraph session where those pull requests are. All right? If I look at the session, I will see I have a description uh that uh description of the session describes the work conceptually uh kind of bypassing the repo boundary, saying we have to change stuff in this repo, change stuff in that repo. It gives me a good view of which repos are involved, pull requests involved, CI in those repos, everything I need to know. A lot of this stuff is basically what I would have in a single repo but many, right? And I also have all the agent logs captured as well, which is important for resuming, which I'm going to show you in a second. Now it gets interesting. I already saved one re-explanation. I didn't re-explain the back end change uh in the in the front end repo, right? I explained the change once and I got it implemented in both repos and it's all in agreement. Now let's resume a session. Say I want a coworker to finish the back end change. Perhaps they own the back end repo. I send them the session. They resume it on their machine, all right? So this I'm sending them the session. They could run the command. Uh different machine, different everything. They use different terminal, all right? Uh they would reconstruct it on their machine. They don't have the session, right? They have never worked on it. They they can pick an agent. Uh the agent they pick could be a different agent, right? I used Cloud in the original session, but let's say they're using a different one, Cortex. The same setup happens to their machine, same repos, same SHAs, everything set up correctly. Agent starts in a triple like in mine, all right? They're all connected again, so they work together. They're all primed with a trace captured from my machine, so the back end of the repo agent on their machine has the same shine and the same history. The front end repo situation is the same. It's It's checked out at the same at the correct shard, has the agent running with the correct history. So, my agent was Claude. They coded, but they share memory. And they could actually actually make changes in here as shown in a small video. Um but I think what the memory sharing part is key, all right? Uh I can work, they can work, and we can share our memories as though we used to different agents in different machine. The full state of my session can I get materialized on their machine. It kind of less memory and more about the state, right? The state of the world that's attached to the session, uh you know, is what enables them to continue my session even though they had didn't do anything with it originally. It's close to the transporter in Star Trek. Like a whole copy of my session is all of its state materialized on their machine so they can continue. And that's how I often work when there is a pull request for me to review and I have questions, I usually don't ask the person. I resume their session on my machine, I get the exact state, fully functional, zero setup, and then I just talk to my agent about the decisions we made, right? [snorts] Because all these decisions are in the traces captured. So, my agent knows exactly what the other person talked to their agent. Right? So, a side note, this is also useful when I want to switch from say Claude to Codex mid-session when something goes down, okay? Okay. Take the earlier case I talked about where a bug landed in production. Here, I'm going to reference the session and say it's basically broken. Uh and you know, can you figure out what's wrong and fix it? The agent will look it up, will download what it needs. If description is like high-level information is enough, that's great. If not, it's going to pull relevant repos, relevant shards, agent logs, right? It's going to get all this information from the original session to reconstruct that state such that it can do the necessary fixes as shown here. He actually provided the fix, right? I only had to say, "This happened. There is a bug." That's it. No extra information was required for me to provide. Okay. So far, we have manually selected repos and sessions, but we don't have to, all right? Instead of selecting repos by hand, I can also tell the agent what I want. Remember that graph has all this intelligence, right, about how repos relate. I could tell my agent, "Find every repo that depends on a particular version of a library and update it." Right? [snorts] I mean, it knows, right? I I didn't have to select them. It knows a lot of metadata about what's going on. I can also ask loose questions. Things like, you know, uh "What if I I want to write a blog post, right, or an article?" I could describe it and it will figure out which repo is the most relevant based on relationships between repos and what's in them. Another example. Let's say I want to add vector index into the PR collection. And I want to know if anyone at any point did something relevant in any repo that I can draw from. So, in this case, if I do it, I'll see that it will find several sessions that appear to be relevant. [snorts] And I can load one of them or both of them, right? Um it's useful for many reasons. Uh let's just one small example. It helps with best practices and consistency. Instead of doing stuff from scratch, where, you know, every single implementation is bespoke, I can make it replicate the approach used in the session by an engineer I respect. Now, our code cross repos is consistent. That's a big deal. There is a lot more to it, of course. If you are in a repo, I can ask, you know, for sessions, it will prioritize sessions that's relevant to the repo, and vice versa. If I'm asking for repos, it will look at my session and see what similar sessions tend to bring in, right? There's a lot of interesting intelligence that make it a lot more useful that appear at first glance, okay? Lastly, uh everything so far I I used uh everything I shown uh used the Polygraph CLI, the current meta harness CLI, to start it, and then you can start Cloat or Cortex or whatever from within it. But, you don't have to use it this way. So, in this case, I'm already in a Cloat session, but it works with anything. And I could just say, "Hey, you know, I actually think a separate repo would be useful. Like, maybe I'm working on a Vitest plugin in this NX repo, and I could say, 'Can you add the Vitest uh repository to this session so I know what's going on?'" In this case, we'll engage Polygraph, and it'll set it up, you know, configure everything, and we'll bring the Vitest library, which is a the Vitest repo, the open-source repo, to my session. So, now uh my agent can, you know, explore it. It could, you know, uh figure out how it works, and maybe resolve an issue I have in my repo. I much prefer this to say context seven, because if I have the real code, the agent can go really deep. So, the deep problems are discovered all this way. All right. So, agents are constrained in space and time. They only see a small fraction of the code base, as they don't know the past, okay? Uh and both limits could be lifted. Polygraph uh gives agents access to the entire code your organization can reach, the one you own and open source. So, it's no longer constrained in space. Any agent can bring all of it. Right? And it gives you agent a perfect memory of what happened. Every session, every decision made is within reach. Because it crosses developer boundaries, not per developer, the agent can have more context than any single developer. Like a thousand engineers have an organization, create all these sessions, they all accessible to to each of them. Almost like sort of the Borg. Every agent can run by every developer contributes to kind of one big this hive mind, right? So, uh if it's interesting, my name is Victor. You can follow me on Twitter. If you want to check it out, go to try.poligraph.com and see if it works for you. Thank you.