# Google ADK: why InMemoryMemoryService never calls add_session_to_memory

*Disclosure: I work on MemorySync (I'm Mohammed, the founder). I drafted this page with AI assistance and checked it against the source issue and the MemorySync Google ADK guide. I didn't run any code on this page.*

## The question

In [google/adk-python#7527](https://github.com/google/adk-python/issues/7527) (opened Oct 13 2026), a developer asked why initialising an agent with `InMemoryMemoryService` doesn't call `add_session_to_memory` automatically, and whether it has to be called through callbacks.

**Status (checked 2026-11-02 via the GitHub API):** closed. A maintainer replied that ADK does not add sessions to memory automatically, so the app has to call `add_session_to_memory`. A bot marked the issue stale on Oct 23 and closed it on Oct 31, 2026 with no code change, so the answer below still applies.

> **Skip the memory plumbing around this fix.** Once the fix below is in, the [MemorySync Google ADK guide](https://docs.memorysync.io/guides/google-adk?utm_source=hashnode&utm_medium=organic_page&utm_campaign=v5_oct25&utm_content=pseo_google-adk-add-session-to-memory-not-called) shows how to add per-user memory with MemorySync. MemorySync doesn't fix this error itself. When you're ready, [see MemorySync](https://memorysync.io/?utm_source=hashnode&utm_medium=organic_page&utm_campaign=v5_oct25&utm_content=pseo_google-adk-add-session-to-memory-not-called). Founding offer: use code FOUNDING30 for 30% off Starter for your first 3 months (Settings → Billing).

## The answer

A memory service in ADK is storage plus search. Passing one to the `Runner` makes it available to tools like `load_memory` and `preload_memory`, but nothing copies a finished session into it unless your code does. Per the maintainer's reply and the [ADK memory docs](https://adk.dev/sessions/memory/), you have two places to do it:

1. **After a run**, fetch the session and call `memory_service.add_session_to_memory(session)`.
2. **In an `after_agent_callback`**, so every agent run ingests its session without extra code at the call site.

Sketch of option 1 (*not run; check names against your ADK version*):

```python
session = await runner.session_service.get_session(
    app_name="support", user_id="customer-7", session_id="thread-42"
)
await memory_service.add_session_to_memory(session)
```

Two things to keep in mind:

- `InMemoryMemoryService` lives in process memory, so whatever you add is gone after a restart. It's meant for prototyping.
- If you ingest the whole session after every turn, think about duplicates: the in-memory service in the issue's snippet overwrites per session ID, but other backends may not.

## Skip the plumbing with MemorySync

Disclosure: I build MemorySync.

Only if you need memory that outlives the process. The [MemorySync Google ADK guide](https://docs.memorysync.io/guides/google-adk?utm_source=hashnode&utm_medium=organic_page&utm_campaign=v5_oct25&utm_content=pseo_google-adk-add-session-to-memory-not-called) documents a `MemorySyncMemoryService` that implements `add_session_to_memory` against managed storage, so ADK's own `preload_memory` can recall a user's facts in a later session. You still have to call it (or use the guide's context tool or callback), exactly as the maintainer described. It doesn't change the answer above.

From the guide:

**Unverified (not run):**

```bash
pip install google-adk-memorysync google-adk
```

Requires google-adk 2.0+ (Python 3.10+).

```python
from google.adk.agents import LlmAgent
from google.adk.runners import Runner
from google.adk.sessions import InMemorySessionService
from google.adk.tools import preload_memory
from google_adk_memorysync import MemorySyncMemoryService

memory_service = MemorySyncMemoryService()  # reads MEMORYSYNC_API_KEY

agent = LlmAgent(
    name="assistant",
    model="your-model",
    instruction="You are a helpful assistant.",
    tools=[preload_memory],  # ADK's native tool — our service powers it
)

runner = Runner(
    agent=agent,
    app_name="support",
    session_service=InMemorySessionService(),
    memory_service=memory_service,
)

# ... after a conversation, ingest the session:
session = await runner.session_service.get_session(
    app_name="support", user_id="customer-7", session_id="thread-42"
)
await memory_service.add_session_to_memory(session)

# The next run — any session, any process, any deploy —
# preload_memory injects what MemorySync knows about the user.
```

*Snippet adapted from the [MemorySync Google ADK guide](https://docs.memorysync.io/guides/google-adk?utm_source=hashnode&utm_medium=organic_page&utm_campaign=v5_oct25&utm_content=pseo_google-adk-add-session-to-memory-not-called); I haven't run it for this page.*

**Try it:** MemorySync is optional here: the steps above work without it. If you want the memory layer from the snippet, [see MemorySync](https://memorysync.io/?utm_source=hashnode&utm_medium=organic_page&utm_campaign=v5_oct25&utm_content=pseo_google-adk-add-session-to-memory-not-called), create an API key in the dashboard and drop the snippet into your agent.

## Next step

Read the [MemorySync Google ADK guide](https://docs.memorysync.io/guides/google-adk?utm_source=hashnode&utm_medium=organic_page&utm_campaign=v5_oct25&utm_content=pseo_google-adk-add-session-to-memory-not-called). For an overview of MemorySync, see [the MemorySync homepage](https://memorysync.io/?utm_source=hashnode&utm_medium=organic_page&utm_campaign=v5_oct25&utm_content=pseo_google-adk-add-session-to-memory-not-called).

## Sources

- google/adk-python#7527, "InMemoryMemoryService does not call add_session_to_memory?" (read 2026-10-28)
- ADK docs: Memory, https://adk.dev/sessions/memory/
- MemorySync Google ADK guide: docs.memorysync.io/guides/google-adk

**Next step:** read the [MemorySync Google ADK guide](https://docs.memorysync.io/guides/google-adk?utm_source=hashnode&utm_medium=organic_page&utm_campaign=v5_oct25&utm_content=pseo_google-adk-add-session-to-memory-not-called), then [see MemorySync](https://memorysync.io/?utm_source=hashnode&utm_medium=organic_page&utm_campaign=v5_oct25&utm_content=pseo_google-adk-add-session-to-memory-not-called). Founding offer: use code FOUNDING30 for 30% off Starter for your first 3 months (Settings → Billing).
