feat: add optional wrapper parameter to Session methods#2488
feat: add optional wrapper parameter to Session methods#2488Limitless2023 wants to merge 2 commits intoopenai:mainfrom
Conversation
Add optional RunContextWrapper parameter to Session protocol methods (get_items, add_items, pop_item, clear_session) to allow custom sessions to access context data during history operations. This enables custom sessions to make decisions based on agent context, such as storing agent-specific information during handoff. Fixes openai#2072
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: f6cf6a5160
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| Returns: | ||
| List of input items representing the conversation history | ||
| """ | ||
| return await self.underlying_session.get_items(limit, wrapper) |
There was a problem hiding this comment.
Preserve legacy session signatures when forwarding wrapper
OpenAIResponsesCompactionSession.get_items now forwards wrapper positionally via self.underlying_session.get_items(limit, wrapper), which passes an extra argument even when wrapper is None. Any existing underlying session that still implements the pre-change signature (e.g. get_items(limit=None)) will raise TypeError as soon as this wrapper calls into it, so this is not backward compatible despite wrapper being optional; the same unconditional extra-argument forwarding pattern is repeated in add_items, pop_item, and clear_session.
Useful? React with 👍 / 👎.
Summary
Add optional parameter to Session protocol methods (, , , ) to allow custom sessions to access context data during history operations.
This enables custom sessions to make decisions based on agent context, such as storing agent-specific information during handoff.
Fixes #2072
Changes
Test Plan
Existing tests should pass since the new parameter is optional with a default value of , maintaining backward compatibility.