Series: RAG 系統架構 (5/5)
- Headroom compresses context locally before the LLM, masking spans as keep-or-compress rather than rewriting—structure stays verbatim, prose gets shrunk
- Compression can backfire by busting the provider's prompt cache; only shave tokens when the net-gain math actually clears
- Don't trust the README's anomaly-detection claims—the code only keeps keys and high-entropy values; read what's implemented, not promised
Table of Contents
The biggest cost sink in agent workflows isn’t the model — it’s context bloat. One grep returning 100 results, one incident log, one RAG retrieval, and you’ve stuffed tens of thousands of tokens into a prompt where maybe a tenth carries signal. Headroom exists to fix exactly that: before a request reaches OpenAI or Anthropic, it strips that noise locally by 60–95%, claiming accuracy stays essentially flat.
This isn’t just a feature tour. I read it down to the code to unpack how it decides what to compress and what to keep — including one design I rarely see done this maturely, and one gap where the docs run ahead of the implementation.
The core abstraction: every compression is a mask
The easiest way to misread Headroom is to assume it “rewrites content into a summary.” It rewrites nothing — it produces a per-character boolean mask marking each span as “keep” or “compressible,” then only touches the compressible parts.
UniversalCompressor is the orchestrator, with a fixed flow:
flowchart LR
A[Raw content] --> B[detector classifies type]
B --> C[handler builds structure mask]
C --> D[entropy mask overlaid]
D --> E{Is this span structural?}
E -- Yes --> F[Keep verbatim]
E -- No --> G[Send to Kompress model]
F --> H[CompressionResult]
G --> H
The split is the point: structure is decided by rules, semantics go to the ML model. JSON keys, function signatures — those “skeletons” are preserved 100% by deterministic handler rules and never mangled by a model. Only the leftover prose spans go through the ML model. If the model can’t compress or isn’t installed, the fallback chain degrades to plain truncation (_simple_compress). This design boxes the risk of lossy compression into a safe zone.
Three handlers: content-aware, not one model for everything
Headroom first classifies content. The primary path is Google’s Magika (a local deep-learning model, ~5ms, 100+ types), normalized into seven categories: JSON / CODE / LOG / DIFF / MARKDOWN / TEXT / UNKNOWN. Without Magika it falls back to pattern matching. Confidence below 0.5 collapses to UNKNOWN and a NoOp — it won’t gamble on compressing.
Then it routes to the matching handler:
The JSON handler’s real rules (read json_handler.py, not the README):
- Every key is kept — so the LLM can see which fields exist and navigate
- Structural punctuation
{}[]:,is kept - Numbers: kept if ≤10 digits; string values: kept only if ≤20 chars, or high-entropy (no spaces + entropy > 0.85, catching UUIDs / hashes)
- Arrays keep only the first 3 entries in full, aggressively compressing from the 4th on
A clever detail: self-normalized entropy scores English prose >0.85 too, so a “no spaces” gate prevents mistaking a sentence for an identifier and pointlessly preserving it.
The code handler uses AST:
- Primary path tree-sitter, regex fallback, supporting Python / JS / TS / Go / Rust / Java / Perl
- Kept: imports, function and method signatures, class / struct / interface definitions, type declarations, decorators
- Compressed: function bodies, comments, whitespace
- The subtlety: “the signature runs to the body start; the body is NOT marked, so nested function bodies stay compressible.” It even handles tree-sitter’s byte-offset → char-offset conversion (multi-byte correctness).
In other words, after compression you still see a file’s full API shape — only the bodies are folded away. That’s exactly what an LLM needs to understand a file.
The part worth stealing: cache-mutation economics
If I could only show you one file, it’d be the Rust side’s compression_policy.rs. Because it asks a higher-order question than “can we compress?”:
Does dropping this span — and thereby busting the provider’s prompt cache — actually pay off?
Most compression tools ignore something: on providers with KV caching, blind compression can cost more, because mutating a cached prefix invalidates the whole cache downstream, forcing a rewrite at 1.25× the price. Headroom writes this as a net-gain formula:
gain = ΔT·(w + r·(R−1)) − P_alive·(w−r)·(S+ΔT)
w = 1.25(writing a cached token costs 1.25× a plain input token)r = 0.1(reading a cached token costs 0.1×)ΔT= tokens removed,R= expected remaining reads,S= the suffix invalidated after the edit,P_alive= probability the cache stays valid
The intuition (from its test anchors):
| Scenario | Calculation | Result |
|---|---|---|
| Small shave, deep suffix (50K suffix, shave 2K, 10 reads) | 4300 − 59800 | −55500 unprofitable |
| Big shave, shallow suffix (10K suffix, shave 50K, 3 reads) | 72500 − 69000 | +3500 profitable |
The break-even formula R = 11.5·S/ΔT: a small shave needs 287 reads to pay off (basically never), a big shave only 2.3 (profitable within a few turns). should_mutate_deep() only fires when gain > 0.
It even tiers policy by billing mode: subscription users get CacheAligner turned off entirely, because what they pay for is prompt-cache stability — you can’t let compression mutate cached prefixes and corrupt the cache hash. This “compression bows to billing reality” nuance is a level most open-source compressors never reach.
CCR: turning lossy compression into lazy loading
The biggest worry with aggressive compression is “what if you dropped the one thing that mattered?” Headroom’s answer is CCR (Compress-Cache-Retrieve): originals stay in a local store after compression, and the LLM gets a headroom_retrieve tool — when it senses it’s missing something, it can fetch the original on demand.
That demotes “lossy compression” to “lazy loading”: save tokens by default with the compressed version, and pay one tool round-trip only when full content is actually needed. It’s also the safety net behind the claim of aggressive compression without accuracy loss.
The overall architecture
graph LR
App[Agent / App] --> HR[Headroom local layer]
subgraph HR[Headroom local layer]
CA[CacheAligner<br/>stabilize prefix] --> CR[ContentRouter]
CR --> J[JSON handler]
CR --> C[Code handler / AST]
CR --> K[Kompress text model]
J --> CCR[(CCR reversible cache)]
C --> CCR
K --> CCR
end
HR --> LLM[LLM provider<br/>OpenAI / Anthropic / ...]
LLM -.headroom_retrieve.-> CCR
There are four ways in: library (compress(messages) inline), proxy (localhost:8787, a zero-code gateway), agent wrapper (headroom wrap claude), and MCP server. Any OpenAI-compatible client works through the proxy. The text model, Kompress-v2-base, is an extractive token classifier built on ModernBERT (149M params) + LoRA — it predicts keep / drop per token rather than generating a summary, so it can’t hallucinate content the original never had.
An honest caveat: the docs run ahead of the code
After reading the code, I found a gap worth writing down. The README and docs repeatedly stress that JSON compression does “statistical analysis [to] keep errors, anomalies, boundaries.” But in the actual json_handler.py, there is no error detection, no anomaly detection, no statistical sampling — it just “keeps all keys + the first 3 entries + short / high-entropy values.” The only “statistical” element is entropy scoring, and that’s for catching identifiers, not anomalies.
This doesn’t mean it’s lying — it’s the classic signature of an early project (single-author-led, in an F2.x phase, with plenty of fields “plumbed but not yet consumed”): the README describes the vision architecture; the code is the current version. Whenever you evaluate a compression tool, remember — don’t make architecture decisions off capability claims, go read what the code actually does right now.
And note: those “92% / 87.6%” ratios are cherry-picked from high-redundancy scenarios (search results, logs); the ML model itself defaults to just 18% on prose. Don’t expect 90%+ on ordinary conversation.
The bottom line
Headroom’s real technical highlights are three, each extractable on its own: mask-based extraction (rules guarantee structure, only semantics go to the model), cache-mutation economics (decide whether to compress via a cost model, not blindly), and CCR reversibility (lossy demoted to lazy loading). The second one in particular is worth borrowing for anyone leaning on prompt caching with Anthropic or OpenAI.
The reasons to stay skeptical are just as clear: docs ahead of code, cherry-picked ratios, an early single-author project. If you’re on a single provider at modest volume, native context management is probably enough. But if you run multi-agent, cross-provider daily dev flows and feel the token bill, Headroom’s design is worth one read-through — even if you never adopt it, that cache-mutation formula alone earns its keep.
References
For a deeper look at the technologies and architecture mentioned here, see the official resources below.
Answers come from this article only. Click any prompt below or open the chat at the bottom right.
🇺🇸 English
Here's the listening script.
---
The biggest money pit in agent workflows isn't the model you're calling. It's context bloat. Think about it — one `grep` command comes back with a hundred results, one incident log, one retrieval from your vector database, and suddenly you've crammed tens of thousands of tokens into a prompt where maybe a tenth of it actually carries any signal. The rest is noise you're paying for, round after round.
There's a tool called Headroom built to fix exactly that. The idea is simple but the execution is interesting: before your request ever reaches OpenAI or Anthropic, Headroom strips out the noise — locally, on your machine — cutting context by sixty to ninety-five percent, and it claims accuracy stays basically flat.
Now, I didn't want to just give you the feature tour. I went and read the actual code, because I wanted to understand how it decides what to throw away and what to keep. And there's one design in there I almost never see done this maturely — plus one spot where the documentation is writing checks the code can't yet cash. Let's get into both.
So here's the core idea, and it's the easiest thing to get wrong about Headroom. You might assume it "rewrites your content into a summary." It does not. It rewrites nothing. Instead, for every single character, it produces a true-or-false mask — keep, or compressible. And it only ever touches the parts marked compressible.
The flow goes like this. Raw content comes in. A detector classifies what type of content it is. A handler builds a structural mask — the skeleton that must be preserved. Then an entropy mask gets layered on top. And for each span, it asks one question: is this structural? If yes, keep it word for word. If no, hand it to the compression model. Both paths merge back into one result.
And that split is the whole point. Structure is decided by deterministic rules. Meaning gets handed to the machine learning model. So your JSON keys, your function signatures — the skeletons — those are preserved one hundred percent by hard-coded rules and never get mangled by a model. Only the leftover prose goes through the ML side. And if the model can't compress it, or isn't even installed, it gracefully falls back to plain truncation. What that design really does is box the risk of lossy compression into a safe little corner where it can't hurt you.
Headroom starts by figuring out what kind of content it's looking at. The main tool there is Google's Magika — a local deep-learning classifier, runs in about five milliseconds, recognizes over a hundred file types. Headroom boils all that down into seven buckets: JSON, code, logs, diffs, markdown, plain text, and unknown. No Magika installed? It falls back to pattern matching. And here's a nice touch — if its confidence drops below fifty percent, it just gives up and does nothing. It refuses to gamble on compressing something it doesn't understand.
Then it routes to the right handler. Let's talk about the JSON one, and I'm reading from the actual handler code here, not the README. Every key is kept — all of them — so the language model can still see which fields exist and navigate the structure. The structural punctuation, the braces and brackets and colons, all kept. Numbers stay if they're ten digits or shorter. String values stay only if they're twenty characters or less, or if they're high-entropy — meaning no spaces and a randomness score above point eight-five, which is how it catches things like UUIDs and hashes. And arrays? It keeps the first three entries in full, then compresses aggressively from the fourth onward.
There's a clever wrinkle in there. That entropy score? Normal English prose also scores above point eight-five. So if you only checked entropy, you'd mistake a regular sentence for some critical identifier and pointlessly preserve it. The fix is that "no spaces" gate. Sentences have spaces, hashes don't. Simple, but it's the kind of detail that tells you someone actually thought this through.
The code handler is similar in spirit but uses an abstract syntax tree. Primary path is tree-sitter, with a regex fallback, covering Python, JavaScript, TypeScript, Go, Rust, Java, even Perl. What does it keep? Imports, function and method signatures, class and struct and interface definitions, type declarations, decorators. What does it compress? The function bodies, the comments, the whitespace. So after compression, you still see the file's entire API shape — every signature intact — and only the implementation guts are folded away. Which, honestly, is exactly what a language model needs to understand a file.
Okay. Now the part I'd actually steal. If I could show you only one file in this whole project, it'd be the Rust side — a file called compression policy. Because it asks a smarter question than everyone else. Not "can we compress this?" but "does compressing this actually pay off, once you account for the cache?"
Here's what most compression tools completely miss. On providers with prompt caching — KV caching — blind compression can cost you more, not less. Why? Because if you mutate a cached prefix, you invalidate the entire cache downstream of that edit. And rewriting those tokens costs one-point-two-five times the price of a plain input token. So you save a few tokens up front and pay a tax on everything after.
Headroom turns this into an actual economic formula. I won't read you the algebra, but the moving pieces are intuitive. Writing a cached token costs one-point-two-five. Reading a cached token costs only one-tenth. Then it weighs how many tokens you're removing, how many times you expect to read this context again, and how big the suffix is that gets invalidated by your edit. Plug it all in, and you get a net gain — positive or negative.
Let me give you the two scenarios from its own tests, because they make it click. Scenario one: you've got a fifty-thousand-token suffix, and you shave off a measly two thousand tokens, and you'll read it ten times. The math comes out massively negative — you lose around fifty-five thousand. Not worth it. Scenario two: a smaller ten-thousand-token suffix, but now you shave off fifty thousand tokens, read it three times. That comes out positive. Profitable.
The break-even point is the key insight. A tiny shave would need something like two hundred eighty-seven reads before it pays for itself — which basically means never. A big shave pays off after just a couple of turns. So Headroom only pulls the trigger when the gain is genuinely positive.
And it goes one level deeper. It tiers the policy by how you're billed. If you're a subscription user, it turns the cache aligner off entirely — because what you're paying for is prompt-cache stability, and you simply can't let compression go mutating cached prefixes and scrambling the cache hash. That idea — compression bowing to billing reality — is a level of maturity most open-source compressors never even approach.
Now, the obvious fear with aggressive compression: what if you threw away the one thing that mattered? Headroom's answer is something it calls CCR — Compress, Cache, Retrieve. After compression, the originals stick around in a local store. And the language model is handed a retrieve tool. So when the model senses it's missing something, it just asks for the original on demand.
That move quietly demotes "lossy compression" down to "lazy loading." By default you save tokens with the compressed version, and you only pay for one tool round-trip on the rare occasion the model actually needs the full content. That's also the real safety net behind the whole "aggressive compression without losing accuracy" claim.
Quick word on the architecture overall. There are four ways to plug it in: as a library you call inline, as a proxy running on localhost that needs zero code changes, as an agent wrapper, or as an MCP server. Any OpenAI-compatible client works through the proxy. And the text model doing the semantic work — it's called Kompress — is extractive, not generative. It's built on ModernBERT with a LoRA adapter, around a hundred and fifty million parameters, and all it does is predict keep-or-drop for each token. It never generates a summary. Which means, crucially, it physically cannot hallucinate content that wasn't in your original. It can only select from what's already there.
Alright, time for the honest caveat, because I promised you one. After reading the code, I found a real gap. The README and the docs keep stressing that JSON compression does "statistical analysis to keep errors, anomalies, and boundaries." Sounds impressive. But in the actual JSON handler? There's no error detection. No anomaly detection. No statistical sampling. It keeps all the keys, the first three array entries, and short or high-entropy values. That's it. The only thing remotely "statistical" is the entropy scoring, and that exists to catch identifiers, not anomalies.
Now, I don't think they're lying. This is the classic fingerprint of an early-stage, single-author project — plenty of fields "plumbed but not yet consumed." The README is describing the vision. The code is the current reality. And the lesson there is bigger than this one tool: whenever you're evaluating a compression library, don't make architecture decisions based on capability claims. Go read what the code actually does today.
One more reality check. Those headline ratios — ninety-two percent, eighty-seven percent — those are cherry-picked from high-redundancy situations like search results and logs. The ML model on ordinary prose? It defaults to around eighteen percent. So don't go expecting ninety-plus on a normal conversation. It won't happen.
So let me leave you with the three things worth taking away. First, mask-based extraction — the discipline of letting rules guarantee structure and only sending the fuzzy, semantic stuff to a model. That keeps your skeletons safe.
Second, and this is the one I'd genuinely borrow tomorrow: cache-mutation economics. Deciding whether to compress using a cost model instead of compressing blindly. If you're leaning on prompt caching with Anthropic or OpenAI, that single formula will change how you think about trimming context. Sometimes the cheapest move is to leave the bloat alone.
And third, CCR reversibility — turning lossy compression into lazy loading, so a wrong guess costs you one tool call instead of a wrong answer.
Stay skeptical too: the docs run ahead of the code, the ratios are cherry-picked, and it's an early project carried by one person. If you're on a single provider at modest volume, your platform's native context management is probably enough. But if you're running multi-agent, cross-provider dev flows every day and feeling that token bill — Headroom is worth one careful read. Even if you never adopt it, that cache-mutation formula alone earns its keep.
🇹🇼 中文
Agent 工作流最大的成本黑洞,其實不是模型本身,而是上下文膨脹。你想想看,一次 grep 回一百筆結果、一份 incident log、一個 RAG 檢索,動不動就上萬個 token 塞進 prompt,但裡面真正有訊號的,可能連一成都不到。今天要聊的這個工具叫 Headroom,它想解決的就是這件事——在請求送到 OpenAI 或 Anthropic 之前,先在你的本地端,把這層雜訊壓掉百分之六十到九十五,而且宣稱準確度幾乎不變。
不過我今天不只想介紹它能做什麼,我想帶你讀到程式碼層級,拆解它到底怎麼決定該壓什麼、該留什麼。這裡面有一個我覺得在這領域很少見的成熟設計,也有一個文件跑在實作前面的落差,值得提醒你一下。
先講最核心、也最容易誤解的一點。很多人以為 Headroom 是「把內容重寫成摘要」,其實不是。它一個 token 都不重寫。它真正做的,是產生一張逐字元的布林遮罩,標記每一個片段到底是「保留」還是「可壓縮」,然後只對「可壓縮」的部分動手。
它的協調器叫 UniversalCompressor,流程是固定的:原始內容進來,先用 detector 判斷類型,接著 handler 產生一張結構遮罩,再疊上一層熵的遮罩。然後逐段檢查,如果這一段是結構,就原樣保留;如果不是,才丟給壓縮模型去處理。
關鍵就在這個分工:結構由規則決定,語意才交給機器學習模型。JSON 的 key、程式碼的函式簽名,這些「骨架」由 handler 用確定性規則百分之百保住,模型絕對碰不壞;只有剩下的散文片段才丟進 ML 模型做語意壓縮。萬一模型壓不動、或根本沒裝,它的 fallback 鏈會退化成單純截斷。這個設計把「有損壓縮」的風險,框死在一個安全範圍裡,我覺得很聰明。
接著講三種 handler。Headroom 會先判斷內容類型,主路徑用的是 Google 的 Magika,這是一個本地的深度學習模型,大概五毫秒、支援一百多種類型,它把內容標準化成 JSON、CODE、LOG、DIFF、MARKDOWN、TEXT、還有 UNKNOWN 這七類。沒裝 Magika 就退化成 pattern matching。而且只要信心值低於零點五,一律歸到 UNKNOWN,走 NoOp,寧可不壓也不冒險。
判完型就分流。先看 JSON handler,它真正的規則——注意,是看程式碼不是看 README——是這樣的:所有 key 一律保留,讓 LLM 看得到有哪些欄位、能導航;結構符號像大括號中括號冒號逗號也保留;數字十位以內保留;字串值要嘛二十字元以內,要嘛是高熵值才保留;然後陣列只保留前三筆完整,第四筆之後就積極壓縮。
這裡有個我覺得很聰明的工程細節。它用的這種 self-normalized entropy,其實英文散文也會超過零點八五的門檻,所以它多加了一道「無空白」的閘門,專門避免把英文句子誤判成 UUID 或 hash 這種識別碼,硬留下來。
再看 Code handler,它走的是 AST,主路徑是 tree-sitter,退化用 regex,支援 Python、JS、TS、Go、Rust、Java、Perl。它保留的是:import、函式跟方法的簽名、class、struct、interface 的定義、型別宣告、還有 decorator;壓縮的則是函式 body、註解、空白。精妙的地方在於,簽名延伸到 body 的起點為止,body 本身不標記為保留,所以連巢狀函式的 body 都還是可以被壓。它甚至還處理了 tree-sitter 那種 byte offset 轉 char offset 的多位元組字元正確性問題,這是很現實的坑。
換句話說,程式碼壓完之後,你還是看得到完整的 API 形狀,只是 body 被折疊起來——而這,正好就是 LLM 在理解一個檔案時,真正需要的東西。
好,接下來是我認為整個專案最值得學的部分。如果只能挑一個檔案看,我會選 Rust 端的 compression_policy.rs。因為它問的不是「能不能壓」,而是一個更高階的問題:我壓掉這一段、進而打掉供應商的 prompt cache,到底划不划算?
這是多數壓縮工具忽略的事。在有 KV cache 的供應商上,盲目壓縮反而可能更貴。為什麼?因為你只要動了 cached prefix,下一輪整段 cache 就失效,要用一點二五倍的價格重新寫入。Headroom 把這件事寫成一條淨收益公式,裡面幾個關鍵參數:寫 cache 的成本是普通 token 的一點二五倍,讀 cache 只要零點一倍,然後再考慮你砍掉多少 token、預期還會被讀幾次、編輯點之後有多長的 suffix 會被連帶失效、以及 cache 還有效的機率。
直覺結論很有意思。如果是小砍、深 suffix——比方說五萬的 suffix 你只砍兩千、讀十次——算下來是大虧五萬五。但如果是大砍、淺 suffix——一萬的 suffix 砍掉五萬、讀三次——就是賺三千五。它的 break-even 公式換算下來:小砍要兩百八十七次讀取才回本,幾乎不可能;大砍只要兩點三次,幾個回合對話內就回本了。所以它的 should_mutate_deep 函式,只有在淨收益大於零的時候才動手。
它甚至按付費模式分級。訂閱用戶它直接把 CacheAligner 關掉,因為這些人付錢買的就是 prompt cache 的穩定,你不能讓壓縮去變異 cached prefix、寫壞快取雜湊。這種「壓縮要服從於計費現實」的細膩度,是很多開源壓縮工具根本沒想到的層次。
再來講 CCR。激進壓縮最大的疑慮就是:萬一我壓掉的正好是關鍵資訊怎麼辦?Headroom 的答案叫 CCR,Compress-Cache-Retrieve。壓縮之後,原文還留在本地的 store 裡,同時給 LLM 一個叫 headroom_retrieve 的工具。模型如果發現資訊不夠,可以主動 call 回完整原文。
這等於把「有損壓縮」降級成「延遲載入」。預設給你壓縮版省 token,真的需要時,才付一次工具往返的代價把完整內容取回來。這也是它敢宣稱「激進壓縮又不掉準確度」的安全網。
整體接入方式有四種:可以當 library 內嵌呼叫;可以當 proxy,在 localhost 起一個零改碼的 gateway;可以用 agent wrapper,直接 headroom wrap claude;或者當 MCP server。任何 OpenAI 相容的 client 都能走它的 proxy。它的語意壓縮模型叫 Kompress-v2-base,是基於 ModernBERT、一億四千九百萬參數,加上 LoRA 的抽取式 token 分類器——它是逐 token 預測 keep 還是 drop,不是生成式摘要,所以它不會幻覺出原文裡沒有的東西。
接著是一個誠實的提醒:文件跑在實作前面。我深入讀完程式碼之後發現一個落差。README 跟官方文件反覆強調,它的 JSON 壓縮會用「統計分析保留錯誤、異常、邊界值」。但你打開 json_handler.py 看實際程式碼,裡面根本沒有任何錯誤偵測、異常偵測或統計抽樣。它就只是「保留所有 key、加前三筆、加短值跟高熵值」。唯一沾得上「統計」邊的,就是那個熵的評分,而那是拿來抓識別碼的,不是抓異常。
我不是說它造假,而是這其實是這類早期專案的典型訊號——單一作者主導、還在 F2.x 階段、很多欄位是「已經接好線、但還沒有 consumer 去讀」。也就是說,README 描述的是願景架構,程式碼是當下版本。所以評估任何壓縮工具的時候都要記得:別照著它的能力宣稱去做架構決策,要去看程式碼此刻到底真正做了什麼。
順帶提醒,那些九成二、八成七的壓縮率,都是搜尋結果、log 這種高冗餘場景特別挑出來的。ML 模型本身,對一般散文預設只壓百分之十八。所以一般對話,千萬別期待九成以上。
那總結一下。Headroom 真正的技術亮點有三個,而且都可以拆出來單獨學。第一,mask-based 抽取——結構用規則保證、語意才交給模型,把有損壓縮的風險框死。第二,也是最值得學的,快取變異經濟學——用成本模型決定要不要壓,而不是盲目壓;只要你在 Anthropic 或 OpenAI 上吃 prompt caching,這條公式都值得借鏡。第三,CCR 可逆性——把有損壓縮降級成延遲載入。
該保留懷疑的地方也很清楚:文件超前實作、壓縮率是特挑場景、單一作者的早期專案。如果你只是單一供應商、量也不大,原生的 context 管理可能就夠了。但如果你跑的是多 agent、跨供應商的日常開發流,又對 token 帳單很有感,那 Headroom 的設計思路至少值得你讀一遍——就算最後不直接用它,光那條 cache 變異公式,可能就夠你回本了。
Tags
Related Articles
Harness Engineering (2): Five Engineering Answers from OpenAI's Million-Line Experiment
Three OpenAI engineers, five months, one million lines of AI-generated code, zero hand-written. The real value of this experiment isn't the numbers — it's the proof that Harness design can be engineered. Five concrete practices: making the app legible to agents, treating the repo as the source of truth, mechanizing architectural constraints, rewriting merge philosophy, and background entropy management.
Harness Engineering (3): Industry Consensus, Four Pillars, and a Three-Phase Rollout
Distilling Harness Engineering from concept and benchmark case into something you can start executing today: the four fixed failure modes of Agents, the 40% context sweet spot, the four-pillar framework the industry has converged on, and a three-phase roadmap from 'this afternoon' to 'fully automated in two weeks' — closing with six industry consensus points and three still-unsolved problems.
Sakana Fugu vs OpenRouter Fusion: Two Ways to Wrap a Multi-Agent System in a Single Model
Two 2026 products answering the same question: when a single model hits its ceiling, don't pick one model — orchestrate a pool of them behind one API. Fugu bets on learned coordination; Fusion bets on parallel deliberation plus a judge.