3 ms·
I see a lot of overlap with LSPs, which better agents already use, so I would appreciate a comparison. What does this add?
by esafak 9mo ago
I see a lot of overlap with LSPs, which better agents already use, so I would appreciate a comparison. What does this add?
- jared_stewart 9mo agoTree-sitter and LSP solve different problems. LSP is a full fledged semantics solution providing go-to-definition functionality, trace references, type info etc. But requires a full language server, project configuration, and often a working build. That's great in an IDA, but the burden could be a bit much when it comes to working through an agent. Tree-sitter handles structural queries giving the LLM the ability to evaluate function signatures, hierarchies and such. Packing this into the recursive language model enables the LLM to decide when it has enough information, it can continue to crawl the code base in bite sized increments to find what it needs. It's a far more minimal solution which lets it respond quickly with minimal overhead.
- HarHarVeryFunny 9mo agoLSP is designed to help editors, not AI agents, and provides query by cursor position. Treesitter supports query by symbol (find definition, usages, etc), and so is much better suited to what an AI agent may want to do.
- esafak 9mo agoMy agent already uses LSP plugins, and the protocol supports querying by symbol: https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification/#textDocument_documentSymbol https://microsoft.github.io/language-server-protocol/specifi... https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification/#workspaceSymbol https://microsoft.github.io/language-server-protocol/specifi...
- HarHarVeryFunny 9mo agoThanks - I wasn't aware of that, although it still doesn't seem to be what would be most useful to an AI agent. For example, if the agent wants to modify a function, it may want to know all the places the function is called, which AFAIK Treesitter can provide directly, but it seems with LSP you'd have to use that DocumentSymbol API to process every source file to find the usages, since you're really searching by source file, not by symbol.
- esafak 9mo agoFor that I believe you could use textDocument/references: https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification/#textDocument_references https://microsoft.github.io/language-server-protocol/specifi...
- HarHarVeryFunny 9mo agoYes, but that one is position-based rather than name-based - I believe it's basically for an editor to ask about whatever is under the cursor.