Skip to content

Conversation

@nathansobo
Copy link
Contributor

@nathansobo nathansobo commented Dec 16, 2025

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
When an in-progress edit is cancelled, the buffer would be modified but
not saved to disk. This happened because the save_buffer call occurs
after the edit completes, but cancellation drops the task before reaching
that point.

Added a save_on_cancel defer that checks if the buffer is dirty when the
task is dropped, and saves it if so. Uses abort() before the normal save
path to avoid double-saving on successful completion.

Includes test that verifies the file is saved when edit task is cancelled
mid-stream.
This re-introduces the save_file and restore_file_from_disk agent tools
that were reverted in #44949. The revert was needed to unblock the build,
but the actual issue was a missed step: the tools weren't added to the
default profile settings in default.json.

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
- Update test to match new conditional error message behavior
@cla-bot cla-bot bot added the cla-signed The user has signed the Contributor License Agreement label Dec 16, 2025
@nathansobo nathansobo merged commit 420254c into main Dec 16, 2025
26 checks passed
@nathansobo nathansobo deleted the fix-save-on-cancel branch December 16, 2025 16:18
LivioGama pushed a commit to LivioGama/zed that referenced this pull request Jan 20, 2026
…es#45005)

This re-introduces the `save_file` and `restore_file_from_disk` agent
tools that were reverted in zed-industries#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
LivioGama pushed a commit to LivioGama/zed that referenced this pull request Jan 20, 2026
…es#45005)

This re-introduces the `save_file` and `restore_file_from_disk` agent
tools that were reverted in zed-industries#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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

cla-signed The user has signed the Contributor License Agreement

2 participants