You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
web_fetch cannot retrieve JSON REST APIs. Any request to an endpoint that only serves JSON (for example the GitHub REST API) fails with:
Error during fetch for https://api.github.com/repos/openai/codex/releases/tags/rust-v0.92.0: Request failed with status code 415 Unsupported Media Type
This happens regardless of the format argument, because web_fetch always sends an Accept header that lists only text/* media types. The default (auto) sends text/markdown, text/html, text/plain, and each explicit format maps to a single text/* value. A JSON-only API has no text/* representation to offer, so it rejects the request.
Encountered in real use while asking the assistant to look up a package's release date: web_fetch could read the HTML release page, but every attempt to hit the cleaner JSON API endpoint (which contains the exact published_at timestamp) returned 415 — so the assistant had to fall back to scraping a year-less relative date out of the HTML.
Reproduction
qwen -p "Use the web_fetch tool to fetch https://api.github.com/repos/openai/codex/releases/tags/rust-v0.92.0 and report the published date."
Observed: the tool errors with 415 Unsupported Media Type. Expected: it returns the release info.
The 415 is purely about the Accept header — confirmed with curl against the same URL:
web_fetch should be able to fetch JSON APIs (and any other content type it doesn't explicitly enumerate), while still preferring markdown when a server can provide it (the token-saving path). A general-purpose fetch tool shouldn't hard-fail on a whole class of endpoints just because of an over-narrow Accept header.
Login information
OpenAI-compatible API configuration (DashScope). Note: the bug is in the HTTP request web_fetch makes to the target URL, and is independent of how the model provider is configured or authenticated — it reproduces under any login.
Anything else we need to know?
Proposed fix
Add a low-priority catch-all to the Accept header using standard HTTP quality values — the same single-request content-negotiation pattern browsers use (e.g. Chrome sends …,*/*;q=0.8). The preferred type still wins whenever the server can serve it; */* only activates as a fallback.
Behavior for common requests (auto mode) — only the JSON-API case changes:
Request target
Current
Proposed
Normal HTML page
200, HTML
200, HTML (unchanged)
Markdown-capable server
200, markdown (token-saving)
200, markdown (unchanged)
Raw text/markdown file
200, file
200, file (unchanged)
Server that ignores Accept
200
200 (unchanged)
JSON REST API (e.g. GitHub)
415, fails
200, JSON
Confirmed with curl: the proposed auto header returns 200 on example.com, a raw GitHub README, and the GitHub JSON API (handing back the full published_at: 2026-01-27T11:50:52Z the HTML page couldn't provide).
Notes:
For context, the 415 here is a content-negotiation rejection of the Accept header (the spec-correct status for an unsatisfiable Accept is 406 Not Acceptable; GitHub's use of 415 is idiosyncratic) — so the Accept header is the right lever to adjust.
web_fetch already normalizes all fetched content to plain text regardless of format, so receiving JSON/HTML via the fallback is harmless to downstream processing.
Error during fetch for https://api.github.com/repos/openai/codex/releases/tags/rust-v0.92.0: Request failed with status code 415 Unsupported Media Type
无论传入哪个 format 参数都会这样,因为 web_fetch 始终发送只包含 text/* 媒体类型的 Accept 头。默认值(auto)发送 text/markdown, text/html, text/plain,而每个显式的 format 都映射到单一的 text/* 值。只提供 JSON 的 API 没有任何 text/* 表示可供返回,于是拒绝该请求。
在实际使用中发现:让助手查询某软件包的发布日期时,web_fetch 能读取 HTML 发布页面,但每次尝试访问更干净的 JSON API 接口(其中含有精确的 published_at 时间戳)都返回 415——于是助手只能退而从 HTML 中抓取一个不含年份的相对日期。
复现
qwen -p "Use the web_fetch tool to fetch https://api.github.com/repos/openai/codex/releases/tags/rust-v0.92.0 and report the published date."
观察到:工具报错 415 Unsupported Media Type。期望:返回该 release 的信息。
What happened?
web_fetchcannot retrieve JSON REST APIs. Any request to an endpoint that only serves JSON (for example the GitHub REST API) fails with:This happens regardless of the
formatargument, becauseweb_fetchalways sends anAcceptheader that lists onlytext/*media types. The default (auto) sendstext/markdown, text/html, text/plain, and each explicit format maps to a singletext/*value. A JSON-only API has notext/*representation to offer, so it rejects the request.Encountered in real use while asking the assistant to look up a package's release date:
web_fetchcould read the HTML release page, but every attempt to hit the cleaner JSON API endpoint (which contains the exactpublished_attimestamp) returned 415 — so the assistant had to fall back to scraping a year-less relative date out of the HTML.Reproduction
Observed: the tool errors with
415 Unsupported Media Type. Expected: it returns the release info.The 415 is purely about the
Acceptheader — confirmed withcurlagainst the same URL:Acceptheader senttext/markdowntext/htmltext/plaintext/markdown, text/html, text/plain(currentauto)*/*application/vnd.github+jsonWhat did you expect to happen?
web_fetchshould be able to fetch JSON APIs (and any other content type it doesn't explicitly enumerate), while still preferring markdown when a server can provide it (the token-saving path). A general-purpose fetch tool shouldn't hard-fail on a whole class of endpoints just because of an over-narrowAcceptheader.Login information
OpenAI-compatible API configuration (DashScope). Note: the bug is in the HTTP request
web_fetchmakes to the target URL, and is independent of how the model provider is configured or authenticated — it reproduces under any login.Anything else we need to know?
Proposed fix
Add a low-priority catch-all to the
Acceptheader using standard HTTP quality values — the same single-request content-negotiation pattern browsers use (e.g. Chrome sends…,*/*;q=0.8). The preferred type still wins whenever the server can serve it;*/*only activates as a fallback.formatAcceptAcceptauto(default)text/markdown, text/html, text/plaintext/markdown, text/html;q=0.9, text/plain;q=0.8, */*;q=0.1markdowntext/markdowntext/markdown, */*;q=0.1htmltext/htmltext/html, */*;q=0.1texttext/plaintext/plain, */*;q=0.1Behavior for common requests (
automode) — only the JSON-API case changes:AcceptConfirmed with
curl: the proposedautoheader returns 200 on example.com, a raw GitHub README, and the GitHub JSON API (handing back the fullpublished_at: 2026-01-27T11:50:52Zthe HTML page couldn't provide).Notes:
415here is a content-negotiation rejection of theAcceptheader (the spec-correct status for an unsatisfiableAcceptis406 Not Acceptable; GitHub's use of415is idiosyncratic) — so theAcceptheader is the right lever to adjust.web_fetchalready normalizes all fetched content to plain text regardless offormat, so receiving JSON/HTML via the fallback is harmless to downstream processing.Context
Acceptheader inweb_fetch's direct-fetch path; no change to how fetched content is processed.中文说明
发生了什么?
web_fetch无法获取 JSON REST API。任何只返回 JSON 的接口(例如 GitHub REST API)都会失败并报错:无论传入哪个
format参数都会这样,因为web_fetch始终发送只包含text/*媒体类型的Accept头。默认值(auto)发送text/markdown, text/html, text/plain,而每个显式的 format 都映射到单一的text/*值。只提供 JSON 的 API 没有任何text/*表示可供返回,于是拒绝该请求。在实际使用中发现:让助手查询某软件包的发布日期时,
web_fetch能读取 HTML 发布页面,但每次尝试访问更干净的 JSON API 接口(其中含有精确的published_at时间戳)都返回 415——于是助手只能退而从 HTML 中抓取一个不含年份的相对日期。复现
观察到:工具报错
415 Unsupported Media Type。期望:返回该 release 的信息。415 完全由
Accept头引起——用curl对同一 URL 验证:Accept头text/markdowntext/htmltext/plaintext/markdown, text/html, text/plain(当前auto)*/*application/vnd.github+json期望的行为
web_fetch应当能够获取 JSON API(以及任何它未显式列出的内容类型),同时在服务器能够提供 markdown 时仍优先选择 markdown(节省 token 的路径)。一个通用抓取工具不应仅仅因为Accept头过窄就对一整类接口直接失败。登录信息
OpenAI 兼容 API 配置(DashScope)。注意:该 bug 位于
web_fetch向目标 URL 发起的 HTTP 请求中,与模型提供方如何配置或鉴权无关——在任何登录方式下都会复现。还有什么需要我们了解的吗?
建议的修复
使用标准的 HTTP 质量值(quality value)为
Accept头添加一个低优先级的兜底类型——正是浏览器采用的单请求内容协商方式(例如 Chrome 发送…,*/*;q=0.8)。只要服务器能提供首选类型,首选类型仍然胜出;*/*仅作为兜底生效。formatAcceptAcceptauto(默认)text/markdown, text/html, text/plaintext/markdown, text/html;q=0.9, text/plain;q=0.8, */*;q=0.1markdowntext/markdowntext/markdown, */*;q=0.1htmltext/htmltext/html, */*;q=0.1texttext/plaintext/plain, */*;q=0.1常见请求的行为(
auto模式)——只有 JSON API 这一行发生变化:Accept的服务器已用
curl验证:建议的auto头在 example.com、原始 GitHub README、以及 GitHub JSON API 上均返回 200(并返回 HTML 页面无法提供的完整published_at: 2026-01-27T11:50:52Z)。说明:
415实际上是对Accept头的内容协商拒绝(表示无法满足Accept的规范状态码应为406 Not Acceptable,GitHub 使用 415 属于特例)——因此调整Accept头才是正确的着手点。web_fetch无论format如何都会将抓取到的内容归一化为纯文本,因此通过兜底拿到 JSON/HTML 对下游处理无害。背景
web_fetch直接抓取路径中的Accept头;不改变已抓取内容的处理方式。