feat: make webfetch max response size configurable - #46799
RaviTharuma wants to merge 2 commits into
Conversation
|
This PR doesn't fully meet our contributing guidelines and PR template. What needs to be fixed:
Please edit this PR description to address the above within 2 hours, or it will be automatically closed. If you believe this was flagged incorrectly, please let a maintainer know. |
|
The following comment was made by an LLM, it may be inaccurate: Potentially Related PRs FoundPR #45937 - fix(webfetch): preserve specific errors and preview oversized responses (fixes #45929) Why it might be related: This PR also deals with webfetch response size handling, specifically addressing oversized responses. While it fixes a different issue (#45929), it touches similar webfetch response size concerns and may have overlapping implementation details or requirements. Recommendation: Review #45937 to ensure your configurability feature complements or doesn't conflict with its error handling and preview logic for oversized responses. |
There was a problem hiding this comment.
🟡 Changes recommended
The linked issue proposes an env-var override (OPENCODE_WEBFETCH_MAX_SIZE) but the implementation currently only supports config, so it may not fully satisfy the “Fixes #15459” claim.
Once you've addressed the issues Copilot identified, you can request another Copilot review.
Pull request overview
This PR makes the webfetch tool’s maximum allowed response size configurable (defaulting to the existing 5MB limit), aligning the tool’s behavior with user-configurable settings rather than a hardcoded constant.
Changes:
- Introduces
DEFAULT_MAX_RESPONSE_SIZEand aresolveMaxResponseSize()helper, and wires the resolved limit intoWebFetchTool.execute. - Extends the config schema with
webfetch.max_response_size(bytes). - Adds unit tests covering the resolver default and config override behavior.
File summaries
| File | Description |
|---|---|
| packages/opencode/src/tool/webfetch.ts | Replaces hardcoded response size limit checks with a configurable value resolved at runtime. |
| packages/opencode/src/config/config.ts | Adds webfetch.max_response_size to the validated configuration schema. |
| packages/opencode/test/tool/webfetch.test.ts | Adds tests for default and overridden max response size resolution. |
Review details
- Files reviewed: 3/3 changed files
- Comments generated: 1
- Review effort level: Lite
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
f9b1d2a to
6f9b0f2
Compare
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>
|
This pull request has been automatically closed because it was not updated to meet our contributing guidelines within the 2-hour window. Feel free to open a new pull request that follows our guidelines. |
|
The description now uses the PR template (Closes #15459). GitHub will not let me reopen this PR from here. Please reopen if the template looks ok, or say if you want a fresh PR from the same branch (feat/webfetch-max-response-size). |
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 response at 5MB. This adds webfetch.max_response_size (bytes) so operators can raise or lower that cap. Default stays 5MB. OPENCODE_WEBFETCH_MAX_SIZE is a fallback when the config key is omitted (positive integer only).
How did you verify your code works?
Existing webfetch tests plus the env-fallback path for OPENCODE_WEBFETCH_MAX_SIZE. Default remains 5MB when neither config nor env is set.
Screenshots / recordings
Not a UI change.
Checklist