feat(file): cap read_file/edit_file size to prevent OOM (N5)

This commit is contained in:
sausheong committed 2026-06-13 11:27:34 +08:00
1 parent 01b55a1446
commit fb5103fb87
4 files changed
+112 -2

No files matched your search

+4
View File
@@ -74,6 +74,10 @@ func (t *EditFileTool) Execute(_ context.Context, input json.RawMessage) (tool.T
}
}
if msg := checkFileSize(in.Path, int64(maxTextFileSize), "text"); msg != "" {
return tool.ToolResult{Error: msg}, nil
}
data, err := os.ReadFile(in.Path)
if err != nil {
return tool.ToolResult{Error: fmt.Sprintf("failed to read file: %v", err)}, nil