feat(file): cap read_file/edit_file size to prevent OOM (N5)
This commit is contained in:
1 parent
01b55a1446
commit
fb5103fb87
4 files changed
+112
-2
No files matched your search
@@ -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
|
||||
|
||||
Reference in new issue
Block a user