Skip to content

fix: make auto-pagination cursor direction order-aware#78

Open
kianjones9 wants to merge 1 commit intomainfrom
kian/fix-desc-pagination-cursor
Open

fix: make auto-pagination cursor direction order-aware#78
kianjones9 wants to merge 1 commit intomainfrom
kian/fix-desc-pagination-cursor

Conversation

@kianjones9
Copy link
Contributor

Summary

  • Make shared pagination cursor advancement order-aware in src/letta_client/pagination.py
  • Preserve existing API params (before, after, order) while avoiding duplicate pages under order=\"desc\"
  • New behavior:
    • forward + order=asc -> after=<last_id>
    • forward + order=desc -> before=<first_id>
    • backward (before provided) -> before=<first_id>

Why

Auto-pagination currently assumes ascending traversal and always advances with after, which can duplicate items for descending endpoints.

Compatibility

  • No server contract changes
  • No endpoint default changes
  • Users that explicitly pass order keep intuitive ordering

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant