Skip to content

Commit a95075d

Browse files
committed
fixup: too many breakpoints in anthropic
1 parent 9c5d051 commit a95075d

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

node/providers/anthropic.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -624,13 +624,13 @@ export function placeCacheBreakpoints(messages: MessageParam[]): number {
624624
const tokens = Math.floor(lengthAcc / STR_CHARS_PER_TOKEN);
625625

626626
// Anthropic allows for placing up to 4 cache control markers.
627-
// It will not cache anythign less than 1024 tokens for sonnet 3.5
627+
// It will not cache anything less than 1024 tokens for sonnet 3.5
628628
// https://docs.anthropic.com/en/docs/build-with-claude/prompt-caching
629629
// this is pretty rough estimate, due to the conversion between string length and tokens.
630630
// however, since we are not accounting for tools or the system prompt, and generally code and technical writing
631631
// tend to have a lower coefficient of string length to tokens (about 3.5 average sting length per token), this means
632632
// that the first cache control should be past the 1024 mark and should be cached.
633-
const powers = highestPowersOfTwo(tokens, 4).filter((n) => n >= 1024);
633+
const powers = highestPowersOfTwo(tokens, 3).filter((n) => n >= 1024);
634634
if (powers.length) {
635635
for (const power of powers) {
636636
const targetLength = power * STR_CHARS_PER_TOKEN; // power is in tokens, but we want string chars instead

0 commit comments

Comments
 (0)