fix(file): honor ctx cancellation in read_file/edit_file (N12)
This commit is contained in:
1 parent
e133f97e1e
commit
1752cbf2fb
3 files changed
+36
-2
No files matched your search
@@ -52,7 +52,7 @@ func (t *EditFileTool) Parameters() json.RawMessage {
|
||||
// IsConcurrencySafe returns false — edit_file mutates the filesystem.
|
||||
func (t *EditFileTool) IsConcurrencySafe(_ json.RawMessage) bool { return false }
|
||||
|
||||
func (t *EditFileTool) Execute(_ context.Context, input json.RawMessage) (tool.ToolResult, error) {
|
||||
func (t *EditFileTool) Execute(ctx context.Context, input json.RawMessage) (tool.ToolResult, error) {
|
||||
var in editFileInput
|
||||
if err := json.Unmarshal(input, &in); err != nil {
|
||||
return tool.ToolResult{Error: fmt.Sprintf("invalid input: %v", err)}, nil
|
||||
@@ -74,6 +74,10 @@ func (t *EditFileTool) Execute(_ context.Context, input json.RawMessage) (tool.T
|
||||
}
|
||||
}
|
||||
|
||||
if err := ctx.Err(); err != nil {
|
||||
return tool.ToolResult{Error: err.Error()}, nil
|
||||
}
|
||||
|
||||
if msg := checkFileSize(in.Path, int64(maxTextFileSize), "text"); msg != "" {
|
||||
return tool.ToolResult{Error: msg}, nil
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user