"""Run event storage configuration. Controls where run events (messages + execution traces) are persisted. Backends: - memory: Compatibility name for a bounded-IO local SQLite event spool. Completed events remain on disk instead of accumulating in process RAM. - db: SQL database via SQLAlchemy ORM. Provides full query capability. Suitable for production deployments. - jsonl: Append-only JSONL files. Lightweight alternative for single-node deployments that need persistence without a database. """ from __future__ import annotations from typing import Literal from pydantic import BaseModel, Field class RunEventsConfig(BaseModel): backend: Literal["memory", "db", "jsonl"] = Field( default="memory", description="Event backend: 'memory' uses a durable local disk spool, 'db' uses the business SQL database, 'jsonl' uses per-run files.", ) max_trace_content: int = Field( default=10240, description="Maximum trace content size in bytes before truncation (db backend only).", ) track_token_usage: bool = Field( default=True, description="Whether RunJournal should accumulate token counts to RunRow.", )