fix: fingerprint cacheable context prefix#6067
Conversation
|
Response from ADK Triaging Agent Hello @he-yufeng, thank you for submitting this pull request! This is a bug fix (associated with #6062). To help reviewers process your contribution more efficiently, could you please update the PR to include:
Thank you for your help in keeping the codebase robust! |
778780d to
02135c2
Compare
|
Hi @he-yufeng , Thank you for your contribution! We appreciate you taking the time to submit this pull request. Please fix formatting errors. |
62773e9 to
3e848fb
Compare
|
Pushed an updated branch with the formatting fix and rebased it onto current main. Validation:
|
8dbc9cc to
de5b663
Compare
|
Rebased this on current
The focused test run passed with 30 tests. |
fc2eaac to
44dc7bf
Compare
|
Rebased this onto current Current head: Validation:
|
01942ca to
1bcedc7
Compare
1bcedc7 to
b94362f
Compare
Merge #6067 ## Summary - Use the cacheable content prefix for fingerprint-only cache metadata instead of the full request contents. - Keep request-scoped dynamic instruction contents out of the initial fingerprint chain. - Update `CacheMetadata.contents_count` docs to match the prefix semantics. Fixes #6062. ## Testing plan This PR is covered by focused unit tests for the Gemini context cache manager. The important behavior is that cache fingerprints are derived only from the cacheable prefix, while request-local dynamic instructions still flow into the request without changing the cache identity. ## Verification output Run locally on Windows with Python 3.13: ```text python -m py_compile src\google\adk\models\gemini_context_cache_manager.py src\google\adk\models\cache_metadata.py # passed PYTHONPATH=src python -m pytest tests\unittests\agents\test_gemini_context_cache_manager.py -q # passed python -m ruff check src\google\adk\models\gemini_context_cache_manager.py src\google\adk\models\cache_metadata.py tests\unittests\agents\test_gemini_context_cache_manager.py # passed git diff --check # passed ``` ## Risk Low. The patch narrows what contributes to fingerprint-only cache metadata; it does not change response generation, model selection, or live cache service calls. Co-authored-by: George Weale <gweale@google.com> COPYBARA_INTEGRATE_REVIEW=#6067 from he-yufeng:fix/context-cache-dynamic-instruction 44dc7bf PiperOrigin-RevId: 936129492
|
Thank you @he-yufeng for your contribution! 🎉 Your changes have been successfully imported and merged via Copybara in commit 7c7f1e7. Closing this PR as the changes are now in the main branch. |
Summary
CacheMetadata.contents_countdocs to match the prefix semantics.Fixes #6062.
Testing plan
This PR is covered by focused unit tests for the Gemini context cache manager. The important behavior is that cache fingerprints are derived only from the cacheable prefix, while request-local dynamic instructions still flow into the request without changing the cache identity.
Verification output
Run locally on Windows with Python 3.13:
Risk
Low. The patch narrows what contributes to fingerprint-only cache metadata; it does not change response generation, model selection, or live cache service calls.