on main help sign in
fix:remove 100MB file size limit from download tool (#1631)
commitc822651c9bfe6071fe6d29c1f470c9221faf0613 authorGustave-241021 <2909789120@qq.com> dateMon 15 Dec 2025, 20:00 (1 year ago) parentb1d93eb
1 file changed+4−16
internal/agent/tools/download.go+4−16
internal/agent/tools/download.go+4−16
@@ -114,12 +114,6 @@ func NewDownloadTool(permissions permission.Service, workingDir string, client *
114114 return fantasy.NewTextErrorResponse(fmt.Sprintf("Request failed with status code: %d", resp.StatusCode)), nil
115115 }
116116
117− // Check content length if available
118− maxSize := int64(100 * 1024 * 1024) // 100MB
119− if resp.ContentLength > maxSize {
120− return fantasy.NewTextErrorResponse(fmt.Sprintf("File too large: %d bytes (max %d bytes)", resp.ContentLength, maxSize)), nil
121− }
122−
123117 // Create parent directories if they don't exist
124118 if err := os.MkdirAll(filepath.Dir(filePath), 0o755); err != nil {
125119 return fantasy.ToolResponse{}, fmt.Errorf("failed to create parent directories: %w", err)
@@ -132,20 +126,14 @@ func NewDownloadTool(permissions permission.Service, workingDir string, client *
132126 }
133127 defer outFile.Close()
134128
135− // Copy data with size limit
136− limitedReader := io.LimitReader(resp.Body, maxSize)
137− bytesWritten, err := io.Copy(outFile, limitedReader)
129+ // Copy data without an explicit size limit.
130+ // The overall download is still constrained by the HTTP client's timeout
131+ // and any upstream server limits.
132+ bytesWritten, err := io.Copy(outFile, resp.Body)
138133 if err != nil {
139134 return fantasy.ToolResponse{}, fmt.Errorf("failed to write file: %w", err)
140135 }
141136
142− // Check if we hit the size limit
143− if bytesWritten == maxSize {
144− // Clean up the file since it might be incomplete
145− os.Remove(filePath)
146− return fantasy.NewTextErrorResponse(fmt.Sprintf("File too large: exceeded %d bytes limit", maxSize)), nil
147− }
148−
149137 contentType := resp.Header.Get("Content-Type")
150138 responseMsg := fmt.Sprintf("Successfully downloaded %d bytes to %s", bytesWritten, relPath)
151139 if contentType != "" {