Description
Is your feature request related to a problem? Yes
I'm frustrated when trying to integrate the Google ADK DataBaseSessionServices with modern async Python web frameworks like FastAPI. The current session service implementations appear to be synchronous, which creates performance bottlenecks and blocking operations in async applications. This is particularly problematic when:
- Building FastAPI applications that need to handle high concurrency
- Integrating with async database operations using SQLAlchemy's async engine
- Maintaining non-blocking I/O operations throughout the application stack
- Scaling applications that require efficient resource utilization
I alway got this particular error while using DatabaseSessionService for Neon DB.
greenlet_spawn has not been called; can't call await_only() here. Was IO attempted in an unexpected place? (Background on this error at: https://sqlalche.me/e/20/xd2s)
My solution:
I would like to see an AsyncDatabaseSessionService added to the Google ADK session services that provides:
-
Fully async/await compatible methods for all session operations:
async def create_session(...)
async def get_session(...)
async def list_sessions(...)
async def delete_session(...)
async def append_event(...)
-
Native async database support using:
- SQLAlchemy's
create_async_engine
andAsyncSession
- Proper async context managers for database connections
- Non-blocking database operations throughout
- SQLAlchemy's
-
Seamless FastAPI integration that allows developers to:
- Use dependency injection with async session services
- Maintain async context throughout request handling
- Achieve optimal performance in high-concurrency scenarios
-
Backward compatibility with existing session service interfaces while extending them for async operations
Additional context
Framework Compatibility: This enhancement would make Google ADK more compatible with the modern Python async ecosystem, including:
- FastAPI
- Starlette
- aiohttp
- async SQLAlchemy patterns