-
-
Notifications
You must be signed in to change notification settings - Fork 6.8k
Re-add save_file and restore_file_from_disk agent tools #45005
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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
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
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This re-introduces the
save_fileandrestore_file_from_diskagent 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
save_fileandrestore_file_from_diskto the "write" profile indefault.jsonThread::has_tool()method to check tool availability at runtimeedit_file_tool's dirty buffer error message conditional on whethersave_file/restore_file_from_disktools are available (so the agent gets appropriate guidance based on what tools it actually has)Release Notes:
save_fileandrestore_file_from_diskagent tools to handle dirty buffers when editing files