建议大家升级一下openclaw网页抓取逻辑升级:
在所有 HTTP 请求中统一添加 Accept: text/markdown, text/html header。
原理:Cloudflare 推出了 Markdown for Agents 功能,启用了该功能的网站会在 AI agent 请求时直接返回 Markdown 格式内容,token 消耗比 HTML 减少约 80%。不支持的网站会正常返回 HTML,不受影响。
具体改动:
1. 找到 所有 Agent 中涉及网页抓取的代码(fetch、axios、request 等 HTTP 调用)
2. 在请求 header 中统一加上:Accept: text/markdown, text/html
3. 在响应处理中加一层判断:
- 如果 content-type 是 text/markdown → 直接使用,跳过 HTML 解析
- 如果 content-type 是 text/html → 走原有 HTML 解析逻辑
4. 如果响应中有 x-markdown-tokens header,记录到日志(方便未来做 token 预算估算)
改动后运行测试,找一个 Cloudflare 托管的网站验证,确认能收到 Markdown 响应。