Raise WebFetchTool's output cap to ~1M tokens

MaxOutputLength was 50,000 chars, truncating fetched pages to a few
paragraphs well before hitting any model's context window. Match Sonnet
5's 1M-token context using this codebase's 4-chars/token estimate
(session.Session.EstimateTokens), and raise the raw HTTP read cap
(maxFetchSize) to 8MB so plain-text/JSON responses that don't shrink
during HTML->markdown conversion aren't cut short before the output cap
even applies.
This commit is contained in:
sausheong committed 2026-09-22 17:45:40 +08:00
1 parent 1e5b6599bb
commit 9a013f6f4b
1 file changed
+6 -3
+6 -3
View File
@@ -14,9 +14,12 @@ import (
)
const (
maxFetchSize = 5 * 1024 * 1024 // 5MB
fetchTimeout = 30 * time.Second
MaxOutputLength = 50000 // truncate very long pages
maxFetchSize = 8 * 1024 * 1024 // 8MB raw read; headroom over MaxOutputLength since HTML->markdown shrinks most pages but plain text/JSON responses pass through near 1:1
fetchTimeout = 30 * time.Second
// MaxOutputLength caps fetched content at roughly 1M tokens, matching
// Sonnet 5's context window, using this codebase's own token estimate
// of 4 chars/token (see session.Session.EstimateTokens).
MaxOutputLength = 4_000_000
)
// WebFetchTool fetches a URL and returns its content as markdown.