Google ADK: context caching with cached_content (constraints on tools and system instruction)

Passing a GenerateContentConfig(cached_content=cache.name) to an ADK LlmAgent failed with a 400 INVALID_ARGUMENT error. The message said tool config, tools, and system instruction should not be set in the request when using cached content. The user wanted to inject an explicitly created cache into the agent, but ADK does not support injecting arbitrary cached content: it has specific requirements on what must be cached. Separately, the adk web CLI in 1.51.1 had bugs loading cache configs, fixed on the main branch.

Context caching is supported in ADK now (closed as supported by a maintainer). Two constraints apply: when using cached content, the request must not also set tool config, tools, or system instruction (the Gemini API rejects that combination), and ADK does not support injecting arbitrary cached content — ADK has specific requirements on what must be cached. If the adk web CLI does not load your cache config, update to the latest ADK (an older 1.51.x CLI had bugs fixed on main). Source: https://github.com/google/adk-python/issues/211