fix(sessions): do not forward session limit as Conversations page size - #4961
Open
tiagovilasboas wants to merge 3 commits into
Open
fix(sessions): do not forward session limit as Conversations page size#4961tiagovilasboas wants to merge 3 commits into
tiagovilasboas wants to merge 3 commits into
Conversation
Omit limit from conversations.items.list so the OpenAI client paginates. Apply the Session.get_items cutoff locally after collecting N newest items.
Assert get_items(limit=101) omits provider page size, stops after N items, and returns the newest items in chronological order.
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
This pull request fixes
OpenAIConversationsSession.get_items(limit=N)forwarding the SDK history cutoff asconversations.items.list(limit=N).For a large finite session limit that exceeds the Conversations API page-size constraint, an otherwise valid
Session.get_items(limit=N)call could fail before the OpenAI Python client paginated. Maintainer guidance on #4721 was to omitlimitfrom the provider list call, let the client own pagination, and keep the SDK cutoff local.The finite-history path now requests items in descending order without a provider page-size argument, stops locally once N items are collected, and reverses them into chronological order. Unlimited and zero-limit paths are unchanged.
Test plan
conversations.items.list()is called withoutlimituv run pytest -q tests/memory/test_openai_conversations_session.py tests/memory/test_session_limit.py— 56 passed.agents/skills/code-change-verification/scripts/run.sh:make format— passedmake lint— passedmake typecheck— passed (mypy + pyright, 0 errors)make tests— 9611 passed, 29 skipped (parallel); 77 passed, 4 skipped, 55 deselected (serial)Issue number
Fixes #4757
Checks
.agents/skills/code-change-verification/scripts/run.sh/reviewbefore submitting this PR