Skip to content

[Bug] MemoryManager sync single-memory CRUD silently no-ops against AsyncBaseDb #11143

Open

Description

@BlueX888

Summary

MemoryManager's sync single-memory CRUD methods silently no-op when the manager is built on an AsyncBaseDb:

  • add_user_memory / replace_user_memory / delete_user_memory call the async DB APIs without awaiting them — the coroutine is discarded (Python emits RuntimeWarning: coroutine ... was never awaited), nothing is written, and the method still returns a success memory_id.
  • clear() behaves the same way (returns normally, nothing cleared).

The class contract allows both DB kinds (db: Optional[Union[BaseDb, AsyncBaseDb]]), and the sibling sync methods already guard async DBs with ValueError("... is not supported with an async DB ...") — these four methods are the outliers, so callers get a success result for an operation that never happened.

Repro

from agno.db.async_sqlite import AsyncSqliteDb
from agno.memory.manager import MemoryManager

manager = MemoryManager(db=AsyncSqliteDb(db_file="tmp/test.db"))
memory_id = manager.add_user_memory(memory=UserMemory(memory="likes tea"))
# returns a fresh UUID and emits "RuntimeWarning: coroutine 'AsyncSqliteDb.upsert_user_memory' was never awaited"
# nothing is stored

On current main (commit 0aa5924):

add_user_memory    -> memory_id returned, 0 rows stored, RuntimeWarning (never awaited)
replace_user_memory-> returns normally, row unchanged, RuntimeWarning
delete_user_memory -> returns normally, row still present, RuntimeWarning
clear()            -> returns None, rows still present, RuntimeWarning

Expected: a clear error (matching the existing "not supported with an async DB" guard convention), not a silent no-op with a success return.

Suggested fix

Add the same isinstance(self.db, AsyncBaseDb) guard the sibling sync methods already use, at the top of add_user_memory, replace_user_memory, delete_user_memory, and clear() — before any mutation or DB call. The async twins remain the supported path.

Tests

Unit tests with an AsyncBaseDb double (and a real AsyncSqliteDb variant): all four methods must raise ValueError matching the existing convention, directly at base (DID NOT RAISE) and the repo's own unit/memory suite grows 75 → 79 with the new tests. Sync BaseDb and db=None behavior is unchanged; there are no in-repo callers of the four sync methods that would regress.

Activity

  1. kaust1495 commented on Oct 20, 2026

    @kaust1495

    Hi maintainers - I ran into this while using MemoryManager against an async DB and have a fix ready in PR #11154. The triage bot let me know the issue needs the ready label before that PR can be reviewed. Could a maintainer triage this issue and mark it ready when convenient? Happy to adjust the approach if you'd prefer it solved differently.

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

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions