Skip to content

feat(adk): complete v2 integration - #738

Open
cofin wants to merge 12 commits into
litestar-org:mainfrom
cofin:feat/adk-2-flows
Open

cofin wants to merge 12 commits into
litestar-org:mainfrom
cofin:feat/adk-2-flows

Conversation

@cofin

@cofin cofin commented May 24, 2026

Copy link
Copy Markdown
Member

Summary

  • replace ADK-owned tables with user-owned model mixins and config, supporting Google ADK v2+ only
  • implement session, artifact, and memory services using Advanced Alchemy bases, datatypes, and storage integration
  • add Litestar, FastAPI, Flask, Sanic, and Starlette integration helpers, docs, examples, and focused tests

Verification

  • uv run ruff check advanced_alchemy/extensions/adk advanced_alchemy/types/datetime.py tests/unit/test_extensions/test_adk tests/integration/test_extensions/test_adk examples/adk_models.py examples/litestar/adk_example.py examples/fastapi/adk_example.py examples/flask/adk_example.py examples/starlette/adk_example.py examples/sanic_adk_example.py
  • uv run pytest tests/unit/test_extensions/test_adk tests/integration/test_extensions/test_adk -q
  • uv run pyright
  • uv run make docs
  • git diff --check

CI on PR litestar-org#738 surfaced 27 mypy errors across the ADK extension and a
docs test failure caused by ADK rst files not being classified.

- Tighten ADK model return types: `to_session`/`to_event`/`from_event`
  now declare ``Session`` and ``Event`` via TYPE_CHECKING imports
  instead of ``Any``, eliminating downstream ``no-any-return`` errors.
- Annotate ``session.scalar`` results in session and artifact services
  so SQLAlchemy's loose typing no longer bleeds into return values.
- Type the ``alchemy`` parameter on Starlette/Sanic plugins with the
  real ``AdvancedAlchemy`` extension via TYPE_CHECKING imports and
  drop the now-redundant ``type: ignore`` and runtime isinstance
  defenses.
- Tighten the Flask plugin: type ``app``/``alchemy``/handlers properly
  and cast the Flask ``g`` cache reads to their concrete service types.
- Add mypy overrides for ``pgvector.*``, the unstable Sanic plugin,
  and the version-gated ADK ``__init__``; drop a stale type ignore on
  Starlette's ``wrapped_lifespan`` that recent stubs made redundant.
- Register the ADK ``docs/usage/adk/*.rst`` pages in
  ``NON_EXECUTABLE_DOCS`` so the doc tracking test recognizes them.
- Fix mypy issues in the ADK examples and tests (assert services,
  guard optional ``event_data``/``parts``, suppress untyped
  ``postgresql.dialect`` calls) and allow ``assert`` in
  ``examples/flask/*`` via ruff per-file-ignores.
Oracle implicitly creates an index for unique constraints, so the
``ix_..._adk_session_lookup`` index on the same (app_name, user_id,
session_id) tuple collided with the unique-constraint index and
raised ``ORA-01408: such column list already indexed`` during
integration test setup.

Guard the explicit Index with ``ddl_if`` so it is only emitted on
non-Oracle dialects, mirroring the existing pattern in
``SessionModelMixin`` and ``SlugKey``.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant