메뉴
HN
Hacker News • 22일 전

grep이 LSP를 이기는 이유: 코딩 에이전트는 정밀한 도구를 무시한다

IMP
7/10
핵심 요약

코딩 에이전트의 코드 검색 실험에서 LSP 기반 시맨틱 내비게이션이 grep보다 정밀함에도 불구하고 에이전트는 대부분 grep을 선택했고, 시맨틱 도구를 강제하면 오히려 성공률이 떨어지는 경우가 있었다. 핵심은 도구의 'LLM 친화성'—정확성만이 아니라 다음 단계에 필요한 충분한 맥락을 모델이 바로 쓸 수 있는 형태로 반환하는지—이며, 코드베이스의 어휘적 노이즈가 많을수록 시맨틱 내비게이션의 가치가 커진다는 결과다.

번역된 본문

왜 코딩 에이전트는 더 정밀한 결과를 반환하는 검색 인터페이스를 무시할까? 나는 grep을 활용한 어휘 검색과 LSP 기반 시맨틱 내비게이션을 비교하는 소규모 연구를 통해 이 질문을 탐구했다. 시맨틱 내비게이션이 노이즈를 줄이고 토큰을 절약해줄 것으로 예상했다. 그러나 실제로는 에이전트가 종종 grep에 머물렀다. 시맨틱 경로를 먼저 쓰도록 강제하자, 작업 성공률이 오히려 떨어지는 경우도 있었다.

이것은 'LLM 친화성(LLM-friendliness)'의 문제다. 도구가 모델에게 친화적인 것은 결과가 정밀하다는 이유만으로는 충분하지 않다. 다음 단계에 필요한 충분한 맥락을 반환하고, 그 맥락을 모델이 직접 사용할 수 있는 인터페이스와 출력 형태로 제공해야 한다. 친숙함도 중요할 수 있다. 모델이 학습 중에 유사한 행동 경로를 익혔을 가능성이 있다. 인터페이스 특성은 직접 평가할 수 있지만, 학습 지원 여부는 이 결과와 일치하는 가설일 뿐 이 연구가 증명하는 것은 아니다.

이 결과는 LSP 전반에 대한 반박이 아니다. LSP 프로토콜은 코드 내비게이션을 훨씬 뛰어넘는 기능을 포함하며, 이 연구는 그중 아주 일부만 테스트했다. 대신 결과는 더 넓은 엔지니어링 문제를 가리킨다. 모델은 도구를 고립된 상태로 사용하지 않는다. 사용 가능한 행동, 그 이름, 입력, 모델에게 반환되는 맥락을 정의하는 '하네스(harness)'를 통해 도구를 사용한다.

이 글에서는 코드 검색이 코드 탐색 작업과 편집 작업 모두에 어떤 영향을 미쳤는지, 왜 grep이 특정 조건에서 유리했는지, 그리고 이것이 에이전트 플랫폼에 어떤 의미를 갖는지 설명한다.

두 가지 코드 검색 인터페이스 비교

나는 에이전트가 코드 맥락을 검색하는 두 가지 방식을 비교했다. grep은 어휘 검색을 수행한다. 즉, 일치하는 텍스트를 찾는다. 반면 테스트한 LSP 기반 도구는 참조(reference), 정의(definition), 문서 심볼(document symbol)을 통한 시맨틱 내비게이션을 수행하며, 덕분에 실제 함수 호출과 주석에 나오는 동일한 단어를 구별할 수 있다.

파일럿은 세 가지 Claude 모델, 여러 Python과 TypeScript 저장소, 다양한 작업 유형을 다뤘다. 토큰 사용량은 두 접근 방식 모두 작업을 성공적으로 완료했을 때만 측정했다. 이는 흔한 평가 오류를 통제하기 위해서다. 실패한 실행은 일찍 중단되었기 때문에 효율적으로 보일 수 있기 때문이다.

간단한 코드 위치 파악 작업에서는 세 모델 모두 두 도구를 함께 제공했을 때 시맨틱 도구를 선택한 비율이 0%~6%에 불과했다. 시맨틱 우선 경로를 강제하자 해당 그룹의 성공률이 100%에서 89%로 떨어졌다.

참조 완전성(reference-completeness) 작업은 다른 결과를 냈다. 모든 호출자(caller)를 찾으라고 했을 때 모델들은 45%~57%의 비율로 시맨틱 내비게이션을 선택했다. LSP 기반 경로는 거짓 일치를 제거하여 정밀도(precision) 1.00을 달성한 반면 grep은 0.76이었다. 그러나 재현율(recall)은 두 그룹 모두 0.66 근처에 머물렀다. 시맨틱 내비게이션이 더 많은 실제 호출을 찾아내지는 못한 것이다. 남은 한계는 검색 정밀도가 아니라 에이전트가 얼마나 꼼꼼하게 작업했는지에서 비롯됐다. 더 강력한 모델들의 경우 정밀도 향상은 절약이 아니라 오히려 더 높은 토큰 사용을 수반했다.

모델은 맹목적으로 grep을 선호하지 않는다 — 작업에 따라 라우팅한다

grep과 LSP를 모두 사용할 수 있고 에이전트가 자유롭게 선택할 때, 시맨틱(LSP) 도구 호출 비율. 범례: Opus 4.8(파랑), Sonnet 4.6(마젠타), Haiku 4.5(초록).

작업 Opus 4.8 Sonnet 4.6 Haiku 4.5
위치 파악 0% 4% 6%
참조 완전성 45% 50% 57%
다중 파일 이름 변경 3% — —

코드베이스도 중요했다. 깔끔한 TypeScript 저장소에서는 LSP 기반 내비게이션이 F1 향상을 전혀 만들어내지 못했고 토큰을 16% 더 사용했다. 반면 노이즈가 많은 TypeScript 저장소에서는 F1을 0.246 개선하고 토큰을 12% 절약했다. 유용한 예측 변수는 언어의 정적 타입 강함 여부가 아니라 어휘적 노이즈였다.

코드베이스 노이즈가 시맨틱 내비게이션의 가치를 결정한다

참조 완전성 작업에서 시맨틱 검색의 정확도 향상(ΔF1 = LSP − grep).

원문 보기
원문 보기 (영어)
Docs Blog Star 952 Get started All posts Engineering 9 min read Grep beats LSP? Why coding agents ignore your fancier tools I compared grep with LSP-backed semantic navigation across code-finding and editing tasks. The results show why a tool's LLM-friendliness may matter as much as the capability behind it. PX Pengcheng Xu Engineering · 2026-08-12 Copy link Why would a coding agent ignore a retrieval interface that returns more precise results? I explored this question in a small study comparing lexical search with grep against LSP-backed semantic navigation. I expected semantic navigation to reduce noise and save tokens. Instead, agents often stayed with grep . When I forced them to use the semantic path first, task success sometimes fell. This is a question of LLM-friendliness. A tool is not friendly to a model merely because its results are precise. It must return enough context for the next step and present that context in an interface and output shape the model can use directly. Familiarity may also matter: the model may have learned similar action paths during training. The interface properties can be evaluated directly. Training support is a hypothesis consistent with these results, not something this study proves. The result is not a general argument against LSP. The protocol includes capabilities far beyond code navigation, and this study tested only a small subset. Instead, the results point to a broader engineering problem: a model does not use tools in isolation. It uses them through a harness that defines the available actions, their names, their inputs, and the context returned to the model. In this post, I describe how code retrieval affected both code-finding and editing tasks, why grep had an advantage in some conditions, and what this means for agent platforms. Comparing two code retrieval interfaces I compared two ways for an agent to retrieve code context. grep performs lexical search: it finds matching text. The tested LSP-backed tools perform semantic navigation through references, definitions, and document symbols, allowing them to distinguish a real function call from the same word in a comment. The pilot covered three Claude models, several Python and TypeScript repositories, and multiple task types. I measured token use only when both approaches completed the task successfully. This controls for a common evaluation error: a failed run can appear efficient simply because it stopped early. On simple code-location tasks, all three models chose the semantic tool only 0% to 6% of the time when both tools were available. Forcing a semantic-first path reduced success from 100% to 89% in that arm. Reference-completeness tasks produced a different result. When asked to find every caller, the models chose semantic navigation 45% to 57% of the time. The LSP-backed path reached 1.00 precision, compared with 0.76 for grep , by removing false matches. However, recall stayed near 0.66 in both arms. Semantic navigation did not find more true calls. The remaining limit came from how thoroughly the agent worked, not from retrieval precision. For the stronger models, the precision gain also came with higher token use rather than a saving. The model doesn't blindly prefer grep — it routes by task Share of semantic (LSP) tool calls when both grep and LSP are available and the agent chooses freely. Legend: Opus 4.8 (blue), Sonnet 4.6 (magenta), Haiku 4.5 (green). Task Opus 4.8 Sonnet 4.6 Haiku 4.5 Localization 0% 4% 6% Reference-completeness 45% 50% 57% Multi-file rename 3% — — The codebase was also important. On a clean TypeScript repository, LSP-backed navigation produced no F1 gain and used 16% more tokens. On a noisy TypeScript repository, it improved F1 by 0.246 and used 12% fewer tokens. The useful predictor was lexical noise, not whether the language had strong static types. Codebase noise determines the value of semantic navigation Accuracy gain from semantic retrieval on reference-completeness (ΔF1 = LSP − grep). Bar colour encodes how noisy grep is on that repo; prec = grep’s precision there. Legend: blue means grep is clean here; magenta means grep is noisy here. Repo Language grep precision ΔF1 (LSP − grep) Token cost remeda TypeScript 1.00 +0.000 +16% hono TypeScript 0.51 +0.246 −12% requests Python 0.76 +0.072 +19% These results are conditional rather than categorical. The agents did not simply “always use grep.” Their routing changed with the task, and the value of LSP-backed navigation changed with the repository. Tool interfaces change agent behavior The tested LSP-backed tools initially returned only a location: a file path, line, and column. The agent then had to open the file to inspect the code. grep , by contrast, usually returned the matching line immediately: src/auth.ts:42: return validateToken(token) . I changed the semantic-navigation response to include source text in a similar shape. The semantic backend and the set of references stayed the same; only the information returned to the model changed. Pass@1 on the rename tasks rose from 0.67 to 0.83, while follow-up file reads fell from 15.2 to 3.2 per episode. Returning source context improves semantic navigation Multi-file rename, Opus 4.8, pyright with a pre-warmed index. Same semantic backend in both LSP arms — only the output shape differs. Legend: grep (blue), LSP — locations only (magenta), LSP + inline context (green). Arm pass@1 Site recall Tokens Follow-up reads grep 1.00 1.000 2,451 4.3 LSP — locations only 0.67 0.930 4,131 15.2 LSP + inline context 0.83 0.958 3,336 3.2 This result illustrates a principle that Anthropic also emphasizes in Writing effective tools for agents : tools are interfaces for non-deterministic agents, so the context they return is part of the design. A semantically correct tool can still create a poor agent workflow if each result requires several extra actions to interpret. The output change does not prove that post-training data caused the improvement. It may also have helped simply because each response contained more useful information. However, the result is consistent with a broader hypothesis: models learn concrete action patterns, not “tool use” in the abstract. A familiar loop—prompt, tool call, readable result, next action—can be part of the capability observed in practice. Why lexical search had an advantage Interface familiarity is only part of the explanation. Lexical search also had a real structural advantage for some tasks. A semantic reference is only one kind of text match. A rename may also need to update comments, docstrings, configuration, or strings. find_references will not return those by design, while grep can. semantic references ⊂ textual occurrences For text-wide edits, grep can be the better retrieval tool even for a model with perfect training on LSP-backed navigation. This gives us two explanations for the observed behavior: Structure: some tasks need textual completeness, which the tested semantic-navigation methods do not provide. Distribution: the model may have more practice with familiar tools and result shapes. The first explanation follows directly from what the tools retrieve. The second is a hypothesis consistent with the routing and output-format results, but this study did not manipulate training data and therefore cannot prove it. The harness is part of the system Here, I use harness to mean the runtime around a model: the instructions placed in context, the tools made available, their input schemas, the shape of their results and errors, and the loop that decides what the model sees next. This surrounding system can materially change behavior. Anthropic’s work on effective harnesses for long-running agents shows the same idea at a longer time scale: the model alone is not enough to make reliable progress across sessions. Environment setup, progress artifacts, and verification routines affect what the agent can accomplish. The same principle applies within a single tool loop. When post-