@@ -114,12 +114,6 @@ func NewDownloadTool(permissions permission.Service, workingDir string, client *
114 return fantasy.NewTextErrorResponse(fmt.Sprintf("Request failed with status code: %d", resp.StatusCode)), nil
114 return fantasy.NewTextErrorResponse(fmt.Sprintf("Request failed with status code: %d", resp.StatusCode)), nil
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
123 // Create parent directories if they don't exist
117 // Create parent directories if they don't exist
124 if err := os.MkdirAll(filepath.Dir(filePath), 0o755); err != nil {
118 if err := os.MkdirAll(filepath.Dir(filePath), 0o755); err != nil {
125 return fantasy.ToolResponse{}, fmt.Errorf("failed to create parent directories: %w", err)
119 return fantasy.ToolResponse{}, fmt.Errorf("failed to create parent directories: %w", err)
@@ -132,20 +126,14 @@ func NewDownloadTool(permissions permission.Service, workingDir string, client *
133 defer outFile.Close()
127 defer outFile.Close()
135− // Copy data with size limit
129+ // Copy data without an explicit size limit.
136− limitedReader := io.LimitReader(resp.Body, maxSize)
130+ // The overall download is still constrained by the HTTP client's timeout
131+ // and any upstream server limits.
137− bytesWritten, err := io.Copy(outFile, limitedReader)
132+ bytesWritten, err := io.Copy(outFile, resp.Body)
138 if err != nil {
133 if err != nil {
139 return fantasy.ToolResponse{}, fmt.Errorf("failed to write file: %w", err)
134 return fantasy.ToolResponse{}, fmt.Errorf("failed to write file: %w", err)
142− // Check if we hit the size limit
143− if bytesWritten == maxSize {
144− // Clean up the file since it might be incomplete
146− return fantasy.NewTextErrorResponse(fmt.Sprintf("File too large: exceeded %d bytes limit", maxSize)), nil
149 contentType := resp.Header.Get("Content-Type")
137 contentType := resp.Header.Get("Content-Type")
150 responseMsg := fmt.Sprintf("Successfully downloaded %d bytes to %s", bytesWritten, relPath)
138 responseMsg := fmt.Sprintf("Successfully downloaded %d bytes to %s", bytesWritten, relPath)
151 if contentType != "" {
139 if contentType != "" {