fix:remove 100MB file size limit from download tool (#1631)

Gustave-241021 created

Change summary

internal/agent/tools/download.go | 20 ++++----------------
1 file changed, 4 insertions(+), 16 deletions(-)

Detailed changes

internal/agent/tools/download.go 🔗

@@ -114,12 +114,6 @@ func NewDownloadTool(permissions permission.Service, workingDir string, client *
 				return fantasy.NewTextErrorResponse(fmt.Sprintf("Request failed with status code: %d", resp.StatusCode)), nil
 			}
 
-			// Check content length if available
-			maxSize := int64(100 * 1024 * 1024) // 100MB
-			if resp.ContentLength > maxSize {
-				return fantasy.NewTextErrorResponse(fmt.Sprintf("File too large: %d bytes (max %d bytes)", resp.ContentLength, maxSize)), nil
-			}
-
 			// Create parent directories if they don't exist
 			if err := os.MkdirAll(filepath.Dir(filePath), 0o755); err != nil {
 				return fantasy.ToolResponse{}, fmt.Errorf("failed to create parent directories: %w", err)
@@ -132,20 +126,14 @@ func NewDownloadTool(permissions permission.Service, workingDir string, client *
 			}
 			defer outFile.Close()
 
-			// Copy data with size limit
-			limitedReader := io.LimitReader(resp.Body, maxSize)
-			bytesWritten, err := io.Copy(outFile, limitedReader)
+			// Copy data without an explicit size limit.
+			// The overall download is still constrained by the HTTP client's timeout
+			// and any upstream server limits.
+			bytesWritten, err := io.Copy(outFile, resp.Body)
 			if err != nil {
 				return fantasy.ToolResponse{}, fmt.Errorf("failed to write file: %w", err)
 			}
 
-			// Check if we hit the size limit
-			if bytesWritten == maxSize {
-				// Clean up the file since it might be incomplete
-				os.Remove(filePath)
-				return fantasy.NewTextErrorResponse(fmt.Sprintf("File too large: exceeded %d bytes limit", maxSize)), nil
-			}
-
 			contentType := resp.Header.Get("Content-Type")
 			responseMsg := fmt.Sprintf("Successfully downloaded %d bytes to %s", bytesWritten, relPath)
 			if contentType != "" {