← 返回藏书阁

FastContext — read-only delegated repository exploration agent

wiki/ai/sources/fastcontext-read-only-repository-exploration.md
分类:ai / sources · 更新:2026-07-21 09:16

FastContext — read-only delegated repository exploration agent

为什么重要

FastContext 值得入库,因为它把 Repository-ExplorationContext-Engineering 的一个关键原则做成了很窄的工具合同:主 coding agent 不应把大量 grep/read/search 噪音塞进自己的上下文,而是把自然语言问题委托给一个只读探索 agent;FastContext 独立探索 repo,最后返回短、带文件路径和行号 citation 的答案。

这对 Hermes 很有价值:许多复杂代码任务的失败不是不会写 patch,而是主 agent 在探索阶段消耗太多上下文、混入低信号输出、或拿到没有证据的结论。FastContext 的设计把“找证据”和“做修改”拆开,天然降低 blast radius,也使探索结果更容易被验证。

机制 / 一阶原理

FastContext 的机制是:主 agent 通过 bash 提问,FastContext 在独立进程中用只读工具探索,然后返回可机器解析的 cited answer

核心组成:

  1. 只读工具面ReadGlobGrep,不编辑文件。
  2. 独立上下文窗口:探索过程不污染主 agent 的上下文,只把最终高信号答案带回。
  3. 机器可解析 final_answer:输出类似 src/file.py:13-64 的证据范围。
  4. citation validation:未实际打开过的 hallucinated line ranges 会被丢弃。
  5. context-budget management:接近窗口限制时要求 agent 回答而不是继续探索到失败。
  6. trajectory recording / eval harness:每次探索可写 JSONL trajectory,并比较 turns、tool calls、duplicate calls、citation quality、tokens。
一阶原理是:上下文工程不只是“压缩更多材料”,而是把探索噪音和决策上下文隔离;让主 agent 只消费被证据绑定的最小信息。它类似 [[acquire-qa-driven-repository-knowledgeACQUIRE]] 的 Answerer 角色,但更工具化、窄合同化。

与既有 wiki 概念的关系

  • Context-Engineering:FastContext 是 purpose-shaped context 的 runtime provider,按问题返回最小证据,而不是全仓摘要。
  • Repository-Exploration:它把探索能力产品化为独立 agent,并强调 line-range citation 与验证。
  • Agentic-Coding:主 agent 专注改代码,探索 agent 专注找证据,减少角色混淆。
  • Harness-Engineering:只读 delegation 是安全 harness:降低副作用,同时保留审计轨迹。
- 对 [[acquire-qa-driven-repository-knowledgeACQUIRE]]:ACQUIRE 提供 question-driven QA 方法论,FastContext 提供可嵌入 CLI 的 Answerer-like 工具面。

对 Hermes / llm-wiki 的可执行启发

  1. 复杂代码任务默认先委托只读探索:让 read-only worker 回答“相关文件/机制/约束在哪里”,主 agent 再 patch。
  2. wiki ingest 也可借鉴 citation validation:正式 source/concept 页的关键 claim 应能追溯到 raw/source 段落,而不是只凭流畅总结。
  3. 把探索 token 与决策 token 分账:工具输出、搜索循环和低信号文件读取不应污染最终推理上下文。
  4. <final_answer> 合同用于子代理:子代理返回路径/行号/证据,而不是长篇分析,便于主代理行动和验证。
  5. 评估 context provider 的 adoption 与 citation quality:不是问“有没有找到东西”,而是问答案是否短、准、可定位、可复查。

失败模式 / 边界条件

  • 只读不等于正确:探索 agent 仍可能遗漏关键文件、误解调用链或过早回答。
  • citation narrowness:行号 citation 能证明读过某段代码,但不必然证明结论完整。
  • 模型/endpoint 依赖:需要 OpenAI-compatible endpoint 与上下文窗口配置;不同模型探索质量会波动。
  • 主从接口过窄:如果主 agent 问题本身模糊,FastContext 可能返回局部正确但不解决真实知识缺口的答案。
  • README 证据限制:当前入库基于 README,未在真实 repo 中运行 eval harness。

深度判断

本条值得 deep ingest,因为它提供了一个可直接迁移到 Hermes 的安全/上下文模式:只读 delegated exploration + cited compact answer + citation validation + trajectory/eval。它不是泛泛的 repo RAG,而是围绕 coding-agent 主上下文减噪和证据绑定设计的窄工具合同。

写入记录

  • 2026-07-21 09:01 CST:新增 FastContext source 页,提炼只读委托探索、citation validation、context-budget management 与探索/修改解耦对 Hermes 的启发。