#15242: feat(web-fetch): Add Accept header for Cloudflare Markdown for Agents [AI-assisted]
agents
stale
size: XS
## Summary
This PR implements support for [Cloudflare's Markdown for Agents](https://blog.cloudflare.com/markdown-for-agents/) feature by updating the `Accept` header in `web_fetch`.
## Changes
- Changed Accept header from `*/*` to `text/markdown, text/html;q=0.9, */*;q=0.8`
- Implements backward-compatible content negotiation using quality values
## How it works
The updated Accept header uses HTTP content negotiation with quality values (q=):
1. **Prefers `text/markdown`** (q=1.0 implicit) - Cloudflare will serve optimized markdown if available
2. **Falls back to `text/html`** (q=0.9) - Standard HTML if markdown not available
3. **Accepts any content type** (q=0.8) - Ensures compatibility with all servers
This is **fully backward-compatible**: servers that don't support `text/markdown` will continue serving HTML or other formats as before, with no breaking changes.
## Testing
- **Degree of testing**: Lightly tested
- Verified the change compiles and affects only HTTP request headers
- No runtime behavior change for servers that don't support `text/markdown`
Fixes #14999
---
## 🤖 AI Transparency
**Generated with**: OpenAI Codex (GPT-5.2) via [OpenClaw](https://github.com/openclaw/openclaw)
**Degree of testing**: Lightly tested (compilation verified, single-line change)
**Session log**: Available on request
**Code understanding confirmed**: ✅
- The change is a single-line modification to the `Accept` header in `src/agents/tools/web-fetch.ts`
- HTTP content negotiation with q-values ensures backward compatibility
- Servers respond with their preferred format from the Accept list; markdown-capable servers (Cloudflare) will serve markdown, others continue serving HTML
Most Similar PRs
#15414: feat(web-fetch): add Accept: text/markdown header for Cloudflare Ma...
by aldoeliacim · 2026-02-13
88.9%
#15251: feat(web-fetch): send Accept: text/markdown header for Cloudflare M...
by wujieli0207 · 2026-02-13
84.5%
#16590: fix(web-fetch): use bot UA for markdown to enable Cloudflare LLM co...
by Imccccc · 2026-02-14
77.3%
#15530: docs(web_fetch): document markdown-first Accept header and cf-markd...
by novavale · 2026-02-13
72.0%
#20423: fix(web-fetch): cap htmlToMarkdown input size to prevent catastroph...
by Limitless2023 · 2026-02-18
64.8%
#20441: fix: preserve newlines for markdown table rendering in WebChat
by MisterGuy420 · 2026-02-18
64.1%
#14940: fix(googlechat): convert Markdown formatting to Google Chat markup
by brandonwise · 2026-02-12
64.1%
#23329: feat: Add Markdown support for cron job payload
by HeXavi8 · 2026-02-22
63.5%
#16346: feat: support image attachments in OpenAI chat completions endpoint
by sh1nj1 · 2026-02-14
62.3%
#21466: Copilot/fix forwarded message visibility
by stnguyen90 · 2026-02-20
61.6%