Skip to content

VertexAiSessionService.get_session Becomes Super Slow When There Are Higher Numbers of Session Events #3039

Closed

Description

@touhonoob

Describe the bug
VertexAiSessionService.get_session Becomes Super Slow When There Are Higher Numbers of Session Events

To Reproduce
Accumulate some events for a session and get_session will start slowing down when the number of events gets higher.

Expected behavior
It should not get all events by default

Activity

  1. added
    services[Component] This issue is related to runtime services, e.g. sessions, memory, artifacts, etc
    on Sep 29, 2025
  2. added theissue type on Sep 29, 2025
  3. touhonoob commented on Oct 23, 2025

    @touhonoob
    Author

    Hey @DeanChensj
    This issue makes the session service unusable as the response time grows linearly as the number of session events increase.
    Please take a look.

  4. DeanChensj commented on Oct 24, 2025

    @DeanChensj
    Collaborator

    Hi @touhonoob , may I know how do you use session service? Do you use the adk api_server, or do you manage the runner yourself? I'm thinking adding configuration to only load number of recent events in session service, it will either be in the RunConfig in runner, or in the config of App

  5. touhonoob commented on Oct 24, 2025

    @touhonoob
    Author

    Hello @DeanChensj Thanks for checking.
    I deployed my agent on Google Cloud's Vertex AI Agent Engine and didn't add any customization.
    It can be easily reproduced by having a longer conversation with an ADK agent I believe.
    When I checked the profiler chart it's trying to traverse through all session events pages for every single query I made, which apparently would be making it getting slower over time with growing chat history.

  6. touhonoob commented on Oct 24, 2025

    @touhonoob
    Author

    Maybe you guys should work on something like https://platform.openai.com/docs/api-reference/responses ?
    The session service is pointless if it needs to retrieve all of the historical events

  7. added this to the 10/27 ADK Week milestone on Oct 27, 2025
  8. couchrishi commented on Oct 30, 2025

    @couchrishi

    any updates pl? This is critical for production-grade deployments

  9. arminhamp commented on Feb 5, 2026

    @arminhamp

    @adk-bot any solutions?

  10. added
    needs review[Status] The PR/issue is awaiting review from the maintainer
    on Feb 6, 2026
  11. self-assigned this
    on Feb 13, 2026
  12. removed this from the 10/27 ADK Week milestone on Feb 13, 2026
  13. devashishupadhyay-unlocq commented on Feb 17, 2026

    @devashishupadhyay-unlocq

    @adk-bot any updates or quick fixes?

  14. DeanChensj commented on Oct 13, 2026

    @DeanChensj
    Collaborator

    Thank you for reporting this performance issue and sharing the detailed analysis!

    Since this issue was opened, ADK has added two mechanisms on main to prevent VertexAiSessionService.get_session from loading unbounded historical events on every turn:

    1. Per-Run GetSessionConfig via RunConfig.get_session_config:
      RunConfig (src/google/adk/agents/run_config.py) now exposes get_session_config: GetSessionConfig | None = None, which Runner forwards to session_service.get_session(..., config=run_config.get_session_config):

      • after_timestamp (server-side filter): In VertexAiSessionService.get_session (src/google/adk/sessions/vertex_ai_session_service.py), setting after_timestamp pushes a server-side filter='timestamp>="..."' directly to the Vertex AI Agent Engine events.list RPC so older events are never transferred over the network.
      • num_recent_events: Setting num_recent_events=0 skips calling events.list completely when only session metadata/state is needed, and num_recent_events=N bounds the events retained on the session.
      from google.adk.agents.run_config import RunConfig
      from google.adk.sessions.base_session_service import GetSessionConfig
      
      run_config = RunConfig(
          get_session_config=GetSessionConfig(after_timestamp=cutoff_timestamp)
      )
    2. Automatic Sliding-Window Event Compaction (EventsCompactionConfig):
      You can configure EventsCompactionConfig on App (src/google/adk/apps/app.py) to periodically summarize older turns into a single compacted event so active sessions stay bounded in length.

    We're closing this issue as resolved. Please feel free to reopen it if you still experience performance bottlenecks with these options enabled!

  15. github-actions commented on Oct 13, 2026

    @github-actions

    Are you satisfied with the resolution of your issue?
    Yes
    No

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

needs review[Status] The PR/issue is awaiting review from the maintainerservices[Component] This issue is related to runtime services, e.g. sessions, memory, artifacts, etc

Type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions