Skip to content

Conversation

dlants
Copy link
Owner

@dlants dlants commented Jan 12, 2025

implementing prompt caching for anthropic.

Anthropic provides up to 4 cache breakpoints. I'm basically using them to mark off as much of the prompt as I can, in powers of 2.

So if the prompt is 5000 tokens, we'll put cache markers at messages at the 4096, 2048 and 1024 mark. (1024 being the minimum that anthropic can cache).

(see https://docs.anthropic.com/en/docs/build-with-claude/prompt-caching for details)

I think this is a pretty decent strategy to make sure that we're reusing as much context as we can while allowing for things to change as files update and move up in the message stream (due to the smart context placement I implemented here: #24

@dlants dlants merged commit 793fcea into main Jan 12, 2025
1 check passed
@dlants dlants deleted the prompt-caching branch January 12, 2025 20:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant