跳到主内容
@wquguru
精选88r/LLMDevs(Reddit)技巧与观点

实测6款代码索引工具:Token节省宣称未兑现

I benchmarked repowise, CodeGraph, Serena, Graphify, code-review-graph, cocoindex and codebase-memory-mcp across Codex, Claude Code and a local model. The 60-90% token-saving claims didn't hold up

原文
发到 X
推荐理由

Agent开发者的硬核踩坑指南,用严谨实验打假“Token节省”营销,直接指导选型与预期管理。

Scroll to bottom for tldr

滚动到底部查看要点总结(tldr)

In July, JetBrains reran the headline claims of two token-saving tools on real agent workloads.

7月,JetBrains在真实的智能体工作负载上重新验证了两种声称能节省Token的工具的头条声明。

Caveman claimed 65% and measured 8.5%. RTK claimed 60–90% and ended up slightly more expensive than using nothing. How the tools fool you??

Caveman声称节省了65%,实际测量结果为8.5%。RTK声称节省了60-90%,结果反而比不使用任何工具更昂贵。这些工具是如何欺骗你的?

It felt like every tool out there was overclaiming, so I benchmarked 5 token saving tools with conditions closer to how agents actually use them

感觉市面上的每个工具都在夸大其词,因此我基准测试了5种节省Token的工具,测试条件更接近智能体的实际使用方式。

my setup was :

我的设置如下:

  • 48 Django questions drawn from SWE-bench
  • Five question types, selected before running anything
  • Same agent, prompt, repository commit and tool access
  • Fresh index for every tool
  • One no-tools baseline
  • 261 runs on this harness
  • 43 of the 48 questions finished in all six arms. The run hit an API usage cap near the end and lost the last five from every arm equally, so the paired comparisons are over those 43.
  • 从SWE-bench中选取的48个Django问题
  • 五种问题类型,在运行任何测试前选定
  • 相同的智能体、提示词、代码库提交和工具访问权限
  • 每种工具都使用全新的索引
  • 一个无工具的基线对照组
  • 在此测试框架上进行了261次运行
  • 48个问题中有43个在所有六个实验组中均完成。由于接近结束时触发了API使用量上限,导致每个实验组的最后五个问题均失败,因此配对比较仅针对这43个问题。

Since the first version of this post I've added cocoindex and codebase-memory-mcp, a third harness on a local model, and a call graph correctness benchmark graded by a compiler.

自本文初版以来,我添加了cocoindex和codebase-memory-mcp,增加了一个基于本地模型的第三个测试框架,以及一个由编译器评估的调用图正确性基准测试。

Disclosure: I work on repowise. Token saving was never its main goal; it's a side effect of the index it builds for agents (call graph, git history, code health, architectural decisions, searchable docs). The harness, raw data, preregistration files and invalidated runs are all public

披露:我在repowise工作。节省Token从来不是其主要目标;它是其为智能体构建的索引(调用图、git历史、代码健康度、架构决策、可搜索文档)产生的副作用。测试框架、原始数据、预注册文件和无效的运行记录均已公开。

Codex : gpt-5.6-sol

ToolCalledvs baselineTool callsFewer tokens onp-valueIndex time
repowise44/44-31.6%3.837/44<0.0001366.8s
CodeGraph44/44-24.4%4.037/44<0.000116.4s
Serena43/43-14.8%10.135/43<0.0001No index
Graphify43/43-8.9%7.431/430.003141.5s
code-review-graph43/43-6.0%7.226/430.04644.8s
No tools0/44Baseline7.2n/an/an/a
工具被调用次数对比基线工具调用次数减少Token的次数p值索引时间
repowise44/44-31.6%3.837/44<0.0001366.8s
CodeGraph44/44-24.4%4.037/44<0.000116.4s
Serena43/43-14.8%10.135/43<0.0001无索引
Graphify43/43-8.9%7.431/430.003141.5s
code-review-graph43/43-6.0%7.226/430.04644.8s
No tools0/44基线7.2n/an/an/a

Nobody saved 60%.

没有人节省60%。

The best result was about 32% of the agent's output tokens, and once you correct for testing five tools at once, three of those five reductions hold up and two are marginal. CodeGraph is a real second at 24.4%, so the correct reading is that more than one tool here works.

最佳结果约占智能体输出Token的32%,且一旦对同时测试五种工具进行校正,这五种减少量中有三种具有统计学意义,另外两种则边缘显著。CodeGraph以24.4%的真实效果位居第二,因此正确的解读是:这里有超过一种工具有效。

Serena was very weird. It writes less than the bare agent while calling tools 42% more often, which makes it busier rather than leaner.

Serena的表现非常奇怪。它在调用工具频率高出42%的情况下,输出的内容却比裸奔的智能体更少,这使得它变得更忙碌而非更精简。

Indexing is also part of the tradeoff. Repowise saved the most tokens here but took the longest to index, because it builds several additional intelligence layers in the same pass. For a straightforward call graph, CodeGraph is 22x faster. And 366.8s is the version with prose generation switched off; a default init on this repo is 1,058s.

索引也是权衡的一部分。Repowise在这里节省了最多的Token,但索引时间最长,因为它在同一遍处理中构建了多个额外的智能层。对于简单的调用图,CodeGraph的速度快22倍。而366.8秒是关闭文本生成功能后的版本;在该仓库上使用默认初始化则需要1,058秒。

Why there is no Claude Code table here

为什么这里没有 Claude Code 的表格

I ran the same questions, servers and indexes under Claude Code with Sonnet 5, and then again with Opus. Those tables are on the benchmarks page, because under Claude Code most of these tools were barely called at all. code-review-graph was never called once across 15 questions. Graphify was called three times, Serena four. Nothing was different about the servers, the questions or the indexes between the two harnesses, and Codex called every tool on every question.

我在 Claude Code 中针对相同的 15 个问题、服务器和索引,分别使用 Sonnet 5 和 Opus 进行了测试。这些表格位于基准测试页面,因为在 Claude Code 下,大多数工具几乎从未被调用过。在 15 个问题中,code-review-graph 一次都没有被调用。Graphify 被调用了三次,Serena 四次。两个框架下的服务器、问题或索引没有任何区别,而 Codex 在每个问题上都调用了所有工具。

The likely explanation is harness behavior. Claude Code loads MCP schemas on demand, so the agent has to go looking before it can call anything, and frequently never does. Codex mounts them up front

可能的解释是框架行为差异。Claude Code 按需加载 MCP schema,因此代理必须先查找才能调用任何工具,而且经常根本找不到。Codex 则预先挂载它们。

Update: this turned out to be unstable for every tool, mine included. repowise went from 15 of 15 in the first run to 4 and then 3 of 15 in later reruns. Opus landed at 7 of 15, which I had defined before the run as inconclusive.

更新:事实证明这对每个工具都不稳定,包括我的工具。repowise 在第一次运行中达到了 15/15,但在后续重跑中降至 4/15,然后是 3/15。Opus 最终结果为 7/15,这在运行前被我定义为“结论不明确”。

Third harness: local qwen3:8b

第三个框架:本地 qwen3:8b

Same 15 questions under Ollama via opencode, and the agent called the tool on every question. repowise cut output tokens by 40.8% and wall clock time by 27.5%. With only the local tools enabled (no hosted model at all), the cuts were 47.9% on tokens and 41.5% on time. It used fewer tokens on 15 of 15 questions, p = 0.00006. I only ran repowise on this harness, so this row has no competitor comparison.

通过 opencode 在 Ollama 上运行相同的 15 个问题,代理在每个问题上都调用了该工具。repowise 将输出 token 减少了 40.8%,墙钟时间减少了 27.5%。仅启用本地工具(完全不使用托管模型)时,token 减少 47.9%,时间减少 41.5%。在 15/15 个问题中它使用的 token 更少,p = 0.00006。我仅在此框架下运行了 repowise,因此这一行没有竞争对手对比数据。

