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
perf(core): avoid bulk-loading every journal segment on incremental session-log reads #4083
JournalSessionLog.scan(after, through) always calls loadCommitSegments(), which lists every commits/* object and bulk-reads all of their values. This happens for every readAfter(...) call.
AG-UI /agui/connect follows the session log and calls readAfter(cursor, 256) every 200 ms. When the cursor is near the head only a few events are new, but the current code still reads the whole journal's commit payloads from the store (on the JDBC store: SELECT item_key, value_json, version ... WHERE item_key IN (...)).
On long conversations this turns a small tail read into repeated full-journal reads.
Expected
Bulk loading is only worth it when replaying from the beginning. For incremental reads (after > 0), only the segments between head and after are needed; committedSegment(id, null) already falls back to a per-segment read.
Proposed change
// Only a full replay (after == 0) is worth a bulk load; incremental reads// should read segments on demand so polling does not re-read the whole journal.Map<String, AtomicSessionStorage.Value> loadedSegments =
after == 0 ? loadCommitSegments() : null;
Acceptance
scan(after > 0, through) does not call listPaths / readAll.
scan(0, through) keeps the bulk path.
The emitted event sequence is identical on both paths.
Implementation proposed in #4085: bulk pre-read is now limited to after == 0, and incremental reads use the existing per-segment read fallback. Tests cover the no-list/no-readAll assertion, the bulk path, and identical event sequences.
Activity
chcodex commentedon Nov 9, 2026
Implementation proposed in #4085: bulk pre-read is now limited to
after == 0, and incremental reads use the existing per-segmentreadfallback. Tests cover the no-list/no-readAll assertion, the bulk path, and identical event sequences.