Architecting efficient context-aware multi-agent framework for production
context-engineeringmulti-agentgoogle-adkcontext-compactionproductionagent-framework
Abstraction: Context engineering architecture in Google ADK agents
Key points:
- Google's Agent Development Kit (ADK) treats "context engineering" as systems engineering, not prompt gymnastics; core thesis: context is a compiled view over a richer stateful system, not a mutable string buffer.
- Tiered storage separates Session (ground-truth, strongly-typed Event records) from the ephemeral Working Context (a computed projection rebuilt each invocation via ordered request/response processors in an LLM Flow).
- Context Compaction: at a configurable threshold, an async LLM summarizes older events over a sliding window and writes a "compaction" event, letting raw events be pruned. Filtering offers deterministic rule-based reduction.
- Optimizations: prefix/context caching via
static instructionimmutability keeps cache prefix valid; Artifacts (handle pattern viaArtifactService+LoadArtifactsTool) keep large data (5MB CSVs, PDFs) out of the prompt with ephemeral expansion; Memory (MemoryService) provides searchable, agent-directed long-term knowledge over a vector/keyword corpus. - Multi-agent scoping prevents context explosion: two patterns — Agents-as-Tools (callee sees only focused prompt) and Agent Transfer/Hierarchy (control handed off).
include_contentsknob controls how much history flows; ADK reframes prior agents' messages as[For context]: Agent B said...so a sub-agent doesn't misattribute actions to itself.
Connections: Google ADK · Context Engineering · Multi Agent Systems · Prompt Caching · AI Agents