feat: make webfetch max response size configurable - #46812
RaviTharuma wants to merge 12 commits into
Conversation
Prefer config webfetch.max_response_size when set, else a positive-int OPENCODE_WEBFETCH_MAX_SIZE, else the 5MB default so #15459 is fully closed. Signed-off-by: Ravi Tharuma <RaviTharuma@users.noreply.github.com>
|
The following comment was made by an LLM, it may be inaccurate: I found one potentially related PR: PR #45937:
You may want to check if PR #45937 is already merged or if there's any overlap in the functionality being addressed. |
There was a problem hiding this comment.
🟡 Changes recommended
The new configurable size limit still allows fully buffering oversized responses (when Content-Length is missing/incorrect) and needs input validation/error-message improvements to make the feature reliable and diagnosable.
Once you've addressed the issues Copilot identified, you can request another Copilot review.
Pull request overview
Adds configuration support for WebFetch’s maximum HTTP response size so users can raise the previous 5MB hard-cap via ConfigV1 and an environment variable, while keeping the default at 5MB.
Changes:
- Introduces
webfetch.max_response_sizein ConfigV1 (bytes, positive int) with a default of 5MB. - Updates the
webfetchtool to resolve the limit from config/env and enforce it during fetch. - Adds unit tests for
resolveMaxResponseSizeprecedence and env parsing behavior.
File summaries
| File | Description |
|---|---|
| packages/opencode/src/tool/webfetch.ts | Adds max-response-size resolution (config/env/default) and applies it to WebFetch size checks. |
| packages/opencode/test/tool/webfetch.test.ts | Adds unit tests for limit resolution behavior and env var handling. |
| packages/core/src/v1/config/config.ts | Extends ConfigV1 schema with webfetch.max_response_size (PositiveInt, bytes) and documentation. |
Review details
- Files reviewed: 3/3 changed files
- Comments generated: 3
- Review effort level: Lite
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
|
@copilot-pull-request-reviewer re-review: Content-Length is enforced before buffering; PositiveInt config rejects 0/negative; oversized error text is the existing webfetch message with the configured cap. |
Add webfetch.max_response_size (config) and OPENCODE_WEBFETCH_MAX_SIZE (env) overrides. Default remains 5MB; invalid env values fall back. Fork repair for #57 — tip still lacked sealed anomalyco#46799/anomalyco#46812.
Issue for this PR
Closes #15459
Type of change
What does this PR do?
Webfetch currently hard-caps the HTTP body at 5MB. This PR adds
webfetch.max_response_sizein ConfigV1 (positive int, bytes). The default stays 5MB. Larger pages can be fetched without editing source.How did you verify your code works?
Unit tests for
resolveMaxResponseSizein packages/opencode.Screenshots / recordings
N/A — not a UI change.
Checklist