Fix sensory buffer loop for oversized messages#66
Draft
taixiansen2 wants to merge 1 commit into
Draft
Conversation
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
Fixes an infinite loop in
SenMemBufferManager.add_messages()when a single user message is larger than the sensory memory buffer'smax_tokenswhile the current buffer is empty.In the previous logic, this edge case called
cut_with_segmenter()on an empty buffer. No segment was emitted and the oversized message was not added toprocessed_messages, so it was never removed frombig_buffer. The outerwhile self.big_bufferloop then processed the same message forever.This PR handles that edge case by emitting the oversized user turn as a singleton segment, optionally including the following assistant message, and consuming those messages from
big_buffer.Changes
messagesand empty internal buffers.force_segment=Truecleanup to clear the whole remaining buffer withlen(self.buffer)instead oflen(boundaries).Validation
ast.parse.PYTHONPATH=srcbecausepytestis not installed in the local Windows Python environment:In our downstream LongMemEval reproduction, this fixes a run that previously stalled at
Ingest 01493427: 105/242; after the fix, the case completed successfully.