-
Notifications
You must be signed in to change notification settings - Fork 1.5k
Description
Is your feature request related to a problem? Please describe.
I’m building a chat-UI application using the adk api_server
List Sessions endpoint (GET /apps/{app_name}/users/{user_id}/sessions
). I need to display each session’s state or metadata (e.g. an auto-generated title) in a sidebar so users can quickly see past conversations. However, while the single-session endpoint (GET /apps/{app_name}/users/{user_id}/sessions/{session_id}
) correctly returns the state
field, the List Sessions API always returns state
as empty—making it impossible to show any session metadata in the list.
Describe the solution you’d like
Modify the List Sessions API to include the state
field for each session in its response, just as the single-session endpoint does. That way, any metadata stored in state
(such as a short summary or title generated by a small, fast model) will be available directly in the list response.
Describe alternatives you’ve considered
- Fetching every session individually using
GET /apps/{app_name}/users/{user_id}/sessions/{session_id}
, which adds extra HTTP requests and latency. - Storing session metadata in a separate external database and managing synchronization manually, which complicates the overall architecture.
Additional context
The current implementations explicitly clear or omit the state
field when listing sessions:
- Database Sessions:
adk-python/src/google/adk/sessions/database_session_service.py
Lines 437 to 457 in 3b5232c
async def list_sessions( self, *, app_name: str, user_id: str ) -> ListSessionsResponse: with self.database_session_factory() as session_factory: results = ( session_factory.query(StorageSession) .filter(StorageSession.app_name == app_name) .filter(StorageSession.user_id == user_id) .all() ) sessions = [] for storage_session in results: session = Session( app_name=app_name, user_id=user_id, id=storage_session.id, state={}, last_update_time=storage_session.update_time.timestamp(), ) sessions.append(session) return ListSessionsResponse(sessions=sessions) - In-Memory Sessions:
adk-python/src/google/adk/sessions/in_memory_session_service.py
Lines 207 to 222 in 3b5232c
def _list_sessions_impl( self, *, app_name: str, user_id: str ) -> ListSessionsResponse: empty_response = ListSessionsResponse() if app_name not in self.sessions: return empty_response if user_id not in self.sessions[app_name]: return empty_response sessions_without_events = [] for session in self.sessions[app_name][user_id].values(): copied_session = copy.deepcopy(session) copied_session.events = [] copied_session.state = {} sessions_without_events.append(copied_session) return ListSessionsResponse(sessions=sessions_without_events)
Including state
in the List Sessions response would enable native support for recording and displaying session metadata without extra workarounds.