asyncio.to_thread fallback.
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
Prefer async with for exception-safety
Prefer async with for exception-safety
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:Reusing a PraisonAIDB after close
Reusing a PraisonAIDB after close
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:Implement async_* methods for performance
Implement async_* methods for performance
For high-throughput async applications, implement native async methods:
Handle metadata consistently
Handle metadata consistently
All hooks accept optional metadata dictionaries:
Use sync context manager for mixed environments
Use sync context manager for mixed environments
Both sync and async context managers are supported:
Related
Persistence Overview
Complete persistence system documentation
Agent Architecture
Learn about async agent patterns

