Repository navigation
Conversation
The two message-page helpers sliced with the raw offset when a positive limit was given: messages[offset : offset + limit] with a negative offset returned an empty/wrong page, while the no-limit branch treated the same offset as absent. get_session_messages(sid, limit=5, offset=-1) on a 10-message session returned []. Mirror _apply_sort_limit_offset's guards in _entries_to_session_messages and _entries_to_subagent_messages, which the SessionStore path already follows: non-positive offsets are treated as absent and a positive limit takes the first entries after the offset. Fixes anthropics#1519
This branch has not been deployed
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 #1519.
The two message-page helpers (
_entries_to_session_messages,_entries_to_subagent_messages) sliced with the raw offset whenever a positivelimitwas given:messages[offset : offset + limit]withoffset=-1evaluated tomessages[-1:4]— an empty or wrong page — while the no-limit branch treated the same negative offset as absent (if offset > 0).get_session_messages(sid, limit=5, offset=-1)on a 10-message session therefore returned[], the same negative offset meaning two different things in the two branches.Both helpers now mirror the guards of
_apply_sort_limit_offset(which the SessionStore listing path already follows, per the comment at its mirror site): a non-positive offset is treated as absent, and a positive limit takes the first entries after that offset.Test plan
TestGetSessionMessages::test_negative_offset_with_limit_treated_as_absent(disk) andTestGetSessionMessagesFromStore::test_negative_offset_with_limit_treated_as_absent(store) —limit=2, offset=-1now equalslimit=2.main(asyncio + trio) and passes with the fix.pytest tests/: 1758 passed, 6 skipped.ruff check,mypy src/ scripts/all clean.