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
{{ message }}
Repository navigation
SqliteSessions.post() deletes and rewrites all messages on every incremental save — O(n) writes per tool call #19
The agent calls on_message (which triggers storage.post()) after every message appended to the session — including every tool result. For a 20-tool-call turn on a session with 200 messages, this performs 20 × (200 DELETE + 200 INSERT) = 8 000 row writes. On a long session this becomes the dominant cost and causes visible lag in the terminal after each tool call.
Steps to reproduce / context
Profile a long session (100+ messages, 10+ tool calls per turn) with SQLite WAL mode. The post() call time grows linearly with session length.
Expected behavior
Incremental saves should only write new messages since the last save, not rewrite the entire history. The position column already exists and could be used as a monotonic cursor.
Suggested fix
Track the last persisted message count and only insert messages beyond that watermark. The full rewrite should only happen when a message is mutated (e.g., after _compact() rewrites session.messages). Alternatively, add a dirty flag to Session that distinguishes append-only updates from full rewrites.
Activity
🪲 BUG-#19: Snapshot dirty/messages under lock before persisting
🪲 BUG-#19: Persist only new messages instead of rewriting the whole s…