Commit graph

23 commits

Author SHA1 Message Date
Bennet Bo Fenner
e78ddcac8d
agent: Improve UX when agent tries to edit unsaved buffer (#55655)
Before:

1. Agent tries to edit unsaved file
2. Tool call fails with error telling the agent to ask the user to save
or discard edits
3. User types save/restore
4. Agent uses save/restore tool


https://github.com/user-attachments/assets/c94dd361-e8e0-48ee-be31-da8afe594419

After:

1. Agent tries to edit unsaved file
2. User is prompted to save/restore file
3. User accepts/rejects or saves/discards file manually


https://github.com/user-attachments/assets/1d98a0c4-4420-4426-94f2-42355de230be

Release Notes:

- agent: Improved UX when agent tries to edit unsaved buffer

---------

Co-authored-by: Ben Brandt <benjamin.j.brandt@gmail.com>
2026-05-08 11:26:03 +00:00
Bennet Bo Fenner
70ee54da8f
agent: Add write_file tool (#55865)
Splits the edit tool into two separate tools `write_file` (previously
`mode = write`), and `edit_file` (previously `mode = edit`).
This makes the JSON schema for the `edit_tool` much simpler. We've seen
models (especially older ones) struggle with providing `mode = edit +
edits` and `mode = write + content` fields. This seems to improve eval
scores for Sonnet 4.6 slightly.

Also added two unit evals to ensure that the model uses the tool to
create new/override existing files

Release Notes:

- N/A

---------

Co-authored-by: Ben Brandt <benjamin.j.brandt@gmail.com>
2026-05-06 15:47:18 +00:00
Bennet Bo Fenner
02af528c5a
agent: Allow model to provide stringified timezone in now tool (#55776)
See
https://github.com/zed-industries/zed/issues/55186#issuecomment-4376114420

I think the recent changes to the tool schema in #55763 will make this
more unlikely, but does not hurt to allow the model to provide `"utc"`.

Release Notes:

- N/A
2026-05-05 14:40:43 +00:00
Cameron Mcloughlin
f482f9e18c
agent: LSP tools (#55744)
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>
2026-05-05 09:35:08 +00:00
Bennet Bo Fenner
8f2ab516d0
agent: Refactor edit file tool state handling (#55663)
Ports some changes introduced in #51165 out to make merge conflicts
easier to handle.

Splits the `Pipeline` into two separate types for mode edit/write so we
don't need to maintain that invariant inside the pipeline/in the parser

Also moves the parser to be a submodule of `edit_file_tool`

Release Notes:

- N/A
2026-05-04 15:45:06 +00:00
Bennet Bo Fenner
9cbdc46d96
agent: Remove old edit file tool (#55612)
Self-Review Checklist:

- [x] I've reviewed my own diff for quality, security, and reliability
- [x] Unsafe blocks (if any) have justifying comments
- [x] The content is consistent with the [UI/UX
checklist](https://github.com/zed-industries/zed/blob/main/CONTRIBUTING.md#uiux-checklist)
- [x] Tests cover the new/changed behavior
- [x] Performance impact has been considered and is acceptable

Closes #ISSUE

Release Notes:

- agent: Improve reliability when LLM edits file
2026-05-04 09:54:39 +00:00
Ben Brandt
b1e94da0d7
eval: Port over evals for streaming edit tool (#52317)
Setting up the infra for unit evals on the new tool. For now,
replicating the eval setup as close as possible to the old tool.


## Self-Review Checklist

<!-- Check before requesting review: -->
- [x] I've reviewed my own diff for quality, security, and reliability
- [x] Unsafe blocks (if any) have justifying comments
- [x] The content is consistent with the [UI/UX
checklist](https://github.com/zed-industries/zed/blob/main/CONTRIBUTING.md#uiux-checklist)
- [x] Tests cover the new/changed behavior
- [x] Performance impact has been considered and is acceptable

Release Notes:

- N/A
2026-03-24 21:28:17 +01:00
Ben Brandt
b99200fbaf
agent: Add update_plan tool (#52048)
## Context

Adds a tool to utilize the UI we already expose to ACP agents. Behind a
feature flag for now.

## How to Review

Mostly a tool to hook up to all of the plan plumbing we already have in
acp thread.

## Self-Review Checklist

- [x] I've reviewed my own diff for quality, security, and reliability
- [x] Unsafe blocks (if any) have justifying comments
- [x] The content is consistent with the [UI/UX
checklist](https://github.com/zed-industries/zed/blob/main/CONTRIBUTING.md#uiux-checklist)
- [x] Tests cover the new/changed behavior
- [x] Performance impact has been considered and is acceptable

Release Notes:

- N/A
2026-03-20 23:03:32 +00:00
Bennet Bo Fenner
c9425f2a90
agent: Stream new_text in StreamingEditFileTool (#50240)
We now stream the new text into the buffer as soon as we receive partial
chunks of `new_text`. This is pretty much a full re-write of the way
streaming worked, which is now much closer to how the edit agent works:
- `ToolEditParser` buffers chunks as they stream in, and emits relevant
events (`OldTextChunk`,`NewTextChunk`, ...) that we use to power the
`EditSession` pipeline.
- `EditSession::process_events` takes care of consuming these events and
applying the edits incrementally as chunks stream in. `EditPipeline`
maintains the underlying state machine for each edit.
- We handle whitespace mismatches similar to the edit agent, the code is
shared by moving that logic to `reindent.rs`

Before you mark this PR as ready for review, make sure that you have:
- [x] Added a solid test coverage and/or screenshots from doing manual
testing
- [x] Done a self-review taking into account security and performance
aspects
- [x] Aligned any UI changes with the [UI
checklist](https://github.com/zed-industries/zed/blob/main/CONTRIBUTING.md#uiux-checklist)

Release Notes:

- N/A
2026-02-27 13:24:57 +01:00
Bennet Bo Fenner
a2e34cb7bf
agent: Implement streaming for edit file tool (#50004)
Before you mark this PR as ready for review, make sure that you have:
- [x] Added a solid test coverage and/or screenshots from doing manual
testing
- [x] Done a self-review taking into account security and performance
aspects
- [x] Aligned any UI changes with the [UI
checklist](https://github.com/zed-industries/zed/blob/main/CONTRIBUTING.md#uiux-checklist)

Release Notes:

- N/A

---------

Co-authored-by: Zed Zippy <234243425+zed-zippy[bot]@users.noreply.github.com>
2026-02-25 22:58:25 +00:00
Ben Brandt
66bdb116d0
agent: Change tool name to spawn_agent (#49741)
After looking around a bit, I felt like subagent wasn't the right way to
introduce this tool to the model. And with some back and forth
verification + market research, we both agreed spawn_agent was a better
name for what this tool is doing.

It still calls the right tool if you ask for a subagent, but especially
if we move these to be running in the background, spawn will be a better
name anyway.

Release Notes:

- N/A
2026-02-20 18:51:37 +00:00
Ben Brandt
24dbd216d7
agent: Prompt for permission for symlinks outside the project (#49255)
It's possible that a given project/workspace has symlinks that go
outside the current directories. In order to alert the user of some
potential files the agent is accessing they may not be expecting, we ask
for permission first.

Release Notes:

- agent: Prompt for permission if the agent tries to access files whose
symlinks resolve outside the current workspace
2026-02-16 10:39:40 +01:00
Richard Feldman
7ccd6976c4
Remove thinking tool (#48952)
Closes AI-10

The thinking tool is no longer needed. This removes it from the agent
codebase and updates all tests to use other tools instead.

Release Notes:

- Removed the thinking tool from the Agent, as models now have their own
first-class thinking APIs.
2026-02-11 16:22:20 -05:00
Richard Feldman
65da2c2c6a
Use AgentTool::NAME const instead of name() method and hardcoded strings (#48506)
This PR removes the `fn name()` default method from the `AgentTool`
trait (which just returned `Self::NAME`) and replaces all call sites
with direct use of the `NAME` associated constant. This lets us use it
as a single source of truth in macros that want to access it at compile
time.

This PR also replaces hardcoded tool name string literals throughout the
codebase with the corresponding `NAME` constants, so tool name
references stay in sync if a tool is renamed.

Intentionally not changed:

- **Display strings** like `"Thinking"` and `"Subagent"` (user-facing UI
labels)
- **Serde attributes** like `#[serde(rename = "thinking")]` (wire
format)
- **The test assertion** `assert_eq!(SubagentTool::NAME, "subagent")`
(replacing the literal would make it tautological)
- **MCP server names** like `"mcp:srv:terminal"` (not tool identifiers)

Release Notes:

- N/A
2026-02-05 19:28:28 +00:00
Michael Benfield
6b5c06e323
Add a streaming edit file tool (#47244)
Release Notes:

- N/A
2026-01-21 09:41:03 -08:00
Richard Feldman
581e559002
Render subagents in thread (#46188)
## Summary

This PR adds the UI for displaying subagent tool calls:

### Thread view changes
- Add `expanded_subagents` state HashMap for tracking expanded cards  
- Implement `render_subagent_tool_call()` for collapsed card with label
and chevron
- Add subagent detection via `is_subagent()` and `tool_name` field
- Handle `SubagentThread` content type in tool call rendering
- Add expand/collapse toggle button for subagent cards
- Style collapsed cards similar to terminal tool calls
- Support inline image rendering in content blocks

### Agent panel changes
- Add `open_external_thread_with_server()` for testing with stubbed
servers

### Test support
- Add `acp_thread/test-support` feature to agent_ui
- Add base64 dev dependency for image tests

Release Notes:

- N/A

---------

Co-authored-by: Amp <amp@ampcode.com>
2026-01-14 13:49:51 -05:00
Richard Feldman
acbb32d19f
Subagents PR 1: Feature flag + tool skeleton (#46186)
This PR adds the foundation for the subagents feature:

- Add `SubagentsFeatureFlag` with staff-disabled default
- Create `SubagentTool` struct with input schema for
task/summary/context-low prompts
- Register `SubagentTool` conditionally when feature flag is enabled
- Tool returns stub message 'not yet implemented' for now

Release Notes:

- N/A

---------

Co-authored-by: Amp <amp@ampcode.com>
Co-authored-by: Mikayla Maki <mikayla@zed.dev>
Co-authored-by: Yara <yara@zed.dev>
2026-01-08 22:53:02 -05:00
Nathan Sobo
420254cff1
Re-add save_file and restore_file_from_disk agent tools (#45005)
This re-introduces the `save_file` and `restore_file_from_disk` agent
tools that were reverted in #44949.

I pushed that original PR without trying it just to get the build off my
machine, but I had missed a step: the tools weren't added to the default
profile settings in `default.json`, so they were never enabled even
though the code was present.

## Changes

- Add `save_file` and `restore_file_from_disk` to the "write" profile in
`default.json`
- Add `Thread::has_tool()` method to check tool availability at runtime
- Make `edit_file_tool`'s dirty buffer error message conditional on
whether `save_file`/`restore_file_from_disk` tools are available (so the
agent gets appropriate guidance based on what tools it actually has)
- Update test to match new conditional error message behavior

Release Notes:

- Added `save_file` and `restore_file_from_disk` agent tools to handle
dirty buffers when editing files
2025-12-16 09:18:51 -07:00
Nathan Sobo
9c32c29238
Revert "Add save_file and restore_file_from_disk agent tools" (#44949)
Reverts zed-industries/zed#44789

Need to fix a bug

Release Notes:

- N/A
2025-12-16 09:53:08 +01:00
Nathan Sobo
5987dff7e4
Add save_file and restore_file_from_disk agent tools (#44789)
Release Notes:

- Added `save_file` and `restore_file_from_disk` tools to the agent,
allowing it to resolve dirty buffer conflicts when editing files. When
the agent encounters a file with unsaved changes, it will now ask
whether you want to keep or discard those changes before proceeding.
2025-12-15 15:15:09 -07:00
Michael Benfield
5cd30e5106
inline assistant: Use tools and remove insertion mode (#44248)
Co-authored by: Mikayla Maki <mikayla.c.maki@gmail.com>
Co-authored-by: Danilo Leal <daniloleal09@gmail.com>

Release Notes:

- N/A
2025-12-05 13:28:29 -08:00
Bennet Fenner
6622902964
agent: Only show compatible tools in profile selector (#40917)
In practice this just hides the web search tool when not using the Zed
provider

Release Notes:

- Fixed an issue where the web search tool would show up in the profile
selector even when not using a model via Zed Pro
2025-10-22 18:17:33 +00:00
Bennet Fenner
3f1319162a
Remove agent1 code (#40495)
Release Notes:

- N/A
2025-10-17 18:49:11 +02:00