Skip to content

Storage Layer

The buyer agent persists all state in SQLite, accessed through a set of concrete, domain-specific store classes in ad_buyer/storage/. There is no pluggable backend abstraction — one SQLite database (configured by DATABASE_URL, default sqlite:///./ad_buyer.db) holds every table, and each store class owns one slice of it.

The schema is defined centrally in ad_buyer/storage/schema.py (17 domain tables plus a schema_version table) and created idempotently on first connect.

The stores

The DealStore is the largest store — a synchronous sqlite3 layer for deal lifecycle, negotiation history, and booking records (synchronous by design, for CrewAI thread safety). Alongside it sit focused domain stores:

Store (ad_buyer/storage/) Persists
deal_store.pyDealStore Deals, negotiation rounds, booked lines (full reference)
order_store.pyOrderStore Buyer-side order records
negotiation_store.pyNegotiationStore Negotiation state
booking_record_store.pyBookingRecordStore Booking records
campaign_store.pyCampaignStore Campaign automation records
pacing_store.pyPacingStore Budget pacing snapshots
creative_asset_store.pyCreativeAssetStore Creative assets and validation status
adserver_store.pyAdServerStore Ad server campaigns and deal-to-line bindings
deal_activation_store.pyDealActivationStore Cross-platform deal activations
deal_event_store.pyDealEventStore Persisted deal events
deal_template_store.pyDealTemplateStore Deal templates
supply_path_template_store.pySupplyPathTemplateStore Supply path templates
performance_cache_store.pyPerformanceCacheStore Cached deal performance data
portfolio_metadata_store.pyPortfolioMetadataStore Portfolio metadata (import source, tags, advertiser)
status_transition_store.pyStatusTransitionStore State machine transition audit trail
job_store.pyJobStore API booking jobs
audience_audit_log.py Audience planning audit log

ad_buyer/storage/health.py provides probe_database() / database_accessible() health checks against the configured database.

Configuration

Variable Default Description
DATABASE_URL sqlite:///./ad_buyer.db SQLite connection string. All stores share it.

Single writer

SQLite serializes writes. Run exactly one agent instance against a given database file (e.g. DesiredCount: 1 on ECS). Running multiple instances against the same file — including a shared network file system — risks corruption.