Skip to content

webfetch: cap the page and let the model say what it is looking for - #117

Merged
its-janghoon merged 2 commits into
developfrom
perf/webfetch-focus
Oct 16, 2026
Merged

its-janghoon merged 2 commits into
developfrom
perf/webfetch-focus

Conversation

@its-janghoon

Copy link
Copy Markdown
Member

What's done

webfetch gains query (keywords; only the lines around matches are returned, 8 lines of context, gaps marked [...]) and max_chars (default 12,000; longer content is cut with a note saying the total size and how to see more). Implemented as a pure helper in webfetch-focus.ts, applied to text/markdown/html outputs; image fetches unchanged. Tool description updated so the model knows to pass query.

Why

In a 10-task benchmark (same prompts, claude-opus-5, medium), the two web-research tasks pulled 25k and 35k characters into context with single webfetch calls (~15k tokens), re-sent on every later step. The generic tool-output cap is 50 KB, so nothing stopped it. Capping at 12k characters and focusing on the question cuts the carried context by roughly two thirds on those tasks at no loss to the answer (the checker still passes on the same prompts).

What's not done

No change to websearch (Exa already takes contextMaxCharacters, default 10k) and no change to read. Not re-benchmarked end to end against the Console yet: wall time there is dominated by Console per-request latency (separate PR in redrob-console #276), so the measurable effect of this change is tokens, not seconds.

What to review

focus() in webfetch-focus.ts: term splitting (whitespace/commas, terms under 2 chars dropped), the context window, and the wording of the notes the model reads.

Intentions

Smaller per-step context on research turns; follow with the same query parameter on read for very large files if the numbers justify it.

A fetched page converted to markdown is routinely 25-35k characters, and in the benchmark runs
(10 tasks, claude-opus-5) the two research tasks pulled 25k and 35k characters into the context
in single webfetch calls, which every later step of the turn then re-sent. The tool now takes
`query` (keywords; only the lines around matches come back, with eight lines of context and the
gaps marked) and `max_chars` (default 12,000; longer content is cut with a note that says how much
there was and how to see more). Images and the fetch itself are unchanged; the generic 50 KB
tool-output cap still applies after this.
@its-janghoon
its-janghoon merged commit ae689ad into develop Oct 16, 2026
27 of 28 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant