Skip to content

OpenAIConversationsSession get_items(limit>provider page size) forwards the session limit as provider page size #4757

Closed

Description

@sylvesterkaczmarek

OpenAIConversationsSession.get_items(limit=N) currently forwards N directly to conversations.items.list(limit=N). For large session limits this couples the SDK's local history cutoff to the provider's page-size constraints and can make an otherwise valid Session.get_items(limit=N) call fail before client pagination occurs.

A previous implementation attempt in #4721 confirmed the underlying bug. Maintainer guidance there was to avoid copying provider page-size constants into the SDK and instead omit limit from conversations.items.list(), letting the OpenAI client handle provider pagination while preserving the SDK's existing local cutoff.

Expected behavior: for a finite session limit, request items in descending order without forwarding the SDK limit as a provider page size, stop locally once N items are collected, then reverse them into chronological order.

Activity

  1. tiagovilasboas commented on Sep 11, 2026

    @tiagovilasboas
    Contributor

    I'd like to take this.

    Plan: stop forwarding the session limit as conversations.items.list(limit=…). Request items descending without a provider page-size copy, cut locally at N, reverse to chronological. Matches the guidance from #4721.

  2. sylvesterkaczmarek commented on Sep 12, 2026

    @sylvesterkaczmarek
    ContributorAuthor

    Thanks, that matches the intended fix. Please include a regression with a session limit above the provider page size and verify the returned items are still capped locally and chronological.

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

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions