-
Notifications
You must be signed in to change notification settings - Fork 3.6k
Description
Description
Package Versions:
"@ai-sdk/anthropic": "^1.2.10",
"ai": "^4.0.22",
My code setting up the system message:
const systemMessages = [
{
role: 'system' as const,
content: systemPrompt,
providerOptions: {
anthropic: { cacheControl: { type: 'ephemeral' } },
},
},
];
* My system prompt is approx 36K characters.
The code runs fine, returning a response and the following usage info..
"finishReason":"stop","usage":{"promptTokens":11323,"completionTokens":467,"totalTokens":11790},"
however on the second run, ran 30 seconds later to ensure the cache is primed, you can see the prompt caching results is empty... (although the usage tokens are as above)
,"providerMetadata":{"anthropic":{"cacheCreationInputTokens":0,"cacheReadInputTokens":0}},"experimental_providerMetadata":{"anthropic":{"cacheCreationInputTokens":0,"cacheReadInputTokens":0}},"isContinued":false}]}
To try and figure out what was going on, i've routed it through Helicone to see the raw request...
and you can see that the cache control properties are not present..
Helicone raw request:
{
"model": "claude-3-5-haiku-20241022",
"max_tokens": 1000,
"temperature": 0,
"system": [
{
"type": "text",
"text": "You are an exper... [40,000 characters more]"
}
],
"messages": [
{
"role": "assistant",
"content": [
{
"type": "text",
"text": "Hello... I'm your smart assistant. Ask me anything and i'll try to answer your questions. "
}
]
},
{
"role": "user",
"content": [
{
"type": "text",
"text": "Summarize the strengths and weaknesses"
}
]
}
]
}
This worked ok in "@ai-sdk/anthropic": "^1.0.6",