{
  "id": "redis-agent-memory",
  "title": "Redis Agent Memory",
  "url": "https://redis.io/docs/latest/integrate/google-adk/redis-agent-memory/",
  "summary": "Working and long-term memory for Google ADK agents using the Redis Agent Memory Server.",
  "tags": [
    "docs",
    "integrate",
    "oss",
    "rs",
    "rc"
  ],
  "last_updated": "2026-04-15T13:31:09-05:00",
  "page_type": "content",
  "content_hash": "ba3da545d292a7784492bbb7b8d34c27123bfe5845c1ebe87a05e09194250a18",
  "sections": [
    {
      "id": "overview",
      "title": "Overview",
      "role": "overview",
      "text": "Redis Agent Memory gives ADK agents two tiers of persistent memory, backed by the [Redis Agent Memory Server](https://github.com/redis/agent-memory-server):\n\n- **Working memory** — session-scoped storage for the current conversation, with automatic summarization when context grows long.\n- **Long-term memory** — facts extracted from past conversations, stored as vectors in Redis and searchable by semantic similarity with optional recency boosting.\n\nYou can wire these tiers into an ADK agent three ways:\n\n| Approach | Control | Best for |\n|----------|---------|----------|\n| **Framework services** | ADK Runner (automatic) | Invisible infrastructure |\n| **REST tools** | LLM (explicit) | Agent autonomy over memory |\n| **MCP tools** | LLM via MCP protocol | Portable, standardized |\n\nSee [Integration patterns]() for detailed tradeoff comparison."
    },
    {
      "id": "working-memory",
      "title": "Working memory",
      "role": "content",
      "text": "`RedisWorkingMemorySessionService` implements ADK's `BaseSessionService`. It stores the current conversation in the Redis Agent Memory Server and automatically summarizes older messages when the context window limit is approached.\n\n[code example]"
    },
    {
      "id": "configuration",
      "title": "Configuration",
      "role": "configuration",
      "text": "| Parameter | Description | Default |\n|-----------|-------------|---------|\n| `api_base_url` | Agent Memory Server URL | Required |\n| `default_namespace` | Isolates data between applications | Required |\n| `model_name` | LLM used for summarization | `None` |\n| `context_window_max` | Token limit that triggers summarization | `None` |"
    },
    {
      "id": "auto-summarization",
      "title": "Auto-summarization",
      "role": "content",
      "text": "When the token count of stored messages crosses `context_window_max`, the Agent Memory Server uses the model specified in `model_name` to summarize older turns. Recent messages are preserved in full. This avoids the hard tradeoff between truncating context (losing information) and sending the full conversation (hitting token limits and costs)."
    },
    {
      "id": "incremental-appends",
      "title": "Incremental appends",
      "role": "content",
      "text": "The session service uses an incremental append API: it sends only new messages rather than re-sending the entire conversation on every turn. Network overhead stays proportional to message size, not conversation length."
    },
    {
      "id": "supported-operations",
      "title": "Supported operations",
      "role": "compatibility",
      "text": "The service implements all of ADK's session methods:\n- `create_session`: Create a new session\n- `get_session`: Retrieve an existing session\n- `list_sessions`: List sessions for an app/user\n- `delete_session`: Remove a session\n- `append_event`: Add a new message (incremental)"
    },
    {
      "id": "long-term-memory",
      "title": "Long-term memory",
      "role": "content",
      "text": "`RedisLongTermMemoryService` implements ADK's `BaseMemoryService`. After each conversation, the Agent Memory Server extracts structured information (facts, preferences, episodic events), embeds them as vectors, and stores them in Redis for semantic search across all past sessions.\n\n[code example]"
    },
    {
      "id": "configuration",
      "title": "Configuration",
      "role": "configuration",
      "text": "| Parameter | Description | Default |\n|-----------|-------------|---------|\n| `api_base_url` | Agent Memory Server URL | Required |\n| `default_namespace` | Namespace for data isolation | Required |\n| `extraction_strategy` | How conversations are broken into memories: `discrete`, `summary`, or `preferences` | `None` |\n| `recency_boost` | Enable recency-weighted search | `False` |\n| `semantic_weight` | Weight for vector similarity (0-1) | `0.7` |\n| `recency_weight` | Weight for recency signal (0-1) | `0.3` |"
    },
    {
      "id": "extraction-strategies",
      "title": "Extraction strategies",
      "role": "content",
      "text": "- **`discrete`**: Extracts individual facts as separate memories, making them independently searchable.\n- **`summary`**: Creates a narrative summary of the conversation.\n- **`preferences`**: Focuses on user preferences and settings."
    },
    {
      "id": "recency-boosting",
      "title": "Recency boosting",
      "role": "content",
      "text": "Raw semantic similarity often isn't enough. A user might have said \"I love Italian food\" three years ago and \"I've been getting into Japanese cuisine\" last week. Both are semantically relevant, but the recent one matters more.\n\nRecency boosting combines semantic similarity with time-based signals so that recent preferences outweigh stale ones."
    },
    {
      "id": "framework-services",
      "title": "Framework services",
      "role": "content",
      "text": "Pass both services to an ADK `Runner`. The framework handles memory automatically: sessions are persisted via working memory, long-term memory is searched before each agent turn, and an `after_agent_callback` triggers extraction in the background.\n\n[code example]"
    },
    {
      "id": "runtime-flow",
      "title": "Runtime flow",
      "role": "content",
      "text": "1. ADK creates or retrieves a session via `RedisWorkingMemorySessionService`.\n2. Long-term memory is searched for context relevant to the current conversation.\n3. User messages are appended to working memory incrementally.\n4. The LLM generates a response using session context plus retrieved memories.\n5. `after_agent_callback` triggers `add_session_to_memory()` for background extraction.\n6. If the conversation grows long, working memory auto-summarizes older turns."
    },
    {
      "id": "rest-tools",
      "title": "REST tools",
      "role": "content",
      "text": "Give the agent explicit memory tools that the LLM calls like any other function. The LLM decides when to search memory, what to store, and what to update. No framework services required.\n\n[code example]\n\nRequires prompt engineering to teach the LLM memory management strategy, but gives the agent genuine autonomy over its own memory."
    },
    {
      "id": "mcp-tools",
      "title": "MCP tools",
      "role": "content",
      "text": "Point ADK's `McpToolset` at the Agent Memory Server's SSE endpoint. Tool discovery happens automatically — no manual tool wiring required.\n\n[code example]\n\nAvailable MCP tools: `search_long_term_memory`, `create_long_term_memories`, `get_long_term_memory`, `edit_long_term_memory`, `delete_long_term_memories`, `memory_prompt`, `set_working_memory`.\n\nThe most portable approach — swap memory backends without changing agent code. Requires the Agent Memory Server running with MCP support on a separate port."
    },
    {
      "id": "more-info",
      "title": "More info",
      "role": "content",
      "text": "- [Integration patterns](): Detailed tradeoff comparison of all three approaches\n- [simple_redis_memory](https://github.com/redis-developer/adk-redis/tree/main/examples/simple_redis_memory): Minimal framework services setup\n- [travel_agent_memory_tools](https://github.com/redis-developer/adk-redis/tree/main/examples/travel_agent_memory_tools): REST tools only\n- [fitness_coach_mcp](https://github.com/redis-developer/adk-redis/tree/main/examples/fitness_coach_mcp): MCP tools\n- [travel_agent_memory_hybrid](https://github.com/redis-developer/adk-redis/tree/main/examples/travel_agent_memory_hybrid): Framework services + REST tools combined\n- [Agent Memory Server documentation](https://github.com/redis/agent-memory-server)"
    }
  ],
  "examples": [
    {
      "id": "working-memory-ex0",
      "language": "python",
      "code": "from adk_redis.sessions import (\n    RedisWorkingMemorySessionService,\n    RedisWorkingMemorySessionServiceConfig,\n)\n\nsession_service = RedisWorkingMemorySessionService(\n    config=RedisWorkingMemorySessionServiceConfig(\n        api_base_url=\"http://localhost:8088\",\n        default_namespace=\"my_app\",\n        model_name=\"gemini-2.0-flash\",\n        context_window_max=8000,\n    )\n)",
      "section_id": "working-memory"
    },
    {
      "id": "long-term-memory-ex0",
      "language": "python",
      "code": "from adk_redis.memory import (\n    RedisLongTermMemoryService,\n    RedisLongTermMemoryServiceConfig,\n)\n\nmemory_service = RedisLongTermMemoryService(\n    config=RedisLongTermMemoryServiceConfig(\n        api_base_url=\"http://localhost:8088\",\n        default_namespace=\"my_app\",\n        extraction_strategy=\"discrete\",\n        recency_boost=True,\n        semantic_weight=0.7,\n        recency_weight=0.3,\n    )\n)",
      "section_id": "long-term-memory"
    },
    {
      "id": "framework-services-ex0",
      "language": "python",
      "code": "from google.adk import Agent\nfrom google.adk.agents.callback_context import CallbackContext\nfrom google.adk.runners import Runner\n\nasync def after_agent(callback_context: CallbackContext):\n    await callback_context.add_session_to_memory()\n\nagent = Agent(\n    name=\"memory_agent\",\n    model=\"gemini-2.5-flash\",\n    instruction=\"You are a helpful assistant with long-term memory.\",\n    after_agent_callback=after_agent,\n)\n\nrunner = Runner(\n    agent=agent,\n    app_name=\"my_app\",\n    session_service=session_service,\n    memory_service=memory_service,\n)",
      "section_id": "framework-services"
    },
    {
      "id": "rest-tools-ex0",
      "language": "python",
      "code": "from adk_redis.tools.memory import (\n    SearchMemoryTool,\n    CreateMemoryTool,\n    UpdateMemoryTool,\n    DeleteMemoryTool,\n    MemoryToolConfig,\n)\n\nconfig = MemoryToolConfig(\n    api_base_url=\"http://localhost:8088\",\n    default_namespace=\"my_app\",\n    recency_boost=True,\n)\n\nagent = Agent(\n    model=\"gemini-2.5-flash\",\n    name=\"memory_agent\",\n    tools=[\n        SearchMemoryTool(config=config),\n        CreateMemoryTool(config=config),\n        UpdateMemoryTool(config=config),\n        DeleteMemoryTool(config=config),\n    ],\n)",
      "section_id": "rest-tools"
    },
    {
      "id": "mcp-tools-ex0",
      "language": "python",
      "code": "from adk_redis.tools.mcp_memory import create_memory_mcp_toolset\n\nmemory_tools = create_memory_mcp_toolset(\n    server_url=\"http://localhost:9000\",\n    tool_filter=[\"search_long_term_memory\", \"create_long_term_memories\"],\n)\n\nagent = Agent(\n    model=\"gemini-2.5-flash\",\n    name=\"mcp_agent\",\n    tools=[memory_tools],\n)",
      "section_id": "mcp-tools"
    }
  ]
}
