agent: LSP tools - #55744
Conversation
bennetbo
left a comment
There was a problem hiding this comment.
Let's experiment with it and see how it feels
|
Made some improvements based on testing #55803 |
Adds 4 (technically 5) new tools to the zed agent, corresponding to LSP actions: - `find_references` - `goto_definition` - `rename_symbol` - `get_code_actions` and `apply_code_actions` Notes: - `rename_symbol` skips doing a `prepare_rename`. If there is nothing to rename at the position, it will forward the error to the agent - The code action tools are stateful. The state is stored in the `get_code_actions` tool itself as a `PendingCodeActions`. It is not passed into/out of subagents. Calling `apply_code_actions` without calling `get_code_actions` first is an error, but I've never seen an agent do this Symbols are identified by: - file name - line number - symbol If there is no substring match on that line for the symbol text, it is an error. If there are multiple, it chooses the first. This may not be great if you have a line like: `fn convert(x: foo::Something) -> bar::Something` - the second `Something` is a different symbol, but is inacessible to these tools. Probably fine for now, but we can look into improving Release Notes: - Added: New tools for the Zed Agent for interacting with language servers --------- Co-authored-by: Lukas Wirth <me@lukaswirth.dev>
|
The agent seems surprised that the rename tool doesn't save the files it edits:
This caused it to have to do grep to find all unsaved files and then save them one by one or simply do the edits again manually. It probably spent as much time trying to recover form this as it would have if it did all the edits traditionally. This should probably be addressed if the tool it to be made generally available, either by having it save, letting it be an option, or making it clear to the agent that the tool doesn't save the changes. |
Adds 4 (technically 5) new tools to the zed agent, corresponding to LSP actions: - `find_references` - `goto_definition` - `rename_symbol` - `get_code_actions` and `apply_code_actions` Notes: - `rename_symbol` skips doing a `prepare_rename`. If there is nothing to rename at the position, it will forward the error to the agent - The code action tools are stateful. The state is stored in the `get_code_actions` tool itself as a `PendingCodeActions`. It is not passed into/out of subagents. Calling `apply_code_actions` without calling `get_code_actions` first is an error, but I've never seen an agent do this Symbols are identified by: - file name - line number - symbol If there is no substring match on that line for the symbol text, it is an error. If there are multiple, it chooses the first. This may not be great if you have a line like: `fn convert(x: foo::Something) -> bar::Something` - the second `Something` is a different symbol, but is inacessible to these tools. Probably fine for now, but we can look into improving Release Notes: - Added: New tools for the Zed Agent for interacting with language servers --------- Co-authored-by: Lukas Wirth <me@lukaswirth.dev>
Adds 4 (technically 5) new tools to the zed agent, corresponding to LSP actions: - `find_references` - `goto_definition` - `rename_symbol` - `get_code_actions` and `apply_code_actions` Notes: - `rename_symbol` skips doing a `prepare_rename`. If there is nothing to rename at the position, it will forward the error to the agent - The code action tools are stateful. The state is stored in the `get_code_actions` tool itself as a `PendingCodeActions`. It is not passed into/out of subagents. Calling `apply_code_actions` without calling `get_code_actions` first is an error, but I've never seen an agent do this Symbols are identified by: - file name - line number - symbol If there is no substring match on that line for the symbol text, it is an error. If there are multiple, it chooses the first. This may not be great if you have a line like: `fn convert(x: foo::Something) -> bar::Something` - the second `Something` is a different symbol, but is inacessible to these tools. Probably fine for now, but we can look into improving Release Notes: - Added: New tools for the Zed Agent for interacting with language servers --------- Co-authored-by: Lukas Wirth <me@lukaswirth.dev>
Adds 4 (technically 5) new tools to the zed agent, corresponding to LSP actions:
find_referencesgoto_definitionrename_symbolget_code_actionsandapply_code_actionsNotes:
rename_symbolskips doing aprepare_rename. If there is nothing to rename at the position, it will forward the error to the agentget_code_actionstool itself as aPendingCodeActions. It is not passed into/out of subagents. Callingapply_code_actionswithout callingget_code_actionsfirst is an error, but I've never seen an agent do thisSymbols are identified by:
If there is no substring match on that line for the symbol text, it is an error. If there are multiple, it chooses the first. This may not be great if you have a line like:
fn convert(x: foo::Something) -> bar::Something- the secondSomethingis a different symbol, but is inacessible to these tools. Probably fine for now, but we can look into improvingRelease Notes: