AI改代码先得知道改哪,这篇帮你画地图
改AI智能体的代码,最难的不是写新代码,而是找到旧代码里哪些地方要动。因为智能体的行为分散在几十个文件里,改一个功能可能要改七八个地方,开发者得自己翻遍整个仓库。这篇论文做了一个自动工具,把代码库按「行为」重新组织——比如「调用天气API」这个行为,它会自动标出所有相关的代码位置,还按层级展开:先看高层行为,再点进去看具体实现。在真实项目上测试,用这个工具规划修改,定位准确率更高,用的token还更少。它不是你明天就能用的产品,但方向很明确:未来AI改自己的代码,得先学会读自己的地图。
📄 原文摘要(英文)
The capability of a modern AI agent depends not only on its foundation model but also on its harness, which constructs prompts, manages state, invokes tools, and coordinates execution. As models, APIs, environments, and requirements evolve, the harness must be continually modified. Before such a change can be made, a developer or coding agent must identify all code locations that implement the target behavior. This is difficult because production harnesses are large, tightly coupled, and behaviorally distributed, while modification requests describe what the system should do and repositories are organized by files and modules. Code search, repository indexing, and long-context processing ease inspection, but still leave this behavior-to-code mapping to be recovered by hand. Behavior localization is therefore a central bottleneck in harness evolution. We introduce the Harness Handbook, a behavior-centric representation synthesized automatically from a harness codebase via static analysis and LLM-assisted structuring, linking each behavior to its corresponding source. We also introduce Behavior-Guided Progressive Disclosure (BGPD), which guides agents from high-level behaviors to relevant implementation details and verifies candidate locations against the current source. On diverse modification requests from two open-source harnesses, Handbook-Assisted planning improves behavior localization and edit-plan quality while using fewer planner tokens, with the largest gains on scattered sites, rarely executed paths, and cross-module interactions. Evolving complex agentic systems thus depends not only on generating edits, but also on determining where those edits should be made.