Skip to content

Send Accept: text/markdown HTTP header when fetching URLs in fallback mode. #13513

@guilleiguaran

Description

@guilleiguaran

What would you like to be added?

The web_fetch tool should send an Accept: text/markdown, */* HTTP header when fetching URLs in fallback mode.

Why is this needed?

Currently, the WebFetch fallback fetches URLs without content negotiation. This means servers that can provide markdown default to HTML, which we then convert to text using html-to-text. This conversion loses formatting, code blocks, and structure.

By adding Accept: text/markdown, */*, servers that support markdown will return native markdown directly, providing:

  • Better quality content (no lossy HTML-to-text conversion)
  • Preserved formatting, code blocks, and structure
  • Cleaner context for the LLM

Servers without markdown support will continue returning HTML as before (fully backward compatible).

Additional context

  • Other CLI agents like Claude Code already support this
  • Only affects fallback path (not the primary Gemini API fetch)

Metadata

Metadata

Assignees

No one assigned

    Labels

    Stalearea/agentIssues related to Core Agent, Tools, Memory, Sub-Agents, Hooks, Agent Qualitypriority/p1Important and should be addressed in the near term.status/need-triageIssues that need to be triaged by the triage automation.
    No fields configured for Feature.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions