diff --git a/internal/agent/tools/download.go b/internal/agent/tools/download.go index 23bebcd602a82d8f8db1d0c99d5e7d5c53c48767..353b312a29d410c6485f76fc8dd42a4b9dcdefb1 100644 --- a/internal/agent/tools/download.go +++ b/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 != "" {