Memory Eviction and Consolidation Strategies: Keeping Memories High-Signal
Consolidation is a real Memory Bank feature (enable_consolidation flips memories.create to memories.generate); eviction is a design pattern you build around ADK's MemoryService. This article shows both honestly.
Published on • December 3, 2026
AI Assistant

A memory store that only ever grows is not a memory — it is a landfill. Every near-duplicate preference, every superseded fact, and every stale project name you ingest makes the next search_memory call noisier, until the agent’s “profile” reads like a changelog and the model starts contradicting itself based on which fragment it retrieved.
The instinct is to reach for an eviction API: TTLs, LRU caps, a delete_memory() call. ADK does not give you one. The BaseMemoryService interface is four operations — add_session_to_memory, add_events_to_memory, add_memory, and search_memory — and none of them deletes. So the honest answer splits in two: consolidation is a real, built-in capability you should switch on, and eviction is a set of design patterns you build around the service, mostly by being disciplined about what enters in the first place.
Prerequisites
- An ADK app with a
Runnerand a configuredMemoryService. - For consolidation: a Google Cloud project, an Agent Runtime on Agent Platform,
gcloud auth application-default login, andGOOGLE_CLOUD_PROJECT/GOOGLE_CLOUD_LOCATIONexported. - Read the companion tutorial on
preload_memoryif you have not wired memory retrieval yet.
1. What consolidation actually is
Consolidation is not an eviction policy. It is a write-time behavior of VertexAiMemoryBankService.add_memory that decides how a new memory relates to what already exists.
The custom_metadata flag selects the underlying Memory Bank API:
from google.adk.memory import VertexAiMemoryBankService
from google.adk.memory.memory_entry import MemoryEntry
from google.genai.types import Content, Part
memory_service = VertexAiMemoryBankService(
project="your-gcp-project-id",
location="your-gcp-location",
agent_engine_id="1234567890",
)
# Default: memories.create — each entry is a distinct, separate item.
await memory_service.add_memory(
app_name="my-app",
user_id="user-123",
memories=[
MemoryEntry(content=Content(parts=[Part(text="The user's favorite color is blue.")]))
],
)
# Consolidating: memories.generate — merges with related existing memories.
await memory_service.add_memory(
app_name="my-app",
user_id="user-123",
memories=[
MemoryEntry(content=Content(parts=[Part(text="The user's favorite color is light blue.")]))
],
custom_metadata={"enable_consolidation": True},
)
The second call does not append a contradiction — it consolidates “favorite color is blue” and “favorite color is light blue” into a coherent memory. That is redundancy control at the storage layer, and it is the closest thing to “cleaning up” that the ADK interface offers directly.
| Write mode | Memory Bank API | Result | When to use |
|---|---|---|---|
| Default | memories.create | Distinct, separate memory items | Facts that are genuinely new dimensions |
enable_consolidation: True | memories.generate | New item merged with related existing memories | Updates, corrections, overlapping facts |
Note that Memory Bank’s session extraction path also consolidates: it extracts meaningful information from conversations and consolidates it with existing memories using an LLM. So the managed service is already fighting redundancy on both the ingestion and (optionally) the direct-write path.
2. Why you still need an eviction strategy
Consolidation handles redundancy. It does not handle:
- Relevance decay — a fact that was true in March and is false now.
- Ingestion volume — every completed session pushed via
add_session_to_memoryadds extraction load and potential fragments. - Signal dilution — search returns snippets; more stored material means more chances for the wrong snippet to win.
Since the MemoryService interface exposes no delete, your eviction levers are upstream (control what enters), sideways (control what you ask for), or down at the backing-service level (manage data in the Google Cloud service itself, outside the ADK interface). Upstream is where almost all the value is.
3. Pattern: gate the ingestion path
The simplest high-signal strategy is to stop treating add_session_to_memory as unconditional. Ingest selectively:
async def selective_save_callback(callback_context):
session = callback_context.invocation_context.session
# Heuristic: only persist turns that produced a durable fact.
if session.state.get("captured_new_fact"):
await callback_context.add_session_to_memory()
The captured_new_fact flag can be set by a tool that noticed the user state a preference (state_delta through an event), or by evaluating the session before pushing it. The principle: memory ingestion is a decision, not a side effect. Every session you decline to ingest is eviction that never has to happen.
4. Pattern: delta ingestion over whole-session replay
For long-running sessions, re-ingesting the entire conversation each time re-processes everything — including parts already distilled. ADK’s interface has a purpose-built alternative:
# Ingest only the latest turn, not the full session history.
await memory_service.add_events_to_memory(
app_name=app_name, user_id=user_id, events=session.events[-2:]
)
add_events_to_memory appends a delta of events without re-ingesting the full session. Less raw material in, less duplication created, less consolidation work for the service. (Confirm your implementation supports it — it is optional on BaseMemoryService.)
5. Pattern: curate instead of accumulate
For facts you already know are canonical — role, timezone, plan tier — bypass conversation extraction entirely with explicit MemoryEntry writes using enable_consolidation: True. This gives you one authoritative memory per dimension rather than a trail of “user said X” fragments across months of chats. Curated writes are the application-level equivalent of pinning a value: new information consolidates into the fact instead of beside it.
6. Pattern: bound the read side
Eviction also works in reverse — you cannot always control what is stored, but you always control what reaches the model:
- Prefer
preload_memoryfor a bounded profile head start over dumping raw search results into context. - Use
tool_context.search_memory(query)with specific, scoped queries rather than broad ones that match everything. - Treat
VertexAiRagMemoryService’ssimilarity_top_kandvector_distance_thresholdas recall-precision dials when you retrieve over transcripts.
| Lever | Layer | Mechanism |
|---|---|---|
| Gate ingestion | Application | Conditional add_session_to_memory |
| Delta ingestion | ADK API | add_events_to_memory |
| Deduplicate writes | Memory Bank | enable_consolidation: True → memories.generate |
| Curate canonical facts | Application | Explicit add_memory with MemoryEntry |
| Bound retrieval | Read path | preload_memory, scoped queries, RAG thresholds |
| Delete / TTL | Not in ADK’s interface | Manage at the backing Google Cloud service |
Checklist
-
enable_consolidation: Trueis set on overlapping or correctiveadd_memorywrites. - Default
memories.createis used only for genuinely new memory dimensions. - Ingestion is gated — sessions are pushed only when they contain durable facts.
- Long sessions use
add_events_to_memorydeltas instead of full-session replay. - Canonical profile facts are curated via explicit
MemoryEntry, not left to extraction drift. - Retrieval is bounded:
preload_memoryfor head starts, scoped queries for deep search. - The team understands ADK’s
MemoryServicehas no delete/TTL — eviction is upstream or at the backing service. - Search quality is monitored: if the model contradicts itself, audit stored fragments before tuning prompts.
Conclusion
Consolidation in ADK is concrete: one flag on add_memory switches Memory Bank from appending duplicates to merging related facts. Eviction, by contrast, is not an API you call but a discipline you design in — gate what enters, ingest deltas rather than replays, curate the facts that must be canonical, and bound what retrieval hands to the model. Do that, and your memory store stays a high-signal profile instead of an ever-growing transcript graveyard.