@@ -16,7 +16,10 @@ import (
1616 "github.com/charmbracelet/crush/internal/permission"
1717)
1818
19−const FetchToolName = "fetch"
19+const (
20+ FetchToolName = "fetch"
21+ MaxFetchSize = 1 * 1024 * 1024 // 1MB
22+)
2023
2124//go:embed fetch.md
2225var fetchDescription []byte
@@ -105,11 +108,7 @@ func NewFetchTool(permissions permission.Service, workingDir string, client *htt
105108 return fantasy.NewTextErrorResponse(fmt.Sprintf("Request failed with status code: %d", resp.StatusCode)), nil
106109 }
107110
108− // maxFetchResponseSizeBytes is the maximum size of response body to read (5MB)
109− const maxFetchResponseSizeBytes = int64(5 * 1024 * 1024)
110−
111− maxSize := maxFetchResponseSizeBytes
112− body, err := io.ReadAll(io.LimitReader(resp.Body, maxSize))
111+ body, err := io.ReadAll(io.LimitReader(resp.Body, MaxFetchSize))
113112 if err != nil {
114113 return fantasy.NewTextErrorResponse("Failed to read response body: " + err.Error()), nil
115114 }
@@ -161,9 +160,9 @@ func NewFetchTool(permissions permission.Service, workingDir string, client *htt
161160 }
162161 }
163162 // truncate content if it exceeds max read size
164− if int64(len(content)) > MaxReadSize {
165− content = content[:MaxReadSize]
166− content += fmt.Sprintf("\n\n[Content truncated to %d bytes]", MaxReadSize)
163+ if int64(len(content)) > MaxFetchSize {
164+ content = content[:MaxFetchSize]
165+ content += fmt.Sprintf("\n\n[Content truncated to %d bytes]", MaxFetchSize)
167166 }
168167
169168 return fantasy.NewTextResponse(content), nil