Skip to content

fix: skip remote history for zero session limit - #4241

Closed
ump45nose wants to merge 1 commit into
openai:mainfrom
ump45nose:fix/conversations-session-zero-limit
Closed

fix: skip remote history for zero session limit#4241
ump45nose wants to merge 1 commit into
openai:mainfrom
ump45nose:fix/conversations-session-zero-limit

Conversation

@ump45nose

Copy link
Copy Markdown

Summary

This pull request fixes OpenAIConversationsSession.get_items() when the effective session history limit is zero.

The Agents SDK session contract uses limit=0 to disable history retrieval, but this backend forwarded zero to conversations.items.list. The Conversations API only accepts limits from 1 to 100, so the call failed instead of returning no history. The method now resolves the effective limit before initializing a remote conversation and returns an empty list locally when it is zero.

This preserves the existing behavior for positive limits and None, and avoids creating an otherwise unused remote conversation.

API reference: https://developers.openai.com/api/reference/python/resources/conversations/subresources/items/methods/list

Test plan

  • uv run pytest -q tests/memory/test_openai_conversations_session.py (37 passed)
  • uv run ruff check src/agents/memory/openai_conversations_session.py tests/memory/test_openai_conversations_session.py
  • uv run mypy src/agents/memory/openai_conversations_session.py
  • git diff --check

The repository-wide verification script was not run locally; this PR remains Draft while CI supplies the broader regression signal.

Issue number

N/A

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 commented Aug 6, 2026

Copy link
Copy Markdown
Member

Thanks for sharing the idea here, but I don't think this additional logic for limit: 0 use cases is necessary in real-world apps.

@seratch seratch closed this Aug 6, 2026
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.

2 participants