Skip to content

synchronous psycopg2 dependency in postgres database sessionservice , while adk is async all the way #1750

Closed

Description

@athulds

Describe the bug
I can see the dependency on the synchronous psycopg2 db driver for postgres when I added DbSessionService. Since we are expecting adk to be fully async, need to understand why this dependency is in place and will it block the even loop during the db interactions ?

Or
it runs in a separate thread ?

Any plans to move to something like asyncpg ?

To Reproduce
Adk forcing to install psycopg2 when DbSessionService for postgres is enabled.

File "c:\Users..\workspace..\venv\Lib\site-packages\google\adk\sessions\database_session_service.py", line 314, in init
db_engine = create_engine(db_url, **kwargs)
File "", line 2, in create_engine
File "c:\Users..\workspace..\venv\Lib\site-packages\sqlalchemy\util\deprecations.py", line 281, in warned
return fn(*args, **kwargs) # type: ignore[no-any-return]
File "c:\Users..\workspace..\venv\Lib\site-packages\sqlalchemy\engine\create.py", line 602, in create_engine
dbapi = dbapi_meth(**dbapi_args)
File "c:\Users..\workspace..\venv\Lib\site-packages\sqlalchemy\dialects\postgresql\psycopg2.py", line 696, in import_dbapi
import psycopg2
ModuleNotFoundError: No module named 'psycopg2'

Expected behavior
All the modules should be async

Activity

  1. added
    services[Component] This issue is related to runtime services, e.g. sessions, memory, artifacts, etc
    on Jul 2, 2025
  2. added theissue type on Jul 2, 2025
  3. changed the issue type fromtoon Jul 18, 2025
  4. DeanChensj commented on Jul 18, 2025

    @DeanChensj
    Collaborator

    Hi @athulds , we made the interface change to make all session service async, but we haven't migrate the DB session service to be true async yet. I'll convert this into a feature request

  5. athulds commented on Jul 18, 2025

    @athulds
    Author

    @DeanChensj Sure. Yeah DBService is not yet async. Because of that the asyncpg driver is failing when we are dealing with postgres, primarily due to the sync functionalities like inspect etc. within the DBSessionService
    Thanks

  6. hangfei commented on Nov 8, 2025

    @hangfei
    Collaborator

    Duplicate to : #1005

  7. DeanChensj commented on Nov 10, 2025

    @DeanChensj
    Collaborator

    This is now closed by #2889

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    services[Component] This issue is related to runtime services, e.g. sessions, memory, artifacts, etc

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions