mirror of
https://github.com/gotempsh/temps.git
synced 2026-04-25 06:15:55 +03:00
[PR #12] [MERGED] feat(proxy): Markdown for Agents — Accept: text/markdown content negotiation #16
Labels
No labels
bug
enhancement
pull-request
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
starred/temps#16
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
📋 Pull Request Information
Original PR: https://github.com/gotempsh/temps/pull/12
Author: @dviejokfs
Created: 2/18/2026
Status: ✅ Merged
Merged: 2/18/2026
Merged by: @dviejokfs
Base:
main← Head:feat/markdown-for-agents📝 Commits (4)
fceb0d0feat(proxy): add Accept: text/markdown support for AI agents45ef12afix(proxy): fix clippy unnecessary_literal_unwrap in markdown test and update changelogdd26b9ffix(proxy): extract content before HTML-to-Markdown conversiona111d54test(proxy): add pipeline integration tests for markdown edge cases📊 Changes
4 files changed (+1826 additions, -4 deletions)
View changed files
📝
CHANGELOG.md(+1 -0)📝
Cargo.lock(+365 -2)📝
crates/temps-proxy/Cargo.toml(+2 -0)📝
crates/temps-proxy/src/proxy.rs(+1458 -2)📄 Description
Summary
Implements Markdown for Agents content negotiation in the Pingora reverse proxy, compatible with Cloudflare's emerging standard for AI-native content delivery.
When an AI agent or HTTP client sends
Accept: text/markdown, Temps now converts the upstream HTML response to Markdown on the fly before delivering it — reducing token waste and improving response quality for AI systems consuming deployed apps.How it works
Filter chain
early_request_filterAccept: text/markdown; setsctx.wants_markdown = true; disables upstream compressionupstream_response_filtertext/html(not SSE/WS); addsVary: Accept; cancels conversion otherwiseresponse_filterContent-Type → text/markdown; charset=utf-8; removesContent-LengthandContent-Encoding; addsX-Markdown-Tokens: 0placeholderresponse_body_filterhtmdonend_of_stream; falls back to passthrough on error or size limit exceededSafety guards
ctx.is_sseorctx.is_websocketis set — streaming responses always pass through unchangedtext/htmlupstream responses are converted; JSON, images, etc. pass through as-ishtmdfails, the original HTML bytes are returned so the client always gets somethingTests
18 unit tests added in
proxy::markdown_tests:Dependencies
htmd0.5— pure Rust HTML→Markdown converter, no C dependencies🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.