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.
- Python
- TypeScript
- Rust
- Go
- C#
- Java
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())
import { IshClient, PersistenceStore } from "ish-harness";
const client = new IshClient();
const store = new PersistenceStore(client, {
path: "./data/traces.db",
mode: "DiskSync",
capacity: 1024,
overflowPolicy: "Block",
});
store.startTrace("tr_example", "planner", "Audit repo");
store.logSpan({
spanId: "sp_01",
traceId: "tr_example",
name: "list_files",
entityType: "tool",
durationMs: 12.4,
output: { count: 4 },
});
store.finishTrace("tr_example", "completed");
store.flush();
store.close();
client.close();
use ish_harness::persistence::{OverflowPolicy, SqliteWalLogger, WalMode};
let logger = SqliteWalLogger::new_with_mode(
"./data/traces.db",
WalMode::DiskSync,
1024,
OverflowPolicy::Block,
)?;
logger.start_trace("tr_example", "planner", "Audit repo", 1_735_000_000.0)?;
logger.log_span(
"sp_01",
"tr_example",
"list_files",
"tool",
Some(r#"{"count":4}"#),
12.4,
)?;
logger.finish_trace("tr_example", 1_735_000_001.0, "completed")?;
logger.flush()?;
capSize := uint64(1024)
store, err := ish.NewPersistenceStore(client, "./data/traces.db", "DiskSync", &capSize, "Block")
if err != nil {
panic(err)
}
defer store.Close()
_ = store.StartTrace("tr_example", "planner", "Audit repo", nil)
dur := 12.4
_ = store.LogSpan("sp_01", "tr_example", "list_files", "tool", map[string]any{"count": 4}, nil, &dur)
_ = store.FinishTrace("tr_example", "completed", nil)
_ = store.Flush()
using System.Text.Json;
using Ish.Harness;
using var client = new IshClient();
using var store = new PersistenceStore(
client,
path: "./data/traces.db",
mode: "DiskSync",
capacity: 1024,
overflowPolicy: "Block");
store.StartTrace("tr_example", "planner", "Audit repo");
using var spanOut = JsonDocument.Parse("{\"count\":4}");
store.LogSpan("sp_01", "tr_example", "list_files", "tool", spanOut.RootElement, durationMs: 12.4);
store.FinishTrace("tr_example", "completed");
store.Flush();
import com.fasterxml.jackson.databind.ObjectMapper;
import io.github.ishharness.PersistenceStore;
try (var store = new PersistenceStore(client, "./data/traces.db", "DiskSync", 1024L, "Block")) {
store.startTrace("tr_example", "planner", "Audit repo");
var spanOut = new ObjectMapper().createObjectNode().put("count", 4);
store.logSpan("sp_01", "tr_example", "list_files", "tool", spanOut, null, 12.4);
store.finishTrace("tr_example", "completed");
store.flush();
}
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
| Mode | When a write returns | Tradeoff |
|---|---|---|
Memory | After the in-memory write | Fast; data is lost when the process exits |
DiskSync | After SQLite commits the write to its WAL | The transaction is committed before return; the default synchronous=NORMAL setting can lose recent commits after an operating-system or power failure |
Tiered | After the write enters a bounded buffer | Groups 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:
| Store | Contains | Commit behavior |
|---|---|---|
| Trace store | Traces, sessions, workflow state, and checkpoints | Recovery log with synchronous=NORMAL |
| Durable mailbox | Messages and delivery claims | WAL mode with synchronous=FULL |
| Async job store | Background job state | WAL 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.
| Policy | Behavior when full | Suitable for |
|---|---|---|
Reject | Return an error for the new write | Callers that can retry or report backpressure |
ForceFlush | Commit buffered writes before accepting the new write | Callers that prefer to wait for durability |
Block | Wait until buffer space is available | Background writers that can pause |
| Event drop policy | Drop the configured oldest or newest best-effort event | Non-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.