Skip to content

Commit 5972e59

Browse files
committed
fix: token caching
1 parent 5394854 commit 5972e59

File tree

1 file changed

+10
-7
lines changed

1 file changed

+10
-7
lines changed

packages/agent/src/core/llm/providers/anthropic.ts

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -57,13 +57,16 @@ function addCacheControlToMessages(
5757
if (typeof m.content === 'string') {
5858
return {
5959
...m,
60-
content: [
61-
{
62-
type: 'text',
63-
text: m.content,
64-
cache_control: { type: 'ephemeral' },
65-
},
66-
],
60+
content:
61+
i >= messages.length - 2
62+
? [
63+
{
64+
type: 'text',
65+
text: m.content,
66+
cache_control: { type: 'ephemeral' },
67+
},
68+
]
69+
: m.content,
6770
};
6871
}
6972
return {

0 commit comments

Comments
 (0)