Conversation
Contributor
529349029
force-pushed
the
main
branch
8 times, most recently
from
May 31, 2026 07:54
255821f to
3fc76e9
Compare
529349029
force-pushed
the
main
branch
5 times, most recently
from
June 10, 2026 00:47
00e823f to
41fd491
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Fix a bug where state.db loses assistant responses when
_drop_trailing_empty_response_scaffoldingpops trailing messages before_flush_messages_to_session_dbruns, causing_last_flushed_db_idxto overshootlen(messages)and skip all writes.Root Cause
In
_flush_messages_to_session_db,flush_from = max(start_idx, self._last_flushed_db_idx). When_persist_sessioncalls_drop_trailing_empty_response_scaffolding(messages)first, trailing messages can be popped, reducinglen(messages). But_last_flushed_db_idxwas already set to the old (higher) value by a previous intermediate persist call. Result:flush_from >= len(messages),messages[flush_from:]is empty, nothing written.Fix
Evidence
Session
mpjo2msf4kzhz9in state.db: user=26, assistant=123, tool=114 (missing ~43 assistant responses). Same session in WebUI local DB: user=26, assistant=166, tool=122 (complete).