Repository navigation
feat(ai): cache Claude prompts and price the cache tokens - #5577
Merged
Merged
Conversation
Owner
Author
Checks run before the push (head
|
This was referenced Nov 14, 2026
dan-petty
force-pushed
the
feat/3658-claude-prompt-cache
branch
from
November 14, 2026 00:20
a8877fc to
25977a4
Compare
Owner
Author
|
Push
|
…okens The plan of the gateway cache points of the two Claude groups and of the cache read and cache write tokens of the spend ledger.
Each Claude group of the gateway sets two LiteLLM cache injection points: the system messages and the last message. Anthropic then caches the tools, the system prompt and the history of an agent run. The spend ledger keeps the cache read and cache write tokens of each call in two new columns, and genai-prices prices both at the cache rates of the model. The spend hook of build_agent, record_run_spend and the chat calls of LLMClient give the cache write tokens. The gateway test fails when a Claude group loses a point or another group gets one. Closes #3658
…plan A request that no request follows within 5 minutes, such as a refine_judge review, writes the part after the system point at 1.25 times the input price and reads none of it. The design now names that cost and the metric that shows it.
record_run_spend takes its model as Any, so the ignore suppressed nothing. It put the tests one over the type-ignore ceiling of test_suppressions_stay_under_their_ceilings.
…e tokens The gateway spec gets the requirement that a Claude group caches its prompt prefix. The spend pricing spec gets the cache token columns, the cache write rate and the callers that give the cache write tokens.
dan-petty
force-pushed
the
feat/3658-claude-prompt-cache
branch
from
November 14, 2026 01:19
25977a4 to
de1dfb1
Compare
dan-petty
marked this pull request as ready for review
November 14, 2026 01:35
dan-petty-release Bot
added a commit
that referenced
this pull request
Nov 14, 2026
🤖 I have created a release *beep* *boop* --- ## [0.135.0](v0.134.1...v0.135.0) (2026-11-14) ### Features * **ai:** cache Claude prompts and price the cache tokens ([#5577](#5577)) ([a42931c](a42931c)) ### Bug Fixes * **k8s:** the DeepSeek group keeps its structured reply flag ([#5572](#5572)) ([ffce5d9](ffce5d9)) * **security:** bump helm to 4.3.2 and renew the kubectl Trivy ignores ([#5584](#5584)) ([7b27444](7b27444)) --- This PR was generated with [Release Please](https://github.com/googleapis/release-please). See [documentation](https://github.com/googleapis/release-please#release-please). Co-authored-by: dan-petty-release[bot] <346998822+dan-petty-release[bot]@users.noreply.github.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Each Claude group of the gateway now asks Anthropic to cache its prompt prefix.
claude-sonnet-5-5andclaude-haiku-5-5set two LiteLLM cache injection points: one on the system messages, which caches the tools and the system prompt, and one on the last message, which caches the history of an agent run. Before, each Claude request paid the full input price for each prompt token, and an agent run sends its full history again on each request.The spend ledger now keeps the cache read and cache write tokens of each call in two new columns, and genai-prices prices both at the cache rates of the model. Before, a cache write cost the input price, and no row showed the counts. The spend hook of
build_agent,record_run_spendand the chat calls ofLLMClientgive the cache write count. A gateway test fails when a Claude group loses a point or another group sets one.Closes #3658
Change:
openspec/changes/archive/2026-11-13-3658-cache-claude-prompts-and-price-the/