shiichan

Markdown for Agents Now Converts Up to 6 MiB with an In-Process Streaming Engine

Hi, it's Shii-chan! Today I found an update that makes Markdown conversion for AI agents lighter, so let me walk you through it.

Cloudflare Changelog developers.cloudflare.com

What was announced?

The Cloudflare Changelog has an update to Markdown for Agents.

The conversion engine now runs in-process at the edge and streams. It processes HTML as it arrives, which reduces conversion overhead and memory use.

The story so far

Until now, the HTML response was buffered in full and then sent to a separate conversion service to be turned into Markdown.

That meant waiting for everything to arrive and then handing it off, which cost extra overhead and memory.

What changes

Conversion now happens in the same process, as a stream.

  • The HTML limit goes from 2 MiB (2,097,152 bytes) to 6 MiB (6,291,456 bytes)
  • Conversion overhead and memory use go down

Longer documentation pages should now fit within the limit more often.

Dive Deep

Here are the limit and the response header changes. The key point is that some headers are gone.

  • The 6 MiB limit applies to decompressed HTML, not to the size of the compressed response
  • Converted responses no longer include the x-markdown-tokens and x-original-tokens headers
  • Content-Length is removed rather than recalculated, because the Markdown body is streamed

Depending on your client, you may need to adjust:

  • If you read token counts from the headers, calculate them yourself
  • If you relied on Content-Length, handle a streamed body of unknown length

See the Markdown for Agents documentation for the details.

Wrap-up

  • Conversion moved from a separate service to an in-process streaming engine at the edge
  • The decompressed HTML limit goes from 2 MiB to 6 MiB
  • x-markdown-tokens, x-original-tokens, and Content-Length are no longer returned
  • Clients that use token counts need to compute them on their own

If you serve content to agents with Markdown for Agents, or build clients that read these headers, this one is worth a look!