产品与服务

Claude Code 与 Codex 双双放弃向量检索:LLM 驱动 ripgrep 的零索引 agentic search

RAG已死?不,是Grep回归了!

上下文与知识智能体系统应用与实践上下文工程检索增强Agent 工具调用编程

概述

Claude Code 创建者 Boris Cherny 公开表示 Claude Code 不用 RAG、不用 embedding、不建索引,早期版本用过 RAG + 本地向量库但很快发现 agentic search 效果更好,Anthropic 官方 Context Engineering 博客确认其用 Grep 与 Glob 把代码动态加载进 context。2026 年 3 月因泄露公开的 CLI 源码快照(4,471 个文件)中没有任何 embedding、vector、similarity search 实现,GrepTool 底层 import ripgrep(tools/GrepTool/GrepTool.ts:21)而非系统 grep,提供三种输出模式:files_with_matches(默认,只返回匹配文件路径,head_limit 默认 250)、content(返回匹配行及上下文)、count(只返回各文件匹配数)。检索由 LLM 在多轮循环中自主决定搜什么、用什么工具、是否继续,与代码搜索相关的核心工具为 GrepTool(ripgrep)、GlobTool、FileReadTool、AgentTool(可启动只读的 Explore 子 agent 做 context 隔离),并配 LSP 工具补充语义操作。成本侧三层机制:system prompt 拆成可单独标记缓存策略的文本块以命中 prompt cache(第三方分析称相邻轮次 92% 前缀相同、成本降约 81%)、接近窗口上限时 auto-compaction 用 LLM 摘要替换旧消息、子 agent 隔离搜索中间结果。OpenAI Codex CLI 架构高度相似:不建索引、不用 embedding、不用向量库,社区提交的向量索引功能请求(GitHub Issue #609)被团队关闭并回复「not currently on our roadmap」;差异在于 Codex 不封装专用搜索工具,全部通过 shell 执行 rg/find/cat,system prompt 要求「prefer using rg」。文中另提到 Claude Code v2.0.74 引入 LSP 支持,第三方实测称降低约 40% token 消耗。