Software is a training ground for agents
Repositories are not miniature worlds. They are useful because work produces concrete, inspectable consequences that an agent and its reviewers can learn from.
At 10:17 on a Tuesday morning, an engineer opens an issue that looks almost insultingly small: a settings page saves a value, reloads, and displays the old value. The first guess is a stale cache. The second is a form library. The actual cause turns out to be an old API client, generated from a schema that no longer names the field.
That little sequence is useful because every step has consequences. A file changed. A request returned a payload. A browser showed a state. A test passed for the wrong reason. The engineer can revise a hypothesis instead of merely producing a more convincing explanation. This is the quality that makes software such a compelling environment for AI systems.
It is tempting to call a repository a "world model" for agents. The phrase reaches for something real, but it can also overstate the case. A production system is not contained in its source tree. It includes people with partial information, customers who use features in unexpected ways, legal and commercial constraints, incident response, and choices that have never been written down. A test suite cannot represent all of that.
Still, software provides an unusually good place to study action, feedback, and recovery. A dependency either resolves or it does not. A service starts, returns an error, or exceeds a latency budget. A screenshot exposes a broken layout. A migration applies, fails, or leaves a database in a state that needs careful repair. Those are not simulations of consequence. They are consequences, bounded enough to inspect.
The distinction matters. Generating plausible code is a language problem. Improving a living system is an epistemic problem. It requires an agent to make a claim about the current state, take a limited action, observe what happened, and update its next move. Good infrastructure should make that loop possible without hiding the evidence from the people responsible for the system.
A repository is not a miniature universe
The useful claim is narrower than "software is the world." A repository is a constrained environment in which state is partly explicit and actions can be checked. That makes it valuable for training, evaluation, and product design.
Some of the state is visible:
- the code and configuration on a branch;
- the package versions, generated artifacts, and environment variables used by a process;
- the commands that were run and their exit conditions;
- test output, logs, previews, and request traces;
- a diff that records what changed between two points in time.
Some of the state remains outside the repository:
- why a request matters to a customer;
- whether a surprising behavior is acceptable product behavior or an unnoticed bug;
- which maintenance cost a team is willing to accept;
- whether a temporary workaround is appropriate during an incident.
An agent should not pretend the second category has disappeared merely because it can read the first. The purpose of a work environment is to make the known facts legible and to surface the unknown facts early enough for a person to decide.
This is why an agent that confidently edits code after a quick scan is less interesting than one that can say: the change appears local, these two tests cover the primary path, the preview confirms the visible behavior, and the caching assumption has not been checked against production traffic. The second agent has done more than produce a diff. It has separated evidence from inference.
The loop that teaches something
Consider a routine maintenance task: remove a deprecated configuration option from a web service.
An effective workflow is not "search, edit, run tests, announce success." It begins by locating the option in the public schema, runtime configuration, deployment scripts, and documentation. It makes a hypothesis about which references are authoritative and which are historical. It edits the smallest safe surface. It runs the checks that can falsify that hypothesis. If a snapshot fails, it determines whether the snapshot revealed a real contract or an obsolete expectation.
The important object is not the chat transcript. It is the changing state of the work:
- Intent. What is being removed, and what must remain compatible?
- Initial evidence. Which files, tests, service paths, and deploy configurations appear relevant?
- Action. What was changed, in what environment, and with what authority?
- Observation. Which checks ran, what they showed, and which result was ambiguous?
- Decision. Why is the task ready for review, or why should it stop?
That record can be compact. It does not need to capture every token of private reasoning or every harmless shell command. It does need to preserve the facts that change the next decision. If the task is paused, another engineer should be able to see that the schema was updated, a staging deployment still references the old key, and the integration test was intentionally not run because it requires a missing credential. That is enough to continue responsibly.
Static examples teach syntax; changing systems teach judgment
Code corpora are rich training material, but they mostly expose artifacts after a decision has been made. A repository at rest can teach an agent what a migration looks like. It cannot, by itself, teach why the team rejected the first migration, which production constraint changed the plan, or how a flaky test was distinguished from a legitimate regression.
Execution adds the missing feedback. A command that fails tells the system something about its model of the environment. A browser preview may contradict a unit test. A reviewer may identify a requirement that was never encoded in an issue. These are the moments in which an agent needs to revise its plan rather than continue emitting the pattern that looked likely in text.
This does not mean that every runtime event should become training signal. Build logs are noisy. Tests can be incomplete. A green pipeline can be produced by an assertion that never exercised the relevant path. Treating all output as equal evidence encourages a different kind of overconfidence.
The infrastructure should therefore connect specific claims to the artifacts that support them. "The empty state renders correctly" is supported by a visual check and perhaps an interaction test. "The API remains backward compatible" is supported by a contract test, a schema diff, and a reasoned account of the compatibility window. "The data change is reversible" is supported by a migration plan and a tested rollback path, not by a general statement that migrations are safe.
The closer a system gets to this discipline, the more useful its execution traces become for evaluation and learning.
Evaluation should include the path, not only the patch
Many software benchmarks score the final state: did the test suite pass, did the agent produce the expected diff, did it close the issue? Those measurements are useful, but incomplete. Two agents can arrive at the same patch by very different routes. One may inspect the affected interface, run a targeted test, notice a dependency constraint, and leave a concise record. Another may make a broad edit, retry until a test turns green, and accidentally remove an edge case the benchmark does not cover.
The difference matters in a shared codebase.
For practical evaluation, we care about questions such as:
- Did the agent identify the files and contracts that actually governed the behavior?
- Did it make reversible, scoped changes before escalating to broader ones?
- Did it use the available environment to test a meaningful hypothesis?
- Did it distinguish a successful command from evidence that the task was complete?
- When it encountered uncertainty, did it preserve the question for review or bury it in a polished summary?
- Can another person recover the current state without replaying a long conversation?
These are not stylistic preferences. They describe whether an agent is safe to place in a real engineering loop.
Recovery is part of the learning signal
The most revealing moments are often failed attempts. An agent changes a configuration file, the service refuses to boot, and the original error message points to a different subsystem. A first draft of a migration passes in isolation but fails when run against a realistic data volume. A frontend fix looks correct until a narrow viewport reveals the layout assumption underneath it.
The right response is not to suppress the false start. It is to make the correction legible. What was tried? What observation invalidated it? What condition now protects against the same failure? A task that records this sequence gives a later reviewer a much better understanding of the system than a task that presents only a clean final diff.
This is one reason durable task state matters. If a process restarts halfway through a repair, it should not begin from the fiction that no work has happened. It should resume with the last verified facts, the unresolved failure, the branch state, and the authority needed for the next action. That is how an agent's experience becomes cumulative rather than disposable.
What software can teach, and what it cannot
Software is a good training ground because feedback is dense, artifacts are inspectable, and interventions can be limited. It offers a practical bridge between language models and consequential work. But it is still only one kind of environment.
The goal is not to build agents that become excellent at generating a ritual of commands. It is to build systems that can maintain a disciplined relationship with evidence: form a hypothesis, act within a boundary, observe an effect, preserve uncertainty, and hand work to the next person in a usable state.
Repositories are valuable because they make that discipline possible. They give agents something more demanding than a prompt and something more honest than a perfect benchmark: a changing system that can answer back.
This distinction has consequences for evaluation. A benchmark that checks only the final diff can reward lucky edits and miss brittle reasoning. A better evaluation can ask whether the agent used relevant evidence, preserved constraints across retries, and stopped when uncertainty remained. It can also measure recovery: whether a later agent or reviewer can understand the current state without replaying an entire chat.
What the environment should expose
Not every signal deserves equal weight. Build output is often noisy. Tests may be incomplete. A screenshot can prove a visible state while saying little about accessibility or failure handling. The system needs a way to connect a claim with the evidence that actually supports it.
That is why the infrastructure around an agent matters. Sandboxed execution, repository state, permissions, tests, previews, logs, and review checkpoints are not merely tools attached to a model. Together, they define what the model can know about its own work.
The near-term opportunity is practical rather than mystical. Build environments in which agents can form hypotheses, make bounded changes, collect evidence, and recover from interruption. Software is a good place to begin because the feedback is dense, the artifacts are inspectable, and the consequences are real enough to teach discipline.
软件是 Agent 的训练场
仓库不是微型世界,但它很有价值,因为工作会产生具体、可检查的后果,让 Agent 和 reviewer 能够从中学习。
周二上午 10:17,一位工程师打开了一个看起来小得近乎可笑的 Issue:设置页面保存了一个值,刷新之后却显示旧值。第一个猜测是缓存,第二个猜测是表单库。最后发现,真正原因是一个旧 API Client,它来自一份已经不再包含该字段的 Schema。
这个过程有价值,是因为每一步都有后果。文件发生了变化,请求返回了 Payload,浏览器显示了一个状态,测试也可能因为错误原因而通过。工程师可以据此修正假设,而不只是生成更有说服力的解释。这正是软件成为 AI 系统优秀环境的原因。
把仓库称为 Agent 的“世界模型”很诱人。这个说法确实触及了某种真实,但也可能夸大其词。生产系统不包含在源码树中。它还包括信息不完整的人、以意外方式使用功能的客户、法律和商业约束、事故响应,以及从未被写下来的选择。测试套件无法代表全部内容。
不过,软件仍然是研究行动、反馈和恢复的非凡环境。依赖要么能解析,要么不能;服务会启动、返回错误或超过延迟预算;截图会暴露布局问题;迁移会成功、失败,或留下需要谨慎修复的数据库状态。这些不是后果的模拟,而是足够可检查的真实后果。
区别很重要。生成看似合理的代码是语言问题;改善一个不断变化的系统是认识问题。它要求 Agent 对当前状态提出判断,在边界内采取行动,观察发生了什么,然后更新下一步。好的基础设施应该让这个循环发生,同时不隐藏证据。
仓库不是微型宇宙
更准确的说法不是“软件就是世界”,而是仓库提供了一个受约束的环境,其中部分状态是明确的,行动可以被检查。这使它适合训练、评估和产品设计。
有些状态是可见的:
- 分支上的代码和配置;
- 进程使用的包版本、生成产物和环境变量;
- 已运行的命令及其退出条件;
- 测试输出、日志、预览和请求 Trace;
- 记录两个时间点之间变化的 Diff。
另一些状态位于仓库之外:
- 一个请求对客户为什么重要;
- 一个意外行为是可以接受的产品行为,还是未被发现的 Bug;
- 团队愿意承担什么维护成本;
- 事故期间临时方案是否合适。
Agent 不应该因为可以读取第一类信息,就假装第二类已经消失。工作环境的作用,是让已知事实变得清楚,并尽早暴露未知事实,让人可以决定。
所以,一个能够自信地快速扫描后修改代码的 Agent,并不如一个能够说清楚证据边界的 Agent 有意思。后者可以说明:变更看起来是局部的,这两个测试覆盖主要路径,预览确认了可见行为,但缓存假设还没有在生产流量下检查。它做的不只是生成 Diff,而是区分了证据和推断。
能够学习的循环
考虑一个普通维护任务:从 Web 服务中移除已弃用的配置选项。
有效的工作流不是“搜索、编辑、运行测试、宣布成功”。它应该先在公共 Schema、运行时配置、部署脚本和文档中定位这个选项;对哪些引用是权威的、哪些只是历史痕迹形成假设;修改最小且安全的表面;运行能够证伪假设的检查;如果 Snapshot 失败,则判断它揭示了真实契约,还是过期预期。
重要对象不是聊天 Transcript,而是工作不断变化的状态:
- 意图。 要移除什么,什么必须保持兼容?
- 初始证据。 哪些文件、测试、服务路径和部署配置看起来相关?
- 行动。 在什么环境、以什么权限改了什么?
- 观察。 运行了哪些检查,显示了什么,哪个结果仍然模糊?
- 决定。 为什么可以进入 review,或者为什么应该停止?
这份记录可以很紧凑。它不需要记录每个私有推理 Token,也不需要保留每条无害的 Shell 命令,但必须保存会改变下一次决定的事实。任务暂停时,另一个工程师应该能看到 Schema 已更新、Staging 部署仍然引用旧 Key,以及因为需要缺失凭证而有意没有运行集成测试。这样就足以负责任地继续。
静态示例教语法,变化中的系统教判断
代码语料很丰富,但它主要展示决定做出之后的产物。一个静止的仓库可以教 Agent 迁移长什么样,却不能单独教它为什么团队拒绝了第一版迁移、哪个生产约束改变了计划,或如何把 flaky test 与真实回归区分开。
执行增加了缺失的反馈。失败的命令告诉系统,它对环境的模型有问题;浏览器预览可能推翻单元测试;Reviewer 可能发现 Issue 从未写下的需求。在这些时刻,Agent 需要更新计划,而不是继续输出在文字里看起来最可能的模式。
这并不意味着每个运行时事件都应该成为训练信号。构建日志有噪声,测试可能不完整,绿色 Pipeline 也可能来自一个没有真正覆盖相关路径的断言。把所有输出当成同等证据,会鼓励另一种过度自信。
因此,基础设施应该把具体结论连接到支持它的产物。“空状态显示正确”需要视觉检查,也可能需要交互测试;“API 保持向后兼容”需要契约测试、Schema Diff 和对兼容窗口的说明;“数据变更可逆”需要迁移计划和经过测试的回滚路径,而不是一句笼统的安全声明。
系统越接近这种纪律,执行 Trace 就越有利于评估和学习。
评估应该包括路径,而不只是补丁
许多软件 Benchmark 只评分最终状态:测试是否通过,Agent 是否生成了预期 Diff,Issue 是否关闭。这些指标有用,却不完整。两个 Agent 可能通过完全不同的路径得到同一个补丁。一个检查了受影响的接口、运行了针对性测试、注意到依赖约束,并留下简洁记录;另一个可能做了宽泛修改,不断重试直到测试变绿,却删掉了 Benchmark 没有覆盖的边界情况。
在共享代码库中,这个差别很重要。
实际评估关心的问题包括:
- Agent 是否找到了真正决定行为的文件和契约?
- 是否在扩大范围前做了可撤销、边界清晰的变更?
- 是否使用可用环境去验证一个有意义的假设?
- 是否区分了命令成功和任务完成的证据?
- 遇到不确定性时,是否保留问题供 review,而不是把它藏进漂亮的总结?
- 另一个人能否在不重放长对话的情况下恢复当前状态?
这些不是风格偏好,而是 Agent 是否适合进入真实工程循环的问题。
恢复也是学习信号的一部分
最能说明问题的时刻往往是失败尝试。Agent 修改配置文件后,服务拒绝启动,原始错误却指向另一个子系统;迁移在隔离环境中通过,接触真实数据量后失败;前端修复看起来正确,却在窄视口下暴露出底层布局假设。
正确响应不是隐藏错误,而是让修正变得清楚。尝试了什么?哪个观察推翻了它?现在有什么条件可以防止同样失败?记录这条路径的任务,比只展示干净最终 Diff 的任务,更能帮助 reviewer 理解系统。
持久任务状态因此很重要。如果进程在修复中途重启,它不应该假装什么都没发生,而应该从最后确认的事实、未解决的失败、分支状态和下一步所需权限继续。这才会让 Agent 的经验积累起来,而不是一次次被丢弃。
软件能教什么,不能教什么
软件是好的训练场,因为反馈密集、产物可检查、干预可以被限制。它为语言模型和有后果的工作之间提供了一座实用的桥。但它仍然只是一种环境。
目标不是训练 Agent 熟练执行一套命令仪式,而是构建能够与证据保持纪律关系的系统:提出假设,在边界内行动,观察结果,保留不确定性,并把工作以可用状态交给下一个人。
仓库有价值,是因为它让这种纪律成为可能。它给 Agent 的不是只有 Prompt,也不是完美 Benchmark,而是一个会回应的变化系统。
这对评估有直接影响。只检查最终 Diff 的 Benchmark 可能奖励幸运的修改,忽略脆弱推理。更好的评估会问 Agent 是否使用了相关证据,是否在重试中保留了约束,是否在不确定性仍然存在时停止;还可以测量恢复:后来接手的 Agent 或 reviewer 能否在不重放整个对话的情况下理解状态。
环境应该暴露什么
不是所有信号都同样重要。构建输出通常有噪声,测试可能不完整,截图可以证明可见状态,却很少说明无障碍或失败处理。系统需要一种方式,把结论和真正支持它的证据连接起来。
所以 Agent 周围的基础设施很重要。沙箱执行、仓库状态、权限、测试、预览、日志和 review 检查点不只是附加在模型旁边的工具,它们共同定义了模型能够了解自己工作的范围。
近期机会是实际的,而不是神秘的:构建让 Agent 可以提出假设、做有边界的变更、收集证据并从中断中恢复的环境。软件是一个好的开始,因为反馈密集、产物可检查,而且后果足够真实,能够教会纪律。