← Back to blog
GoodMem: Adding Persistent Memory to Your AI Agent

GoodMem: Adding Persistent Memory to Your AI Agent

AI agents are great at conversation. They can answer questions, generate content, and use tools. But they forget everything the moment the session ends.

This is a problem when you're building something like a language AI tutor. The agent needs to remember what the student already learned, which quiz answers they got wrong, and what topics to revisit. Without memory, every session starts from zero.

GoodMem solves this. It's a self-hosted memory server that gives AI agents persistent, searchable memory across sessions.

The Problem

I built an Italian language tutor using Google ADK (Agent Development Kit). The agent - named Marco - teaches vocabulary, explains grammar, and runs quizzes. It works well within a single session.

But when the user comes back the next day and asks "what mistakes did I make in my last quiz?", Marco has no idea. The conversation history is gone. The agent can't adapt to the student's level because it doesn't remember what level they're at.

  • User: What mistakes did I make last time?
  • Marco: Hmm, it looks like I don't have any memories about quizzes! Maybe that means you did really well...

That’s not a tutor - that’s a goldfish.

What GoodMem Does

GoodMem is a self-hosted memory server that runs via Docker. It stores conversation chunks as vector embeddings and retrieves them using semantic search.

sequenceDiagram
    participant User
    participant Agent (Marco)
    participant GoodMem
    participant LLM (Gemini)

    User->>Agent (Marco): "What mistakes did I make?"
    Agent (Marco)->>GoodMem: Fetch memories about quiz mistakes
    GoodMem-->>Agent (Marco): Previous quiz results, weak topics
    Agent (Marco)->>LLM (Gemini): User question + memory context
    LLM (Gemini)-->>Agent (Marco): Personalized response
    Agent (Marco)-->>User: "Last time you confused gelato and acqua..."
    Agent (Marco)->>GoodMem: Store this conversation turn

It integrates through two mechanisms:

  • Plugin - automatically stores and retrieves memories on every conversation turn
  • Fetch Tool - lets the agent explicitly search memory when it needs specific information

Integration with Google ADK

GoodMem provides a goodmem-adk package that plugs directly into Google ADK. Note that the ADK integration is currently Python-only - if you're working with TypeScript or another language, you'd need to use the GoodMem REST API directly.

The setup is minimal:

from google.adk.agents import LlmAgent
from google.adk.apps import App
from goodmem_adk import GoodmemPlugin, GoodmemFetchTool

# Plugin - auto-stores/retrieves every turn
goodmem_plugin = GoodmemPlugin(
    base_url="https://localhost:8080",
    api_key="your-api-key",
    space_name="italian_tutor_memory",
    top_k=5,
)

# Tool - agent can explicitly search memory
goodmem_fetch = GoodmemFetchTool(
    base_url="https://localhost:8080",
    api_key="your-api-key",
    space_name="italian_tutor_memory",
    top_k=10,
)

tutor_agent = LlmAgent(
    name="italian_tutor",
    model="gemini-2.5-flash",
    instruction="...",
    tools=[goodmem_fetch, ...],  # agent can search memory
)

app = App(
    name="italian_tutor",
    root_agent=tutor_agent,
    plugins=[goodmem_plugin],  # auto memory on every turn
)
from google.adk.agents import LlmAgent
from google.adk.apps import App
from goodmem_adk import GoodmemPlugin, GoodmemFetchTool

# Plugin - auto-stores/retrieves every turn
goodmem_plugin = GoodmemPlugin(
    base_url="https://localhost:8080",
    api_key="your-api-key",
    space_name="italian_tutor_memory",
    top_k=5,
)

# Tool - agent can explicitly search memory
goodmem_fetch = GoodmemFetchTool(
    base_url="https://localhost:8080",
    api_key="your-api-key",
    space_name="italian_tutor_memory",
    top_k=10,
)

tutor_agent = LlmAgent(
    name="italian_tutor",
    model="gemini-2.5-flash",
    instruction="...",
    tools=[goodmem_fetch, ...],  # agent can search memory
)

app = App(
    name="italian_tutor",
    root_agent=tutor_agent,
    plugins=[goodmem_plugin],  # auto memory on every turn
)

The plugin and the fetch tool share the same space_name. This is important - if they use different spaces, the agent won't find memories stored by the plugin.

Running GoodMem

GoodMem runs as a Docker Compose stack:

goodmem system start
goodmem system start

This starts the server on port 8080 (HTTPS) and 9090 (gRPC). It uses self-signed TLS certificates locally, which means you'll need to handle SSL verification in your HTTP client.

What It Looks Like in Practice

After fixing the integration, Marco can now recall previous sessions:

  • User: What mistakes did I make in my last quiz?
  • Marco: I remember! In your last food quiz you confused: - "il gelato" → you wrote "ice" instead of "ice cream" - "l'acqua" → you wrote "xyz" instead of "water" Want to practice those words?

The tutor adapts. It knows what the student struggled with and can focus on weak areas. That's the difference between a chatbot and a tutor.

Alternatives Worth Knowing

GoodMem isn't the only option for agent memory. The space is growing fast:

  • Mem0 - a drop-in memory layer that works with most agent frameworks. Offers both self-hosted and managed SaaS options. Great if you want something framework-agnostic with minimal setup.
  • Letta (formerly MemGPT) - a full agent runtime with built-in tiered memory management. More opinionated than GoodMem - it's not just a memory layer, it's an entire agent platform.
  • Zep - focuses on temporal knowledge graphs and relationship tracking. Good fit if your agent needs to understand how entities relate to each other over time.

Each takes a different approach. GoodMem and Mem0 are memory layers you bolt onto existing agents. Letta is a full runtime. Zep is more about structured knowledge. Pick based on how much control you want and what framework you're already using.

Takeaway

Most frameworks treat agents as stateless - you get a conversation, and then it's gone. For applications where continuity matters (tutoring, coaching, personal assistants), persistent memory is essential.

The goodmem-adk integration makes it straightforward with Google ADK. Two objects - a plugin and a tool - and your agent remembers everything.

Resources

Comments

Comments are disabled until analytics consent is granted.