Quality

质量

There was no meaningful quality winner, including repowise.

没有显著的质量赢家,包括 repowise。

A blind judge scored every tool in the field, mine included, a fraction below the bare agent, in a range of 0.04 to 0.25 points on a 10 point scale. None of those gaps is distinguishable from zero, and all of them are smaller than the 0.69 points the same benchmark moves when it is rerun unchanged.

盲测评审对现场所有工具(包括我的工具)进行了评分,分数均略低于裸代理,范围在 10 分制下的 0.04 到 0.25 分之间。这些差距与零没有显著差异,且都小于同一基准测试在不改变设置的情况下重跑时产生的 0.69 分波动。

Deterministic retrieval benchmark

确定性检索基准测试

Token counts still depend on an LLM deciding what to write, so I also ran a deterministic benchmark using ContextBench

Token 计数仍然取决于 LLM 决定写什么,因此我还使用 ContextBench 运行了一个确定性基准测试。

Each task has a known list of files touched by the real fix. The score simply measures whether a tool retrieves those files. So there was no LLM judge.

每个任务都有一个已知的真实修复所涉及的文件列表。得分仅衡量工具是否检索到了这些文件。因此这里没有 LLM 评审。

ToolGold files foundPrecisionFiles servedInstances
repowise get_answer0.8760.08719.242
repowise search_codebase0.7420.1688.242
CodeGraph0.6100.09314.042
Graphify0.5460.03334.542
code-review-graph0.4450.2405.442
cocoindex0.3610.0927.141
工具找到的黄金文件精确率提供的文件数实例数
repowise get_answer0.8760.08719.242
repowise search_codebase0.7420.1688.242
CodeGraph0.6100.09314.042
Graphify0.5460.03334.542
code-review-graph0.4450.2405.442
cocoindex0.3610.0927.141

Coverage on its rewards whoever serves highest files, which is why precision and files served sit next to it. get_answer finds the most and hands back about 19 files to do it. code-review-graph finds the least and is the most precise thing in the table, 0.240 from 5.4 files, so if you are paying per token that row reads better than its coverage suggests. Graphify serves 34.5 files for 0.546

其覆盖率基于服务文件数最多的模型,这也是为什么精确度和服务文件数并列显示的原因。get_answer 找出的最多,并返回约 19 个文件以完成操作。code-review-graph 找出的最少,是表中精确度最高的项,从 5.4 个文件中得出 0.240 的数值,因此如果你按 token 付费,该行的表现优于其覆盖率所暗示的水平。Graphify 服务了 34.5 个文件,得分为 0.546

The 42 instances were a sealed half, held out and never touched until the final run. cocoindex was added later; one of its instances never returned an answer, so its n is 41.

这 42 个实例是一个密封的半集,被保留下来,直到最终运行前从未被触碰过。cocoindex 是后来添加的;其一个实例从未返回答案,因此其 n 值为 41。

This required 748 index builds and roughly 78 hours of indexing for 1,129 graded instance/tool pairs. Every tool indexed every repository independently at the task's original base commit, with no shared cache.

这需要构建 748 次索引,并对 1,129 个已评分的实例/工具对进行大约 78 小时的索引处理。每个工具都在任务原始的基础提交点上独立地对每个仓库进行索引,没有共享缓存。

Is the call graph actually correct

调用图实际上是否正确?

A call graph can be wrong in two ways: it can miss real calls (recall), or it can invent calls that don't exist (precision). Here the answer key comes from the compilers, not from me: Go's own callgraph/rta and TypeScript's tsc. That's 37,853 edges across 5 tools and 7 repo cells.

