You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
// Belt and braces for the file growing between the metadata check and the
860
+
// snapshot read.
861
+
if prior.len() > APPEND_FILE_INLINE_DIFF_LIMIT_BYTES{
862
+
returnformat!(
863
+
"{summary}\n\
864
+
[diff omitted] {path} is too large for an inline append_file diff \
865
+
(old={} bytes, limit={} bytes). Use read_file with line ranges to inspect it.",
866
+
prior.len(),
867
+
APPEND_FILE_INLINE_DIFF_LIMIT_BYTES
868
+
);
869
+
}
870
+
let new_contents = format!("{prior}{append_content}");
871
+
let diff = make_unified_diff(path, prior,&new_contents);
872
+
if diff.is_empty(){
873
+
summary.to_string()
874
+
}else{
875
+
format!("{diff}\n{summary}")
876
+
}
877
+
}
878
+
824
879
// === AppendFileTool ===
825
880
826
881
/// Tool for appending UTF-8 content to files in the workspace.
@@ -833,7 +888,7 @@ impl ToolSpec for AppendFileTool {
833
888
}
834
889
835
890
fndescription(&self) -> &'staticstr{
836
-
"Append UTF-8 content to a file in the workspace. Use this for large generated artifacts after creating a small skeleton with write_file, instead of trying to send one huge write_file content argument. **Recommended chunk size ≤ 16KB, hard limit 64KB per call** to keep tool-arg size small and avoid SSE-timeout-on-slow-decoders failures. Creates parent directories and the target file if needed. Returns a compact byte-count summary, not a full diff."
891
+
"Append UTF-8 content to a file in the workspace. Use this for large generated artifacts after creating a small skeleton with write_file, instead of trying to send one huge write_file content argument. **Recommended chunk size ≤ 16KB, hard limit 64KB per call** to keep tool-arg size small and avoid SSE-timeout-on-slow-decoders failures. Creates parent directories and the target file if needed. Returns a compact unified diff of the appended chunk (omitted when the existing file is very large) plus a byte-count summary."
837
892
}
838
893
839
894
fninput_schema(&self) -> Value{
@@ -894,6 +949,18 @@ impl ToolSpec for AppendFileTool {
894
949
895
950
let existed_before = file_path.exists();
896
951
let before_len = fs::metadata(&file_path).map(|m| m.len()).unwrap_or(0);
952
+
// Snapshot the existing contents before appending — used to render an
953
+
// inline diff in the tool result (same renderer path as write_file).
954
+
// Gate on the metadata size first: appending to a huge file must not
955
+
// pull the whole file into memory just to decide the diff is omitted.
956
+
// A non-UTF-8 existing file can't be diffed as text → skip the diff.
0 commit comments