Skip to main content

SQLite database storage

SqliteWalLogger (called SQLiteLogger in Python and PersistenceStore in TypeScript, Go, C#, and Java) stores records in the SQLite database file you configure. SQLite uses a write-ahead log (WAL), a recovery file that helps it restore committed changes after an interruption. The database stores traces, conversation history, workflow progress, approvals, and namespaced context and memory entries. ContextStore and MemoryStore are in memory by default; pass a SQLite-backed store and a namespace to keep their entries after the process exits. The CLI also accepts a database path through --db.

import asyncio
from ish import SQLiteLogger


async def main() -> None:
logger = SQLiteLogger(db_path="./data/traces.db")
await logger.initialize()

await logger.start_trace("tr_example", agent_name="planner", input_prompt="Audit repo")
await logger.finish_trace("tr_example", status="completed")
await logger.flush()
await logger.close()


asyncio.run(main())

Choose a write mode​

SqliteWalLogger::open_with_options selects WalMode::Memory by default when no path (or ":memory:") is supplied, and WalMode::DiskSync when a filesystem path is given (SqliteWalLogger::new(path) defaults to WalMode::DiskSync, ring capacity 1024, and OverflowPolicy::Reject). Explicit Tiered or DiskSync modes require a file path.

WalMode Semantics​

ModeWhen a write returnsTradeoff
MemoryAfter the in-memory writeFast; data is lost when the process exits
DiskSyncAfter SQLite commits the write to its WALThe transaction is committed before return; the default synchronous=NORMAL setting can lose recent commits after an operating-system or power failure
TieredAfter the write enters a bounded bufferGroups writes for throughput; a flush commits buffered writes using the configured SQLite sync setting

SQLite settings​

SQLite uses write-ahead logging. The trace store uses synchronous=NORMAL to balance throughput with recovery from application crashes; a host or power failure can lose recent commits. Durable mailboxes use synchronous=FULL for each commit, which asks SQLite to sync the WAL before reporting commit success:

StoreContainsCommit behavior
Trace storeTraces, sessions, workflow state, and checkpointsRecovery log with synchronous=NORMAL
Durable mailboxMessages and delivery claimsWAL mode with synchronous=FULL
Async job storeBackground job stateWAL mode with synchronous=FULL

Why durable writes are not dropped​

Buffered durable writes are never silently discarded. OverflowPolicy controls what happens when the buffer is full: reject the write, flush before accepting it, or wait for space. Best-effort event queues have their own explicit drop policies; these policies do not apply to durable trace or workflow records.

PolicyBehavior when fullSuitable for
RejectReturn an error for the new writeCallers that can retry or report backpressure
ForceFlushCommit buffered writes before accepting the new writeCallers that prefer to wait for durability
BlockWait until buffer space is availableBackground writers that can pause
Event drop policyDrop the configured oldest or newest best-effort eventNon-durable telemetry only

Wait for durable writes​

In Tiered mode, reads flush earlier writes first, so the same store returns the latest value. Use the store's durable-acknowledgment method when a caller must know that a buffered write reached SQLite before continuing.

Inspect the database​

ish-server logs --db ./data/traces.db --limit 10
ish-server inspect tr_example --db ./data/traces.db

SQLite's Write-Ahead Logging mode can allow readers to proceed while a writer commits changes. SQLite still serializes writes, and behavior depends on transaction duration, filesystem characteristics, and connection use. There is no fixed commit latency or zero-contention guarantee.

Persistence diagnostics​

ISH keeps a limited set of recent storage timing samples. A successful write records its duration; adding a write to a buffer does not count as a completed commit. The percentile methods summarize those storage samples. They do not measure model latency or total agent run time.

SQLiteLogger exposes diagnostics, clear_diagnostics(), set_diagnostic_capacity(), and get_commit_latency_percentiles() in Python. The other SDKs expose corresponding typed methods on PersistenceStore. They use the same persistence behavior in every language. Host code can also add a diagnostic message through record_diagnostic or its language-specific name.

Configure a database path​

For CLI use, pass --db to the command:

ish-server logs --db ./data/traces.db

Attach persistence to an agent​

Pass the logger (persistence=logger in Python) or handle (persistence_handle / PersistenceHandle / .persistenceHandle(...) in TypeScript, Go, C#, and Java) into agent runs, or call flush() / await_durable_ack() directly when custom tooling requires an explicit commit barrier before handing off work across processes.