Knowledge for Agents
An index, not a copy
An Agent that has to answer a question needs to know where to look and what is true, quickly. It does not need a second copy of the codebase, and it does not need long, polished prose that restates every function.
Context therefore treats knowledge as an index with explanations:
- each article answers specific reader questions agreed in the requirements;
- each statement points to the exact source region it came from;
- the source itself stays where it is, readable at a pinned version when more detail is needed.
flowchart LR
src["Sources"] --> idx["Indexer"]
idx -->|keeps| kept["Entries, contracts, rules"]
idx -.->|leaves in source| left["Bodies, boilerplate"]
kept --> art["Article with references"]Extract on demand
Indexers do not start with a full symbol scan or a complete relationship graph. During planning they expose a useful skeleton — directories, manifests, registration points, public entries — and propose reader topics. Detailed reading happens while writing each topic, bounded to what that topic needs. Signals such as public exports, registered interfaces, scheduled jobs, storage interfaces or generated clients suggest reader questions, not mandatory pages; one page per symbol is explicitly avoided.
Symbol count is not a quality measure. Internal or out-of-scope items can be left out with a reason; Review checks whether the pages actually answer the reader's questions.
How much smaller
In a large production full-stack monorepo, the two repositories that could be counted locally held about 33,700 code files and 5.84 million lines (about 200 MB); together with about 1,130 document snapshots (about 1.77 MB), they became 220 reviewed articles totalling about 1.75 MB — roughly 1/115 of the source volume.
Two limits apply to that figure:
- only part of the registered sources was counted, so the real ratio is higher;
- the ratio measures size, not coverage or quality. Quality is measured separately in the Knowledge Retrieval benchmark.
The knowledge is not lossless and does not "cover all code". It keeps the facts needed to answer questions, each with a pointer back to the code line or document section. See Evidence Chains and Index First.
写给 Agent 的知识
是索引,不是副本
需要回答问题的 Agent,要能快速知道去哪里找以及什么是事实。它不需要代码库的第二份副本,也不需要把每个函数都复述一遍的长篇精修文字。
因此,Context 把知识当作带有解释的索引:
- 每篇文章回答需求中约定的具体读者问题;
- 每条陈述都指向它所依据的确切来源区域;
- 来源本身保持原位,需要更多细节时可以在固定版本上阅读。
flowchart LR
src["来源"] --> idx["Indexer"]
idx -->|保留| kept["入口、契约、规则"]
idx -.->|留在来源中| left["实现体、样板代码"]
kept --> art["带引用的文章"]按需抽取
Indexer 不会从全量符号扫描或完整关系图开始。在计划阶段,它们先展示有用的骨架——目录、清单文件、注册点、公开入口——并提出读者主题。详细阅读发生在撰写各个主题时,范围以该主题所需为限。公开导出、已注册接口、定时任务、存储接口或生成的客户端等信号,提示的是读者问题,而不是必须产出的页面;明确避免一个符号一页。
符号数量不是质量指标。内部或超出范围的条目可以说明理由后略去;审核检查的是这些页面是否真正回答了读者的问题。
能小多少
在一个大型生产级全栈 monorepo 中,可在本地统计的两个仓库共有约 33,700 个代码文件、584 万行代码(约 200 MB);加上约 1,130 份文档快照(约 1.77 MB),最终形成 220 篇经过审核的文章,总计约 1.75 MB——大约是来源体量的 1/115。
这个数字有两点限制:
- 只统计了部分已登记的来源,因此实际比例更高;
- 该比例衡量的是体量,而不是覆盖度或质量。质量另行在知识检索测评中衡量。
这些知识并非无损,也不“覆盖全部代码”。它保留回答问题所需的事实,每条都带有指回代码行或文档章节的指针。参见证据链与索引优先。