Skip to content

fix(sessions): cap Conversations item pagination at the API limit - #4721

Closed
hsusul wants to merge 1 commit into
openai:mainfrom
hsusul:fix/conversations-page-size-cap
Closed

hsusul wants to merge 1 commit into
openai:mainfrom
hsusul:fix/conversations-page-size-cap

Conversation

@hsusul

@hsusul hsusul commented Aug 27, 2026

Copy link
Copy Markdown
Contributor

Summary

Cap the Conversations items provider page size at 100 while preserving the caller's larger get_items(limit=N) cutoff. This lets session callers retrieve more than 100 recent items without sending an invalid page-size value to the API, while retaining chronological output ordering.

Test plan

  • uv run pytest -q tests/memory/test_openai_conversations_session.py — 39 passed
  • uv run ruff format --check — 921 files already formatted
  • uv run ruff check — passed
  • uv run python .github/scripts/check_optional_truthiness.py src/agents — passed
  • uv run mypy src — passed (307 source files)
  • uv run pyright --project pyrightconfig.json --threads "${PYRIGHT_THREADS:-4}" — passed
  • make tests-serial — 77 passed, 4 skipped, 55 deselected
  • make tests-parallel — 9234 passed, 28 skipped; one unrelated failure in tests/sandbox/test_run_cwd.py::test_python_skill_uses_absolute_root_from_nested_workdir, reproduced unchanged on upstream/main

Issue number

None.

Checks

  • I've added new tests, if relevant
  • I've run .agents/skills/code-change-verification/scripts/run.sh
  • I've confirmed all verification steps pass
  • If using Codex, I've run /review before submitting this PR

@seratch seratch changed the title Cap Conversations item pagination at the API limit fix(sessions): cap Conversations item pagination at the API limit Aug 27, 2026
@seratch

seratch commented Aug 27, 2026

Copy link
Copy Markdown
Member

Thanks for investigating and fixing the large-limit failure. The underlying bug is real, but I do not think we should copy the Conversations API's current page-size maximum into the Agents SDK. _MAX_ITEMS_PAGE_SIZE = 100 creates a second source of truth for provider-owned behavior, and the added test makes that duplicated constraint part of this repository's implementation.

The simpler fix is to omit limit from conversations.items.list() and let the OpenAI Python client handle provider pagination, while the existing local cutoff continues to enforce the Session.get_items(limit=N) contract.

Since that replaces the central implementation and test in this PR rather than refining them, I am going to close this PR and pursue the narrower approach separately. Thank you for identifying the original issue.

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants