From 9a013f6f4bacf7cd858e87219328f4a19313d92b Mon Sep 17 00:00:00 2001 From: sausheong Date: Tue, 22 Sep 2026 17:45:40 +0800 Subject: [PATCH] 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. --- tools/web/webfetch.go | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/tools/web/webfetch.go b/tools/web/webfetch.go index 71f70b6..3dd63d0 100644 --- a/tools/web/webfetch.go +++ b/tools/web/webfetch.go @@ -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.