llama.cpp normalisation of Claude Code billing header cch
Parent: Mac local LLMs: Agent clients, context and compaction · Published reference · snapshot 2026-10-05
↓ Facts as markdownall context files
The converter's code comment calls the cch stamp "a whitebox end-to-end integrity hint" that is not meaningful as system-prompt data to llama.cpp, and notes it changes on each request so the prefix cache "will not get past it".
These notes link each claim to its source. A source may be a research report hosted on this site rather than the primary document. A published reference means the content is available; it does not certify independent review or accuracy.Read the editorial policy and follow the sources before relying on a claim.
Facts
- The converter's code comment calls the cch stamp "a whitebox end-to-end integrity hint" that is not meaningful as system-prompt data to llama.cpp, and notes it changes on each request so the prefix cache "will not get past it". [source]
- The function does nothing unless the system text starts with the exact prefix `x-anthropic-billing-header:`. [source]
- The function replaces exactly five characters after `cch=` with `f` only when the character after them is `;`; otherwise it logs `anthropic string not as expected: <text>` at error level and leaves the text unchanged. [source]
- The normaliser is called both for a string-typed `system` field and for each `text` block in an array-typed `system` field, before the blocks are concatenated into one system message. [source]
- The code comment's example header is `x-anthropic-billing-header: cc_version=2.1.101.e51; cc_entrypoint=cli; cch=a5145;You are Claude Code, Anthropic's official CLI for Claude.`, so the checksum and the identity sentence can share one system text. [source]
- Before the change, the PR author saw prefix reuse stop at `n_past` about 18,577 even with a 60k context, and the `/slots` prompt diff showed line 62 (the billing header) differing while over 5,000 following lines matched. [source]
- On the second request after the change, slot selection moved from `sim_best = 0.566, f_keep = 0.704` to `sim_best = 0.805, f_keep = 1.000`, and later requests showed `sim_best = 0.994`. [source]
- The PR author reasoned the cost for non-Claude traffic is a single-position prefix check per system message, and chose to replace the value instead of deleting the header because a meaningful string sometimes follows it. [source]
- The author wrote the replacement defensively because the checksum is always five hexadecimal characters today but the protocol could change. [source]
- Reviewer ngxson approved PR 21793 on 2026-04-12 and the PR title was changed to `server: (anthropic API) fix prefix caching`; after the converter code moved, the author migrated the helper by hand, and ServeurpersoCom merged it on 2026-04-23 as commit c807c6e3b0c74b77ad4c7a8213a1d5690d34e462. [source]
- PR 21793 declares AI usage disclosure as "NO", with the code and PR text hand-written. [source]
- Inferred: a server that is not llama.cpp (oMLX, Rapid-MLX, LM Studio, Ollama) has no such normalisation in the sources read, so for them `CLAUDE_CODE_ATTRIBUTION_HEADER=0` or Claude Code v2.1.181 or later remains the control. [source]
- Inferred: the `cc_version` hash suffix is a second possible cache-breaker on Claude Code builds older than v2.1.181 that this normaliser does not touch. [source]
Children
- No children recorded.