{
  "id": "integration-patterns",
  "title": "Memory integration patterns",
  "url": "https://redis.io/docs/latest/integrate/google-adk/integration-patterns/",
  "summary": "Three approaches for connecting Google ADK agents to Redis memory.",
  "tags": [
    "docs",
    "integrate",
    "oss",
    "rs",
    "rc"
  ],
  "last_updated": "2026-04-15T13:31:09-05:00",
  "page_type": "content",
  "content_hash": "453b24c4b318524bb66cc660e09f820b87505bbac479854317e2f4e3e97c628d",
  "sections": [
    {
      "id": "overview",
      "title": "Overview",
      "role": "overview",
      "text": "adk-redis offers three distinct approaches for connecting agents to memory. Each has different tradeoffs around control, complexity, and standardization."
    },
    {
      "id": "comparison",
      "title": "Comparison",
      "role": "content",
      "text": "| Approach | Control | Complexity | Protocol | Best for |\n|----------|---------|-----------|----------|----------|\n| **ADK services** | Framework | Low | HTTP | Invisible infrastructure |\n| **REST tools** | LLM | Medium | HTTP | Explicit memory management |\n| **MCP tools** | LLM | Medium | SSE | Standardized, portable |"
    },
    {
      "id": "1-adk-services-framework-managed",
      "title": "1. ADK services (framework-managed)",
      "role": "content",
      "text": "Configure `RedisWorkingMemorySessionService` and `RedisLongTermMemoryService`, pass them to the `Runner`, and the framework handles everything automatically. Memory extraction happens in the background. Search happens before each agent turn. The agent code never directly interacts with memory.\n\n[code example]\n\n**Tradeoffs:** Simplest to implement, hardest to customize. The agent has no explicit control over what gets stored or when it searches."
    },
    {
      "id": "2-rest-tools-llm-controlled",
      "title": "2. REST tools (LLM-controlled)",
      "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.\n\n[code example]\n\n**Tradeoffs:** Requires prompt engineering to teach the LLM memory management strategy, but gives the agent genuine autonomy over its own memory."
    },
    {
      "id": "3-mcp-tools-model-context-protocol",
      "title": "3. MCP tools (Model Context Protocol)",
      "role": "content",
      "text": "Point ADK's `McpToolset` at the Agent Memory Server's SSE endpoint. Tool discovery happens automatically.\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\n**Tradeoffs:** Most standardized and portable approach. Swap memory backends without changing agent code. Requires Agent Memory Server with MCP support on a separate port."
    },
    {
      "id": "hybrid-approach",
      "title": "Hybrid approach",
      "role": "content",
      "text": "The most powerful configuration combines framework services with REST tools. Framework services handle session persistence and automatic background extraction. REST tools give the LLM explicit CRUD control on top.\n\n[code example]\n\nThe [travel_agent_memory_hybrid](https://github.com/redis-developer/adk-redis/tree/main/examples/travel_agent_memory_hybrid) example demonstrates this pattern."
    },
    {
      "id": "more-info",
      "title": "More info",
      "role": "content",
      "text": "- [simple_redis_memory](https://github.com/redis-developer/adk-redis/tree/main/examples/simple_redis_memory): Framework-managed services\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- [Car dealership tutorial](https://redis.io/tutorials/build-a-car-dealership-agent-with-google-adk-and-redis-agent-memory/)"
    }
  ],
  "examples": [
    {
      "id": "1-adk-services-framework-managed-ex0",
      "language": "python",
      "code": "from google.adk.runners import Runner\nfrom adk_redis.sessions import (\n    RedisWorkingMemorySessionService,\n    RedisWorkingMemorySessionServiceConfig,\n)\nfrom adk_redis.memory import (\n    RedisLongTermMemoryService,\n    RedisLongTermMemoryServiceConfig,\n)\n\nrunner = Runner(\n    agent=agent,\n    app_name=\"my_app\",\n    session_service=RedisWorkingMemorySessionService(\n        config=RedisWorkingMemorySessionServiceConfig(\n            api_base_url=\"http://localhost:8088\",\n            default_namespace=\"my_app\",\n        )\n    ),\n    memory_service=RedisLongTermMemoryService(\n        config=RedisLongTermMemoryServiceConfig(\n            api_base_url=\"http://localhost:8088\",\n            default_namespace=\"my_app\",\n        )\n    ),\n)",
      "section_id": "1-adk-services-framework-managed"
    },
    {
      "id": "2-rest-tools-llm-controlled-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": "2-rest-tools-llm-controlled"
    },
    {
      "id": "3-mcp-tools-model-context-protocol-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": "3-mcp-tools-model-context-protocol"
    },
    {
      "id": "hybrid-approach-ex0",
      "language": "python",
      "code": "# LLM-controlled tools on the Agent\nagent = Agent(\n    model=\"gemini-2.5-flash\",\n    name=\"hybrid_agent\",\n    tools=[\n        SearchMemoryTool(config=config),\n        CreateMemoryTool(config=config),\n        UpdateMemoryTool(config=config),\n        DeleteMemoryTool(config=config),\n    ],\n)\n\n# Framework-managed services on the Runner\nrunner = Runner(\n    agent=agent,\n    app_name=\"my_app\",\n    session_service=session_service,   # Auto session management\n    memory_service=memory_service,     # Auto memory search\n)",
      "section_id": "hybrid-approach"
    }
  ]
}
