Thalamus · Configuration & integration

Record telemetry and replay history

To retain request history, create a writable directory and add --state-dir ./state to thalamus serve. --state-dir / THALAMUS_STATE_DIR enables SQLite telemetry.db. Completed selections append requests(ts, node, plane, session_fp, ttft_ms, latency_ms, prompt_tokens, completion_tokens, kv_hit, error, stolen, cached_tokens). Time is Unix milliseconds; session fingerprints are 16 SHA-256 hex characters, not stored raw IDs. cached_tokens is the upstream prefix-cache token count; an existing database gains that column on open. Streaming /v1/chat/completions requests have stream_options.include_usage set upstream so the final SSE usage chunk can be recorded. Routing never reads this store to choose members.

TTFT for streaming is measured at the first byte chunk, not semantic token parsing. Nonstreaming TTFT is the completed response latency. Token counts and cached_tokens come from upstream usage, including the trailing SSE usage chunk on a chat completion stream. Missing counts remain unknown (NULL), which is not a claimed cache miss. Rejected requests that never selected a member are not a complete durable audit trail in this completion store.

Retention defaults to 30 days, pruned at startup and hourly. Missing/unwritable directories report disabled (<reason>) in startup logs and health while routing continues. A store that opens but later fails to write reports degraded (...); investigate disk space/permissions rather than treating it as empty traffic. Graceful shutdown flushes the writer.

The server creates a missing state directory when possible. Writes are nonblocking and can drop rows under queue pressure; check health's telemetry_detail.written, dropped, write_errors, pruned and future_dated_rows rather than the status string alone (queue drops need not mark it degraded). Future-dated rows are retained and reported for clock-skew diagnosis. Abrupt termination can lose queued rows even though already-written history survives restart.

Query history without a running daemon:

thalamus replay --since 1h --state-dir ./state --node reasoner --json

The query is read-only, inclusive of --since, ordered oldest-first (insertion order breaks equal timestamp ties), with no upper time bound or pagination option. JSON lines contain ts (Unix milliseconds), time (UTC RFC 3339), node, plane, session_fp, ttft_ms, latency_ms, prompt_tokens, completion_tokens, cached_tokens, kv_hit, error, stolen. Unknown measurements are null, kv_hit and stolen are booleans when known, and HTTP failures are represented as error: "http_<status>". A broken/dropped stream can retain the original upstream HTTP status, so a null error is not proof of full delivery. Preserve the replay exit-code distinctions in automation: successful zero rows and an absent database are different outcomes.