๊ฐ€์ž… ํ›„ ์ดˆ๋Œ€ ๋งํฌ๋ฅผ ๊ณต์œ ํ•˜๋ฉด ๋™์˜์ƒ ์žฌ์ƒ ๋ฐ ์ดˆ๋Œ€ ๋ณด์ƒ์„ ๋ฐ›์„ ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค.

cv usk
@cv_usk
AI / Software Research Notes AI Agent, LLMOps, MLOps, Software Architecture ๆŠ•็จฟใฏๅ€‹ไบบใฎๆ„่ฆ‹ใงใ™ใ€‚
๊ฐ€์ž… May 2026
258 ํŒ”๋กœ์ž‰ ์ค‘    220 ํŒฌ
# Useful but Little-Known Features of ADK 2.0 ๐ŸŒ Sending the same system prompt and tool definitions to the LLM on every call wastes both money and time. What if the SDK could cache that for you? ADK 2.0's ContextCacheConfig caches repeated context data sent to the LLM, reducing both API costs and response latency. Available with Gemini 2.0+, Python v1.15.0+, and Java v0.1.0+. ๐Ÿ“Œ Title: Context Cache (ContextCacheConfig) ๐Ÿ”— URL: ๐Ÿงฉ Overview ContextCacheConfig reduces token consumption by caching context sent to the LLM โ€” system prompts, tool definitions, fixed portions of conversation history, and more. It has three key parameters: min_tokens sets the minimum token threshold for caching to activate (default 0), ttl_seconds controls cache lifetime (default 1800 seconds / 30 minutes), and cache_intervals limits maximum cache reuse count (default 10). Configure it on the App object and caching is applied automatically. ๐Ÿ›  How to use it Create a ContextCacheConfig and set it on the App. ```python from import App from google.adk.context import ContextCacheConfig cache_config = ContextCacheConfig( min_tokens=1000, # Cache only when context >= 1000 tokens ttl_seconds=3600, # Keep cache for 1 hour cache_intervals=20, # Reuse up to 20 times ) app = App( agent=my_agent, context_cache_config=cache_config, ) ``` Setting min_tokens appropriately ensures that small contexts are sent normally while large contexts benefit from caching. ๐Ÿ— Building it into production ใƒปAgents with large system prompts or many tool definitions benefit the most from caching ใƒปTune ttl_seconds to match your workload pattern (short conversations โ†’ shorter TTL, long ones โ†’ longer TTL) ใƒปAdjust cache_intervals based on request frequency to balance freshness and cost savings ใƒปMonitor cost reduction metrics and continuously optimize parameters ๐Ÿ’ก Use cases ๐Ÿ’ฐ Cut API costs for agents with large, stable system prompts โšก Reduce response latency by skipping repeated tool definition transmission ๐Ÿ” Optimize token consumption for high-frequency chatbot interactions ๐Ÿ“‹ Efficiently handle fixed context (rules, guidelines, policies) that rarely changes โš ๏ธ Watch out This feature requires Gemini 2.0 or later. Context changes won't take effect while a cache is active, so set a shorter ttl_seconds if you frequently update system prompts. When cache_intervals is exceeded, a new cache is created, which can cause cost optimization effects to fluctuate. โœจ Context caching delivers significant cost and performance improvements, especially in scenarios with large, frequently-accessed context. It's a quick win for production deployments. #ADK# #AIAgent#
๋” ๋ณด๊ธฐ