Skip to content

feat: make webfetch max response size configurable - #46799

Closed
RaviTharuma wants to merge 2 commits into
anomalyco:devfrom
RaviTharuma:feat/webfetch-max-response-size
Closed

RaviTharuma wants to merge 2 commits into
anomalyco:devfrom
RaviTharuma:feat/webfetch-max-response-size

Conversation

@RaviTharuma

@RaviTharuma RaviTharuma commented Sep 2, 2026 •

Copy link
Copy Markdown

Issue for this PR

Closes #15459

Type of change

  • Bug fix
  • New feature
  • Refactor / code improvement
  • Documentation

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

  • I have tested my changes locally
  • I have not included unrelated changes in this PR

Copilot AI lite review requested due to automatic review settings September 2, 2026 11:26
@github-actions github-actions Bot added the needs:compliance This means the issue will auto-close after 2 hours. label Sep 2, 2026
@github-actions

github-actions Bot commented Sep 2, 2026

Copy link
Copy Markdown
Contributor

This PR doesn't fully meet our contributing guidelines and PR template.

What needs to be fixed:

  • PR description is missing required template sections. Please use the PR template.

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.

@github-actions

github-actions Bot commented Sep 2, 2026

Copy link
Copy Markdown
Contributor

The following comment was made by an LLM, it may be inaccurate:

Potentially Related PRs Found

PR #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.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 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_SIZE and a resolveMaxResponseSize() helper, and wires the resolved limit into WebFetchTool.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.

Comment thread packages/opencode/src/tool/webfetch.ts
@RaviTharuma
RaviTharuma force-pushed the feat/webfetch-max-response-size branch from f9b1d2a to 6f9b0f2 Compare September 2, 2026 13:05
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>
@github-actions

github-actions Bot commented Sep 2, 2026

Copy link
Copy Markdown
Contributor

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.

@github-actions github-actions Bot removed the needs:compliance This means the issue will auto-close after 2 hours. label Sep 2, 2026
@github-actions github-actions Bot closed this Sep 2, 2026
@RaviTharuma

Copy link
Copy Markdown
Author

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).

kvnloo pushed a commit to kvnloo/opencode that referenced this pull request Sep 26, 2026
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.
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.

[FEATURE]: Make webfetch MAX_RESPONSE_SIZE configurable

2 participants