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.
Why would a coding agent ignore a retrieval tool that returns more precise results?
I ran into this in a small study comparing lexical search (grep) against LSP-backed semantic navigation. I expected semantic navigation to cut noise and save tokens. Instead, the agents mostly stuck with grep, and when I forced them to use the semantic path first, task success sometimes dropped.
Precision turned out to be only part of what makes a tool easy for an LLM to use. The tool also has to return enough context for the next step, in a format the model can act on right away. Familiarity may play a role too: the model may have seen similar tool patterns during training. The interface effects show up directly in the results below. I can't prove that training explains the gap, though it fits the data.
Either way, a model never uses a tool in a vacuum. It works through a harness that defines the available actions, their inputs, and the context that comes back.
grep does lexical search: it finds matching text and returns the file path, line number, and matched line. The LSP-backed tools provide semantic navigation through three operations: references, definitions, and document symbols. They can tell a real function call apart from the same word inside a comment.
LSP also supports diagnostics, rename, and code actions. I didn't test those, so these results apply only to the three navigation operations above.
The pilot covered three Claude models, several Python and TypeScript repositories, and three task types: code localization, reference-completeness, and multi-file rename. Each cell ran two or three times, so treat the numbers as signals rather than final verdicts.
I only compared token use when both approaches completed the task. A failed run can look cheap simply because it bailed out early.
On simple code-localization tasks, all three models picked the semantic tool only 0% to 6% of the time when both tools were available. Forcing a semantic-first path dropped success from 100% to 89%.
Reference-completeness tasks, where the agent has to find every caller, looked different. There, the models chose semantic navigation 45% to 57% of the time.
| Task | Opus 4.8 | Sonnet 4.6 | Haiku 4.5 |
|---|---|---|---|
| Localization | 0% | 4% | 6% |
| Reference-completeness | 45% | 50% | 57% |
| Multi-file rename | 3% | — | — |
On reference tasks, LSP bought precision: 1.00 versus 0.76 for grep. Every returned site was a real call, with the false matches from same-named text gone.
Recall, the share of true call sites the agent eventually found, stayed near 0.66 in both arms. Cleaner results didn't lead to more calls found. The agent still stopped before working through everything, and swapping the retrieval backend didn't fix that. For the stronger models, the extra precision also spent more tokens instead of saving them.
On remeda, a clean TypeScript repository, grep already resolved every reference accurately. Switching to LSP added nothing to F1 and used 16% more tokens. F1 combines precision and recall, so a flat score means retrieval quality didn't move.
On hono, another TypeScript repository, grep precision was only 0.51 because the same identifiers show up in many places. There, LSP raised F1 by 0.246 and used 12% fewer tokens.
The Python repository requests landed in between: +0.072 F1, with 19% more tokens.
| 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% |
Two repositories in the same language gave opposite answers, so "statically typed languages suit LSP" is the wrong rule of thumb. What matters is how many false matches grep produces in that codebase. When grep is already clean, semantic navigation is pure overhead. When the same names are everywhere, precision pays for itself.
At first, the LSP-backed tools returned only a location: file path, line, and column. The agent knew where a reference lived, but it still had to open the file to read the code before deciding anything.
grep returns the line itself:
src/auth.ts:42: return validateToken(token)
Location and content arrive together, so the model can judge relevance without another file read.
So I updated the semantic-navigation response to include two lines of source on either side of each reference. The backend and the returned references stayed identical. Only what the model saw changed.
On multi-file rename tasks, pass@1 for the LSP path jumped from 0.67 to 0.83, and follow-up file reads dropped from 15.2 to 3.2 per episode, even below grep's 4.3.
| 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 |
With bare locations, the model has to plan a read, call the tool, and process the result before acting. With inline source, those steps disappear.
Anthropic makes a similar point 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 accurate tool still makes for a clunky workflow if every match takes extra round trips to inspect.
Whether familiarity drove the gain is still an open question. Models may have seen plenty of grep-shaped trajectories during training, and the inline format may match what they know. Or each response may simply have delivered more useful information upfront. Both explanations fit the result, and because this study didn't vary training data, it can't separate them.
There's also a gap no output tweak can close: LSP and grep retrieve different sets. A semantic reference tracks a real symbol relationship in code. A rename often has to update comments, docstrings, configuration, and string literals too. find_references skips those by design, while grep catches them.
semantic references ⊂ textual occurrences
For text-wide edits, grep can be the better retrieval tool even for a model trained thoroughly on LSP-backed navigation.
That leaves two explanations for grep's advantage in this study:
A coding agent is more than a model. It runs inside a harness that controls the instructions in context, the available tools, their input schemas, the shape of their outputs and errors, and the loop that decides what the model sees next.
agent capability = model × harness
In this study, neither the LSP backend nor the model changed. Attaching a few lines of source was enough to shift both pass rate and file-read counts.
Anthropic's post on effective harnesses for long-running agents makes the same point across longer horizons: environment setup, progress artifacts, and verification routines determine what an agent can finish across sessions. Inside a single tool loop, result format, error messages, and fallback paths do the same job.
When post-training includes agent trajectories, the harness also shapes the prompts, tool calls, outputs, and recovery paths in those examples. A model trained heavily on read, grep, edit, and bash can learn policies tightly coupled to those interfaces. Drop it into a different tool layer, and its effective capability can shift.
That's why a model's benchmark scores don't automatically carry over to a different runtime.
LSP did improve retrieval quality on noisy code, and a small output tweak eliminated most follow-up reads. I'm not arguing against LSP, MCP, or new agent skills. I'm arguing for testing any new tool inside the real agent loop before relying on it. Start with the native tools, then check:
path:line:content usually works better than a bare location object.grep.Building effective agents recommends simple, composable patterns. Tools follow the same rule: adding more of them doesn't make an agent more capable.
Semantic navigation cut false matches, though that only paid off where grep was noisy. Returned as bare locations, those more precise results triggered more file reads. With a few lines of source attached, the same results became easy to act on. Evaluating a new tool means checking whether the agent chooses it, whether the task succeeds, what it costs, and whether the output supports the next step.
For the full experimental setup, task definitions, and results, see Does a Language Server Save Tokens for Coding Agents?.
That's the product principle behind AgentConnect: use an open protocol to connect agents, while keeping each model paired with its native runtime and tool loop.
textDocument/rename, diagnostics, or code actions. A rename-capable LSP might perform differently on the refactoring tasks where grep did best. The edit tasks were local and aren't standard SWE-bench scores. These findings are useful signals, not a final verdict across all models, tools, and codebases.