feat: add create_http_options to ContextCacheConfig for cache creation timeout#4702
feat: add create_http_options to ContextCacheConfig for cache creation timeout#4702abhinavmaddineni wants to merge 5 commits intogoogle:mainfrom
Conversation
|
Thanks for your pull request! It looks like this may be your first contribution to a Google open source project. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA). View this failed invocation of the CLA check for more information. For the most up to date status, view the checks section at the bottom of the pull request. |
Summary of ChangesHello, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed! This pull request introduces a significant performance improvement for context caching by enabling asynchronous cache creation. By adding an Highlights
🧠 New Feature in Public Preview: You can now enable Memory to help Gemini Code Assist learn from your team's feedback. This makes future code reviews more consistent and personalized to your project's style. Click here to enable Memory in your admin console. Changelog
Activity
Using Gemini Code AssistThe full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips. Invoking Gemini You can request assistance from Gemini at any point by creating a comment using either
Customization To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a Limitations & Feedback Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here. You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension. Footnotes
|
|
Response from ADK Triaging Agent Hello @abhinavmaddineni, thank you for creating this PR! Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA). You can find more information at https://cla.developers.google.com/. Also, for a new feature, could you please create a GitHub issue and associate it with this PR? This information will help reviewers to review your PR more efficiently. Thanks! |
CachedContent.create() API calls can take 30-40 seconds, blocking the user's request when a cache needs to be recreated. This adds an `async_creation` config option that defers cache creation to a background asyncio task, letting the current request proceed uncached while the cache is built for the next request. When async_creation=False (default), behavior is completely unchanged.
107ad40 to
452a9fa
Compare
There was a problem hiding this comment.
Code Review
This pull request introduces a valuable feature for asynchronous context cache creation, which should significantly improve latency in cache miss scenarios. The overall design, using a module-level task registry and snapshotting request data, is sound. However, I've identified a potential bug in the stale task cleanup logic that could lead to crashes and have suggested a more robust implementation. Additionally, I recommend adding unit tests for the new asynchronous pathways to ensure the long-term stability and maintainability of this complex but important feature.
Note: Security Review is unavailable for this PR.
…n timeout Adds a `create_http_options` field to `ContextCacheConfig` that is passed through to `CreateCachedContentConfig` when creating a cache. This allows users to set a timeout (or other HTTP options) on the CachedContent.create() call, which can take 30-40 seconds on Vertex AI. When the timeout is exceeded, cache creation fails gracefully and the request proceeds without caching. Replaces the previous `async_creation` approach which required global in-memory state that didn't scale across instances. Fixes google#4703
|
Hi @abhinavmaddineni , Thank you for your contribution! We appreciate you taking the time to submit this pull request.
|
…matting - Add null guard for cache_config before accessing create_http_options (mypy union-attr) - Update test_runner_realistic_cache_config_scenario expected str to include new field - Apply pyink formatting to comply with Google style
9cbf285 to
e1f12c8
Compare
|
Hi @rohityan, thanks for the feedback! I've pushed a fix that should address all the CI failures (mypy, tests, formatting). Regarding the feature itself: this adds an optional Why client-level Related issue: #4703 |
Summary
create_http_options: Optional[types.HttpOptions]toContextCacheConfig— passed through toCreateCachedContentConfigwhen creating a cacheCachedContent.create()calls, which can take 30-40s on Vertex AIasync_creationfield which required global in-memory stateUsage
Test plan
create_http_optionsis passed through toCreateCachedContentConfigcreate_http_optionsworks as beforecreate_http_options=None) is unchangedFixes #4703