GitHub Trending | 📄 原文链接 | 2026-10-21 收录

headroom:在内容进模型之前先把它压小

来源:GitHub — 2026-10-21 · ⭐ 76,624 stars · 今日 +555 · Python

📋 概述

Headroom 在工具输出、日志、RAG 片段、文件与会话历史送达模型之前先做压缩,压缩全部在本机完成,提示与文件内容不外传。它按内容类型分流:ContentRouter 判断是 JSON、源码还是散文,再交给 SmartCrusher、CodeCompressor(AST)或 Kompress-v2-base 处理;CacheAligner 只标出会击穿供应商 KV-cache 前缀的易变内容,从不改写提示。原文缓存在本地(CCR),模型需要全文时调 headroom_retrieve 取回,因此压缩是可逆的。接入有四条路:库里直接 compress(messages)、起代理端口零改代码、用 headroom wrap 包住现有客户端、或挂成 MCP 服务。

🔑 核心要点

💡 金句

Headroom compresses everything your AI agent reads — tool outputs, logs, RAG chunks, files, and conversation history — before it reaches the LLM. Same answers, fraction of the tokens.
← 返回 GitHub Trending 首页