Skip to content

feat(opencode): prioritize text/markdown in webfetch accept header#15899

Closed
zeke wants to merge 2 commits intoanomalyco:devfrom
zeke:webfetch-accept-header
Closed

feat(opencode): prioritize text/markdown in webfetch accept header#15899
zeke wants to merge 2 commits intoanomalyco:devfrom
zeke:webfetch-accept-header

Conversation

@zeke
Copy link
Copy Markdown
Contributor

@zeke zeke commented Mar 3, 2026

Resolves: #13486

Type of change

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

What does this PR do?

This PR adds text/markdown as the highest priority in the default Accept header for the webfetch tool. When a server supports content negotiation and can serve markdown directly, this avoids unnecessary HTML-to-markdown conversion on the client side.

Cloudflare recently launched Markdown for Agents, which uses the Accept: text/markdown header to serve markdown versions of web pages at the edge. Any Cloudflare zone with this feature enabled will return markdown instead of HTML when the request includes text/markdown in the Accept header. By prioritizing this in the webfetch tool, opencode gets cleaner output with fewer tokens from any site that supports it.

How did you verify your code works?

Added tests covering accept header behavior for each format option and verifying markdown passthrough vs HTML conversion. Ran the test suite in packages/opencode.

Screenshots / recordings

N/A

Checklist

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

@github-actions github-actions bot added needs:compliance This means the issue will auto-close after 2 hours. contributor labels Mar 3, 2026
@zeke zeke force-pushed the webfetch-accept-header branch from a707d1a to f70cf96 Compare March 3, 2026 20:53
@github-actions github-actions bot removed the needs:compliance This means the issue will auto-close after 2 hours. label Mar 3, 2026
@github-actions
Copy link
Copy Markdown
Contributor

github-actions bot commented Mar 3, 2026

Thanks for updating your PR! It now meets our contributing guidelines. 👍

@github-actions github-actions bot added the needs:compliance This means the issue will auto-close after 2 hours. label Mar 3, 2026
@github-actions
Copy link
Copy Markdown
Contributor

github-actions bot commented Mar 3, 2026

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
Copy link
Copy Markdown
Contributor

github-actions bot commented Mar 3, 2026

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[FEATURE]: Support Cloudflare “Markdown for Agents” docs negotiation (Accept: text/markdown)

1 participant