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
@@ -72,7 +72,7 @@ func detectImageMIMEFromBytes(data []byte, hint string) string {
|
||||
// IsConcurrencySafe returns true — read_file is a pure read.
|
||||
func (t *ReadFileTool) IsConcurrencySafe(_ json.RawMessage) bool { return true }
|
||||
|
||||
func (t *ReadFileTool) Execute(_ context.Context, input json.RawMessage) (tool.ToolResult, error) {
|
||||
func (t *ReadFileTool) Execute(ctx context.Context, input json.RawMessage) (tool.ToolResult, error) {
|
||||
var in readFileInput
|
||||
if err := json.Unmarshal(input, &in); err != nil {
|
||||
return tool.ToolResult{Error: fmt.Sprintf("invalid input: %v", err)}, nil
|
||||
@@ -94,6 +94,10 @@ func (t *ReadFileTool) Execute(_ context.Context, input json.RawMessage) (tool.T
|
||||
}
|
||||
}
|
||||
|
||||
if err := ctx.Err(); err != nil {
|
||||
return tool.ToolResult{Error: err.Error()}, nil
|
||||
}
|
||||
|
||||
ext := strings.ToLower(filepath.Ext(in.Path))
|
||||
limit := int64(maxTextFileSize)
|
||||
kind := "text"
|
||||
|
||||
Reference in new issue
Block a user