Skip to content

fix: fingerprint cacheable context prefix#6067

Open
he-yufeng wants to merge 1 commit into
google:mainfrom
he-yufeng:fix/context-cache-dynamic-instruction
Open

fix: fingerprint cacheable context prefix#6067
he-yufeng wants to merge 1 commit into
google:mainfrom
he-yufeng:fix/context-cache-dynamic-instruction

Conversation

@he-yufeng

@he-yufeng he-yufeng commented Jun 10, 2026

Copy link
Copy Markdown
Contributor

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:

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.

@adk-bot

adk-bot commented Jun 10, 2026

Copy link
Copy Markdown
Collaborator

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:

  1. A testing plan section describing how you tested your changes (as requested in our Contribution Guidelines).
  2. Logs or verification output (such as the output of the passed pytest results) showing that the tests run successfully after your changes.

Thank you for your help in keeping the codebase robust!

@he-yufeng he-yufeng force-pushed the fix/context-cache-dynamic-instruction branch from 778780d to 02135c2 Compare June 10, 2026 19:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Explicit context cache never engages (cache_name always None) when a dynamic instruction coexists with static_instruction

2 participants