Skip to content

Conversation

@tcdent
Copy link
Contributor

@tcdent tcdent commented Feb 10, 2026

Extend the database layer to support async SQLAlchemy sessions alongside
existing sync sessions. Every public activity tracker function now accepts
both Session and AsyncSession via overloaded signatures with isinstance
detection — pass an AsyncSession and the call returns an awaitable
coroutine, pass a Session (or None) and it executes synchronously as
before. The public API names are unchanged.

Key changes:

  • core/db: add async session factory, DatabaseEngine/DatabaseSession type
    aliases, set_global_async_session/get_global_async_session helpers
  • activity/models: add async classmethods (aappend_log, aget_by_agent_id,
    aget_list, aget_pending_ids, aget_active_count) using selectinload for
    relationship access
  • activity/tracker: overload create, update, complete, error,
    cancel_pending, list, detail, count_active for sync/async dispatch
  • Export DatabaseEngine and DatabaseSession from top-level package
  • Add aiosqlite dev dependency and comprehensive async test suite

https://claude.ai/code/session_011TEKqVAGZi4xhkB5Fqqujv

Extend the database layer to support async SQLAlchemy sessions alongside
existing sync sessions.  Every public activity tracker function now accepts
both Session and AsyncSession via overloaded signatures with isinstance
detection — pass an AsyncSession and the call returns an awaitable
coroutine, pass a Session (or None) and it executes synchronously as
before.  The public API names are unchanged.

Key changes:
- core/db: add async session factory, DatabaseEngine/DatabaseSession type
  aliases, set_global_async_session/get_global_async_session helpers
- activity/models: add async classmethods (aappend_log, aget_by_agent_id,
  aget_list, aget_pending_ids, aget_active_count) using selectinload for
  relationship access
- activity/tracker: overload create, update, complete, error,
  cancel_pending, list, detail, count_active for sync/async dispatch
- Export DatabaseEngine and DatabaseSession from top-level package
- Add aiosqlite dev dependency and comprehensive async test suite

https://claude.ai/code/session_011TEKqVAGZi4xhkB5Fqqujv
…tinload

Extract SQL statement construction into private _*_stmt() classmethods
shared by both sync and async execution paths.  Sync methods now use
select() instead of the legacy session.query() API, and get_by_agent_id
uses explicit selectinload(logs) instead of relying on implicit lazy
loading.  The async methods are now thin await wrappers with zero
duplicated query logic.

https://claude.ai/code/session_011TEKqVAGZi4xhkB5Fqqujv
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants