feat(opencode): prioritize text/markdown in webfetch accept header#16208
Open
zeke wants to merge 2 commits intoanomalyco:devfrom
Open
feat(opencode): prioritize text/markdown in webfetch accept header#16208zeke wants to merge 2 commits intoanomalyco:devfrom
zeke wants to merge 2 commits intoanomalyco:devfrom
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Issue for this PR
Closes #13486
Redo of #15899, which was auto-closed for not following the PR template.
Type of change
What does this PR do?
This PR adds
text/markdownas 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/markdownfirst, 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
Acceptheader —text/markdownis prepended beforetext/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