agent: Fix edit file always failing when using DeepSeek v4 Pro - #55841
Closed
Alejandro-HUB wants to merge 3 commits into
Closed
Conversation
…s-when-using-DeepSeek-V4-Pro
|
We require contributors to sign our Contributor License Agreement, and we don't have @Alejandro-HUB on file. You can sign our CLA at https://zed.dev/cla. Once you've signed, post a comment here that says '@cla-bot check'. |
Author
|
@cla-bot check |
|
The cla-bot has been summoned, and re-checked this pull request! |
…ile-always-fails-when-using-DeepSeek-V4-Pro
Member
|
Hey, thanks for working on this and finding the cause of the issue. The code here does not work for the case where we receive both old_text and new_text in the same chunk. I made a PR to handle both cases (new_text appearing first, new_text appearing with old_text) here #55894, closing. |
Alejandro-HUB
deleted the
#55398---edit_file-always-fails-when-using-DeepSeek-V4-Pro
branch
May 6, 2026 18:58
Author
|
@bennetbo I see; I didn't consider the case where both are received in the same chunk. Excited to see your PR merged so that DeepSeek can operate as expected. 👍 |
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
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.
Fix premature old_text finalization when model streams fields out of order
The streaming parser for the
edit_filetool usednew_text'spresence as a signal that
old_textwas complete, emitting it withdone: true. This fails when models stream JSON fields out of schemaorder — specifically DeepSeek V4 Pro, which can emit
new_textbeforeold_texthas been fully received.When this happens,
old_textgets finalized as""(the partial JSONfixer closing an incomplete string), the real value arriving in later
chunks is silently ignored, and the fuzzy matcher finds no match.
The fix: only finalize
old_textduring streaming if actual content hasbeen emitted (
old_text_emitted_len > 0) or the value is non-empty.Empty
old_textwithnew_textpresent is deferred tofinalize_edits,which has the complete data.
Release Notes:
edit_filetool failing with "Could not find matching text"when using DeepSeek V4 Pro
Closes #55398