You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Closes the cache-token propagation sweep by migrating the SQL-backed
storage layer to match the InMemory / ITokenUsage / UsageLedger work.
Before this, consumers on the SQL adapter (persistent conversations
across process restarts) saw the same 0/undefined cache fields even
though the API, strategies, and ledger surfaces all now forward them.
Changes to SqlStorageAdapter:
- messages schema gains cacheReadTokens + cacheCreationTokens INTEGER
columns. Fresh DBs get them via CREATE TABLE IF NOT EXISTS; existing
DBs via an idempotent ALTER TABLE ADD COLUMN wrapped in try/catch
for the duplicate-column case (SQLite does not support IF NOT EXISTS
on ADD COLUMN until 3.35; Postgres does but the catch is harmless
on success).
- Message INSERT path writes the cache counters when the caller
supplies them, null when undefined — preserves the "not reported"
vs "zero hits" signal.
- getConversationTokenUsage now SUMs cacheReadTokens +
cacheCreationTokens and uses COUNT(col) to detect whether any
message actually reported each value, only setting the optional
return fields when at least one did.
- rowToMessage hydrates cache fields back onto the message's usage
when the row carries them.
Typecheck clean. 278/278 core tests still pass (no adapter tests
exist to extend yet; storage adapter integration is covered by the
broader conversation-manager flows).
0 commit comments