fix: unconditional lazy hydration in get_session
Some checks are pending
ci / docker publish / build (amd64) (push) Waiting to run
ci / docker publish / build (arm64) (push) Waiting to run
ci / docker publish / merge manifest + tag (push) Blocked by required conditions

Drop the message_count > 0 guard — if it's 0 in the DB (stale metadata,
race condition, failed persist), the session stays empty and the model
gets no conversation history. The UI history endpoint has its own DB
fallback, so messages display correctly but never reach the LLM.

Now hydrate from DB whenever history is empty, regardless of message_count.
Trade-off: one extra DB query for genuinely empty sessions (rare).
This commit is contained in:
Lukas Parsons 2026-07-07 22:12:22 -04:00
parent 60452712b2
commit 20c7d7e6b7

View file

@ -382,7 +382,7 @@ class SessionManager:
else: else:
cached = self.sessions[session_id] cached = self.sessions[session_id]
# Lazy hydrate: metadata-only entries get their messages on first read. # Lazy hydrate: metadata-only entries get their messages on first read.
if not cached.history and getattr(cached, "message_count", 0) > 0: if not cached.history:
self._load_session_from_db(session_id) self._load_session_from_db(session_id)
# Keep model/endpoint metadata fresh. Endpoint deletion can clear the # Keep model/endpoint metadata fresh. Endpoint deletion can clear the