You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Add fixes for InMemorySessionService behavior across long-lived agent requests #1569
The current implementation of InMemorySessionService in google.adk.sessions lacks documentation on its behavior in long-lived or asynchronous agent pipelines. When agents rely on session memory across multi-minute workflows (e.g., polling bid portals or processing large files), the in-memory context is reset between invocations — leading to unexpected loss of conversation or task state.
How the Issue Arises
In our project, we’re orchestrating multiple agents (DiscoveryAgent → DownloadAgent → AnalysisAgent) using Runner.run(...) calls in a Flask backend. We initially used InMemorySessionService() to persist session data across the agent lifecycle.
However, during testing, we observed that:
When workflows span multiple POST requests or Cloud Run invocations (e.g., step-by-step bid processing), InMemorySessionService resets the session between requests.
This breaks continuity in agent state — for example, the DiscoveryAgent may store portal metadata in session.memory, which becomes unavailable when passed to the DownloadAgent.
Possible solution
Raise a warning in Runner.run() if InMemorySessionService is used in asynchronous environments or repeated contexts (e.g., longer than X seconds or multiple threads/processes).
Hi @ParinAcharyaGit , thanks for your suggestion, we will add docstring to the InMemorySerivces to clarify that they are not suitable for running in multi-thread/process environments, you might use DatabaseSessionService or VertexAiSessionService which are more production ready.
Activity
DeanChensj commentedon Jul 7, 2025
Hi @ParinAcharyaGit , thanks for your suggestion, we will add docstring to the InMemorySerivces to clarify that they are not suitable for running in multi-thread/process environments, you might use DatabaseSessionService or VertexAiSessionService which are more production ready.
chore: Add docstring to clarify that inmemory service are not suitabl…
chore: Add docstring to clarify that inmemory service are not suitabl…
chore: Add docstring to clarify that inmemory service are not suitabl…
chore: Add docstring to clarify that inmemory service are not suitabl…
chore: Add docstring to clarify that inmemory service are not suitabl…
chore: Add docstring to clarify that inmemory service are not suitabl…
chore: Add docstring to clarify that inmemory service are not suitabl…