Skip to main content
Async DB hooks enable non-blocking database operations in async agents through automatic async/sync detection and asyncio.to_thread fallback.
Breaking Change in PR #1829: The async_* prefixed methods have been removed from async stores. The orchestrator now uses isinstance(store, AsyncConversationStore) for dispatch instead of runtime method introspection.
The user chats asynchronously; DB hooks persist messages without blocking the event loop.

Quick Start

1

Async Context Manager

Use async DB operations with the async context manager for automatic cleanup.
2

Wire to Async Agent

Connect async DB hooks to an async agent for seamless persistence.

How It Works


Configuration Options

All async hooks support these signatures from the DB adapter:

Common Patterns

Complete Async Lifecycle

Sync Store Compatibility

Native Async Store


Best Practices

Manual aclose() is now safe and idempotent — calling it twice does nothing harmful. Prefer async with for exception-safety and readability, so cleanup runs even when an error is raised mid-block:
close() and aclose() reset the internal stores, so re-entering a with db: ... block after close cleanly re-initializes instead of dispatching to closed handles:
For high-throughput async applications, implement native async methods:
All hooks accept optional metadata dictionaries:
Both sync and async context managers are supported:

Persistence Overview

Complete persistence system documentation

Agent Architecture

Learn about async agent patterns