← Back to library

GitHub PR:web_fetch 增加 `Accept: text/markdown` 以降低抓取 token 成本

通过优先请求 markdown 响应并直返文本,减少 HTML 解析路径的 token 消耗,适合高频网页研究任务。

GITHUBDiscovered 2026-02-13Author echoVic
Prerequisites
  • OpenClaw runtime supports updated `web_fetch` header behavior (PR merged build).
  • Target site may provide `Content-Type: text/markdown` (e.g., Cloudflare Markdown for Agents).
Steps
  1. Call `web_fetch` against markdown-capable site and inspect response content-type.
  2. When response is markdown, bypass HTML extraction and return markdown directly.
  3. Benchmark token usage before/after header update on identical URLs.
  4. Keep compatibility fallback: if site ignores Accept preference, continue normal HTML extraction.
Commands
openclaw gateway status
npm run build
openclaw help
Verify

Markdown-capable sites return direct markdown with reduced token footprint; non-markdown sites remain behavior-compatible.

Caveats
  • Token reduction ratio varies by site template and markdown quality; quoted 80% is scenario-dependent(需验证).
  • Some markdown responses may omit embedded data present in raw HTML (scripts/meta blocks).
Source attribution

This tip is aggregated from community/public sources and preserved with attribution.

Open original source ↗
Visit original post