mirror of
https://github.com/open-webui/open-webui.git
synced 2026-09-19 00:03:21 +00:00
Critical: INCR and XADD are separate calls, so with overlapping emitters the stream's append order can diverge from seq order (a concurrent emitter can win INCR for seq N+1 yet lose XADD and land ahead of seq N in the stream). Replay returned entries in append order, which meant the later-seq-but-earlier-in-stream frame would advance lastSeq, permanently dropping the earlier-seq-but-later-in- stream frame via the client dedupe guard. Fix: _stream_log_read now sorts envelopes by seq before returning, making replay order independent of append order. Warning: loadChat now unconditionally triggers resume for unfinished assistants with last_seq=0, which in ENABLE_REALTIME_CHAT_SAVE mode (DB is kept up-to-date per token) would replay content already loaded from the DB and produce duplicates. Gate _stream_seq_allocate on `not ENABLE_REALTIME_CHAT_SAVE` — in realtime mode frames emit without a seq, nothing is logged, client bypasses dedupe/resume, DB stays authoritative for refresh recovery. Suggestion: fence flush sort comparator returned 0 for mixed seq/no-seq pairs, which is not strict ordering. Replaced with a partition (seq-bearing vs. seq-less) + sort the seq-bearing subset + concat. Deterministic regardless of engine sort stability. |
||
|---|---|---|
| .. | ||
| main.py | ||
| utils.py | ||