]> git.djapps.eu Git - pkg/ggml/sources/llama.cpp/commitdiff
server: fix read_file append_loc space breaking edit_file match (#25705)
authorPascal <redacted>
Wed, 15 Jul 2026 11:46:46 +0000 (13:46 +0200)
committerGitHub <redacted>
Wed, 15 Jul 2026 11:46:46 +0000 (13:46 +0200)
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

index a8216d7dbc54f886592e1dcc6c3bd0c0f5b6119c..9eb57abaea15245d7fa9495697b0fc1558770dac 100644 (file)
@@ -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";
             }