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.