-
Notifications
You must be signed in to change notification settings - Fork 2.4k
Google Gen AI: Context caching breaks with generateObject / generateContent - #3333
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
I can see how this happens with tool mode. Can you try |
@lgrammel Added that but still same error unfortunately. |
still no solution? |
I have started to get this error too in code that was working before |
it seems that now only version 1.5-001 supports cached content, lol. |
Confirmed. caching is still working with 1.5-001. Not sure what that means for the future. I hope this is just a temporary mistake. The 1.5 models are supposed to be "stable". 1.5-001 seems to be much stricter with the minimum token requirements though. I did not need anywhere near as many tokens to create a cache with 1.5-002 when it was working. |
Here's a method described that I use to make context caching work, even with function calling. It's hacky and could use some improvements in the SDK to better facilitate this. |
Uh oh!
There was an error while loading. Please reload this page.
Description
Hi there,
I'm trying to implement context caching with the Gemini models, but it keeps returning an error saying:
But I'm not passing in system_instruction, tools, or tool_config in my request. Not sure if I'm doing something wrong here?
It seems to work fine with
generateText
, however as soon as I use generateObject or generateContent it fails with that error.Also just to clarify, if the system prompt is already included in the cacheManager, I don't need to specify it again in the generateObject right?
Code example
Here is the full error, you can see in the requestBodyValues there is a systemInstruction object being passed, potentially being injected by the SDK? perhaps that is the issue?
Additional context
"@ai-sdk/google": "^0.0.51",
"ai": "^3.4.18",
"@google/generative-ai": "^0.21.0",
The text was updated successfully, but these errors were encountered: