Skip to content

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

Open
zeke wants to merge 2 commits intoanomalyco:devfrom
zeke:webfetch-markdown-accept
Open

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

Conversation

@zeke
Copy link
Copy Markdown
Contributor

@zeke zeke commented Mar 5, 2026

Issue for this PR

Closes #13486

Redo of #15899, which was auto-closed for not following the PR template.

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 skips the HTML-to-markdown conversion on the client side.

Cloudflare's Markdown for Agents serves markdown at the edge for any zone with the feature enabled. By requesting text/markdown first, opencode gets cleaner output with fewer tokens from sites that support it, and falls back to the existing HTML conversion otherwise.

The change is a single line in the default Accept header — text/markdown is prepended before text/html.

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

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