Skip to content

Memory: Long-term knowledge with MemoryService

Supported in ADKPython v0.1.0TypeScript v0.2.0Go v0.1.0Java v0.1.0Kotlin v0.1.0

While a Session tracks the history (events) and temporary data (state) of a single conversation, an agent may need to recall information from past interactions. This is where the concept of Long-Term Knowledge and the MemoryService come into play. Think of it this way:

  • Session / State: It's your short-term memory during one specific chat.
  • Long-Term Knowledge (MemoryService): It's a searchable archive or knowledge library the agent can consult, potentially containing information from many past chats or other sources.

The MemoryService role

The BaseMemoryService (or Service in Go) defines the interface for managing this searchable, long-term knowledge store. It supports these operations:

  • Ingesting Information:
    • add_session_to_memory: Takes a completed Session and adds relevant information to the long-term knowledge store. This approach is ideal for automatically capturing the essence of a conversation.
    • add_events_to_memory: Appends a delta of events (for example, the latest turn) without re-ingesting the full session. Useful when you want to write to memory partway through a long-running session.
    • add_memory: Adds explicit MemoryEntry objects directly to the memory. This method gives you fine-grained control and is useful for injecting specific facts from other sources.
  • Searching Information (search_memory): Lets an agent (typically via a