From a5822222909b785f23ddc74ce3c8f85bd0e38562 Mon Sep 17 00:00:00 2001 From: Pascal Date: Wed, 15 Jul 2026 13:46:46 +0200 Subject: [PATCH] server: fix read_file append_loc space breaking edit_file match (#25705) read_file with append_loc emits "{n}\u2192 {line}". The space after the arrow is meant as a separator, but it is indistinguishable from real indentation. Models strip "{n}\u2192" yet keep the space, so the old_text passed to edit_file carries a phantom leading space and never matches (normalize_for_fuzzy_match trims trailing whitespace only, never leading). Drop the separator space so the arrow abuts content: stripping "{n}\u2192" now yields the exact line with its real indentation preserved, and the failure mode cannot occur by construction. Update the description example to match the new format. --- tools/server/server-tools.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tools/server/server-tools.cpp b/tools/server/server-tools.cpp index a8216d7db..9eb57abae 100644 --- a/tools/server/server-tools.cpp +++ b/tools/server/server-tools.cpp @@ -289,7 +289,7 @@ struct server_tool_read_file : server_tool { {"function", { {"name", name}, {"description", "Read the contents of a file. Optionally specify a 1-based line range. " - "If append_loc is true, each line is prefixed with its line number (e.g. \"1\u2192 ...\")."}, + "If append_loc is true, each line is prefixed with its line number (e.g. \"1\u2192...\")."}, {"parameters", { {"type", "object"}, {"properties", { @@ -339,7 +339,7 @@ struct server_tool_read_file : server_tool { std::string out_line; if (append_loc) { - out_line = std::to_string(lineno) + "\u2192 " + line + "\n"; + out_line = std::to_string(lineno) + "\u2192" + line + "\n"; } else { out_line = line + "\n"; }