mirror of
https://github.com/google/adk-docs.git
synced 2026-09-14 16:16:59 +08:00
718bcf5c6d
* Document how to check whether the context cache was used The caching page explained how to turn caching on and never how to tell whether it is working. CacheMetadata has been available since adk-kotlin 0.6.0 and is undocumented: adk-python has fourteen code references to cache_metadata, while adk-docs mentions it twice, both incidental -- a BigQuery schema table and a bullet in the Live dev guide. The snippet reads it from Event.cacheMetadata and covers both states the type can be in, because the constructor enforces the split: cacheName, expireTime and invocationsUsed must either all be set (an active cache) or all be null (the fingerprint-only state used for prefix matching before a cache exists). Notes that token counts live on LlmResponse.usageMetadata rather than here, which the KDoc calls out to avoid duplication and a reader would otherwise reasonably look for on CacheMetadata. Badged Kotlin v0.6.0 and verified rather than assumed: the snippet compiles against a temporary 0.6.0 pin as well as the current 0.7.0 one. Transcluded and registered, so CI compiles and lints it. Exercised all four paths with synthetic events: no metadata, fingerprint-only, active, and active with expireSoon true. * Correct when CacheMetadata is present on an event The section claimed every event backed by an LLM response carries a CacheMetadata. It does not: LlmResponse.cacheMetadata is null when caching is disabled and also when the call produced no cache information, so the claim was wrong even with caching on. Say "can carry", name both null cases, and explain why the snippet checks before reading. The snippet's own comment made the same overstatement. * docs: clarify the behavior of expireSoon and cache status in documentation and snippets