fix: cache-friendly feed injection ordering in cllama#123
Merged
Conversation
Points cllama submodule at fix that appends feeds/time after the static system prompt instead of prepending. Keeps the system prompt as a stable prefix for Anthropic prompt caching (~$60/week savings on tiverton pod). Fixes #122
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.
Summary
Root Cause
InjectAnthropicandInjectOpenAIprepended dynamic content before the static system prompt. Anthropic prompt caching is prefix-matched (5-min TTL), so the volatile prefix invalidated the cache on every request — causingcache_creation_input_tokensat 1.25x cost instead ofcache_read_input_tokensat 0.1x cost for the ~120K static system prompt.Changed Files (cllama submodule)
internal/feeds/inject.go— swap prepend → append in 3 code paths (OpenAI string, Anthropic string, Anthropic content-blocks)internal/feeds/inject_test.go— update assertions to expect system-prompt-first orderinternal/proxy/handler_test.go— update 2 handler tests fromHasPrefixtoContains+ ordering assertionTest plan
go test ./...— 11 packages)cllama session-historyJSONL analysisFixes #122
🤖 Generated with Claude Code