调用图可能以两种方式出错:它可能遗漏真实的调用(召回率),或者发明不存在的调用(精确度)。这里的参考答案来自编译器,而非我自己:Go 自身的 callgraph/rta 和 TypeScript 的 tsc。这涉及 5 个工具和 7 个仓库单元格中的 37,853 条边。

  • No tool found as much of the call graph as repowise while also getting more of it right, and that held in all 7 cells.
  • I lose recall in all five Go cells. codebase-memory-mcp and CodeGraph find a bigger graph, but on syft more than a third of the leader's edges don't exist according to the Go compiler.
  • repowise is the most precise tool outright in only 1 of 7 cells. code-review-graph hits 0.997 precision on cobra, but its graph covers 17% of the calls there.
  • 没有哪个工具像 repowise 那样在发现更多调用图的同时还能保持更高的正确率,这一优势在所有 7 个单元格中都成立。
  • 我在所有五个 Go 单元格中损失了召回率。codebase-memory-mcp 和 CodeGraph 找到了更大的图,但在 syft 上,根据 Go 编译器的判断,领先者超过三分之一的边并不存在。
  • repowise 仅在 7 个单元格中的 1 个里成为绝对最精确的工具。code-review-graph 在 cobra 上达到了 0.997 的精确度,但其图仅覆盖了其中 17% 的调用。

Graph-only build across 35 repos: repowise had the lowest memory on all 35 (median 75 MB against 757 MB for CodeGraph). Speed was a tie, with CodeGraph fastest on 16 repos and repowise on 14.

跨 35 个仓库的纯图构建:repowise 在所有 35 个仓库中内存占用最低(中位数为 75 MB,而 CodeGraph 为 757 MB)。速度方面打平,CodeGraph 在 16 个仓库中最快,repowise 在 14 个仓库中最快。

Two mistakes I nearly published

我差点发布的两个错误

I nearly published a cost table showing code-review-graph as 43% cheaper than the baseline, in the same run where Claude Code never called it once.

我差点发布了一张成本表,显示 code-review-graph 比基线便宜 43%,而在同一轮运行中,Claude Code 一次都没有调用它。

The reason was prompt-cache warming. Whichever arm ran first paid the full price, and later arms reused the cache

原因是提示词缓存预热。最先运行的分支支付了全额费用,后续分支则复用了缓存

That is why the tables report output tokens rather than API cost.

这就是为什么表格报告的是输出 token 数量而非 API 成本的原因。

There is a larger version of this mistake, which is measuring one retrieved payload instead of the complete agent session. Loading one commit's context through repowise takes 393 tokens against 13,984 for reading the changed files, so 35.6x, and that is the easy number this whole category tends to publish. The full-session figure is 31.6% on Codex and 15.9% on Claude Code. Agents re-read, backtrack and re-plan, so a compression that looks enormous on a single payload nets out much smaller across a session.

存在一个更严重的错误,即仅测量单个检索到的有效载荷,而非完整的智能体会话。通过 repowise 加载单个提交的上下文需要 393 个 token,而读取变更文件则需要 13,984 个 token,比例为 35.6 倍,这也是该类别通常公布的“容易”数据。完整会话层面的压缩率分别为:Codex 为 31.6%,Claude Code 为 15.9%。由于智能体会重新读取、回溯并重新规划,因此在单个有效载荷上看似巨大的压缩效果,在整个会话中会大幅缩减。

Full methodology, raw data and reproducibility files:

完整的方法论、原始数据和可复现文件:

https://github.com/repowise-dev/repowise/blob/main/docs/BENCHMARKS.md

I'm happy to add other tools if there are ones people think are worth testing. The harness is public, so you can also rerun or challenge the results directly.

如果有哪些工具大家认为值得测试,我很乐意将其加入。测试框架是公开的,因此您也可以直接重新运行或质疑这些结果。

更进一步:量化金融体系

看懂新闻只是起点——沿量化金融路径,把它变成能交付的工程能力

进入量化体系 →

相似阅读

关联信息,但可能不是同一事件