Add Cloudflare Markdown for Agents pre-check to fetch workflows#928
Open
catchingknives wants to merge 1 commit intodanielmiessler:mainfrom
Open
Conversation
Adds a lightweight curl probe before the existing tier chain in FourTierScrape and before WebFetch in Retrieve. Sites behind Cloudflare (Pro+) with Markdown for Agents enabled serve native markdown via Accept: text/markdown content negotiation, saving ~80% tokens. Non-Cloudflare sites ignore the header — zero downside. Framed as a pre-check rather than a new tier to preserve the existing four-tier naming and numbering. Also updates Tier 2 Accept header to prefer text/markdown. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
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.
Idea: Free markdown before the tier chain even starts
Cloudflare launched Markdown for Agents in February 2026 — sites behind Cloudflare (Pro+) can now serve native markdown via
Accept: text/markdowncontent negotiation. Their benchmark shows ~80% token savings (16,180 → 3,150 tokens on a typical blog post). Server-side conversion is more accurate than client-side HTML parsing. Non-Cloudflare sites simply ignore the header and return HTML, so there's zero downside to trying.This PR adds a lightweight curl pre-check to FourTierScrape and Retrieve that probes for markdown before entering the existing tier/layer chain:
If the body comes back as markdown (YAML frontmatter or
#heading instead of<!DOCTYPE) → use it directly, skip the tier chain. If HTML → proceed to Tier 1 as normal.Why "pre-check" and not "Tier 0"
Deliberately framed as a preamble rather than a new numbered tier so the four-tier naming/numbering stays intact. No rename, no renumbering, just an additive optimization before the chain starts.
What changed
Scraping/BrightData/Workflows/FourTierScrape.mdtext/markdownResearch/Workflows/Retrieve.mdGotcha discovered during testing
Cloudflare's CDN currently returns
content-type: text/htmlin the response header even when the body is markdown (verified onblog.cloudflare.com). Thevary: acceptheader confirms content negotiation occurred. Detection should check the body format, not just the content-type header. This is noted in the workflow.Tested against
blog.cloudflare.com/markdown-for-agents/withAccept: text/markdown→ body is clean markdown with YAML frontmatter ✓Accept: text/html→ body is raw HTML ✓example.comwithAccept: text/markdown→ body is HTML, graceful fallthrough ✓Open to feedback on framing, placement, or whether this should live somewhere else entirely.
🤖 Generated with Claude Code