]> git.djapps.eu Git - pkg/ggml/sources/llama.cpp/commit
server: (anthropic API) fix prefix caching (#21793)
authorkvc0 <redacted>
Thu, 23 Apr 2026 15:45:02 +0000 (08:45 -0700)
committerGitHub <redacted>
Thu, 23 Apr 2026 15:45:02 +0000 (17:45 +0200)
commitc807c6e3b0c74b77ad4c7a8213a1d5690d34e462
tree0d20888c533dcdbae551aa52e0edc5fb6d0c61ea
parent0949beb5a3fc02adf0558d0f6736f1011c10891c
server: (anthropic API) fix prefix caching (#21793)

When testing claude code against llama.cpp, I noticed that only
n_past 18577 was used even when context was 60k or more. The log
in llama-server says:
```
slot update_slots: id  3 | task 10342 | old: ... ; cch= | defa0;You are
slot update_slots: id  3 | task 10342 | new: ... ; cch= | 1c8b4;
```
I observed that the cch value changed every time. Reading about that,
the x-anthropic-billing-header system message seems to be specially
handled inside of the anthropic api. I could remove it, but there
is a meaningful string sometimes included at the end. So instead,
I just replace the changing cch checksum with fffff.

I'm treating this as an anthropic message body API detail - I think this
is the right way to do this, but by all means please correct me!

It's always 5 hexadecimal characters, but I've written the replacement
defensively in case they change the protocol.
tools/server/server-chat.cpp