feat: propagate RunContextWrapper to session history read/write paths#2690
feat: propagate RunContextWrapper to session history read/write paths#2690HuxleyHu98 wants to merge 14 commits intoopenai:mainfrom
Conversation
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 53f1c4779f
ℹ️ About Codex in GitHub
Codex has been enabled to automatically 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 👍.
When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 78e39d7b91
ℹ️ About Codex in GitHub
Codex has been enabled to automatically 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 👍.
When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 33cc084153
ℹ️ About Codex in GitHub
Codex has been enabled to automatically 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 👍.
When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 56794b32ad
ℹ️ About Codex in GitHub
Codex has been enabled to automatically 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 👍.
When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: d06a2fe9d3
ℹ️ About Codex in GitHub
Codex has been enabled to automatically 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 👍.
When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".
4c26f31 to
6f96adb
Compare
|
I’ve addressed the review feedback and resolved the outdated Codex conversations. Local checks are passing on my side. Could a maintainer please enable/approve the PR checks when convenient? Thanks! |
168e211 to
3cee188
Compare
Summary
This PR adds backward-compatible
RunContextWrapperpropagation to the main session history read/write paths.Specifically, it:
wrappersupport to:Session.get_items(...)Session.add_items(...)RunContextWrapperthrough:prepare_input_with_session(...)save_result_to_session(...)save_resumed_turn_items(...)wrapperWhy
Issue #2072 is about making runtime context available to session implementations.
The earlier approach in #2488 added optional parameters at the interface level, but it did not actually propagate context from the runner side. This patch focuses on the runner-side propagation path so session implementations that support it can actually receive
RunContextWrapperduring session history reads/writes.At the same time, this keeps older custom session implementations working unchanged.
Scope
This PR intentionally keeps the scope narrow.
Included:
get_itemsadd_itemsNot included:
pop_itemclear_sessionI kept those out on purpose to make the initial change small, testable, and compatibility-focused.
Compatibility
Backward compatibility is handled in the internal dispatch layer.
If a session implementation supports the optional
wrapperparameter, the runner passes the currentRunContextWrapper.If it does not, the runner falls back to the existing call shape, so older custom session implementations continue to work without modification.
Tests
Added coverage for:
wrapperget_items/add_itemsreceive the currentRunContextWrapperRunner.runRunner.run_syncRunner.run_streamedRan:
tests/test_session.pytests/test_agent_runner_streamed.pytests/test_soft_cancel.pytests/test_hitl_session_scenario.pytests/extensions/memory/test_encrypt_session.pytests/memory/test_openai_responses_compaction_session.pyResult:
Static checks:
pyright→ 0 errorsruff check→ passed