Skip to content

[Bug] VertexAiSessionService.get_session() fails with httpx client closure during event pagination (>100 events) #3757

@AlexisMarasigan

Description

@AlexisMarasigan

Expected behavior

get_session() should successfully retrieve all events regardless of how many pages are required for pagination. The API client should remain open until all events have been fetched.

Desktop (please complete the following information):

  • OS: Linux (GCP Cloud Run / Vertex AI Agent Engine)
  • Python version: 3.11
  • ADK version: 1.19.0

Model Information:

  • Are you using LiteLLM: No
  • Which model is being used: gemini-2.5-pro

Additional context

The bug is in src/google/adk/sessions/vertex_ai_session_service.py. The async for event in events_iterator loop is placed outside the async with self._get_api_client() as api_client: block, causing the client to close before pagination completes.

Proposed fix: #3756

The fix moves the event iteration inside the async with block so the API client remains open during the entire pagination process.

This is a critical bug for production deployments as it makes sessions with extended conversations (>100 events) completely unusable.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions