Repository navigation
Forward Responses context management in OpenAI agents - #741
Closed
rakshit-hud wants to merge 2 commits into
Closed
rakshit-hud wants to merge 2 commits into
rakshit-hud wants to merge 2 commits into
Conversation
rakshit-hud
marked this pull request as ready for review
October 23, 2026 02:39
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
Collaborator
|
Closing for now: there's no current consumer, and |
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.
Long tool-using Responses rollouts can exhaust their context window because
OpenAIConfigcurrently drops the provider’scontext_managementoption. Agents therefore cannot request native server-side compaction through their normal configuration.Add the canonical Responses context-management type to
OpenAIConfigand forward it on every provider call. The setting survivesagent.dump()and configuration round trips for hosted execution. When unset, provider requests retain their existing behavior. The normalprevious_response_idchain continues to carry state, including opaque compaction output items.The official compaction guide describes the API contract. A small synthetic gateway check emitted compaction items and retained an exact required ID across a continued response. Adopting this setting in hosted rollouts requires the runner to use the updated SDK; this PR does not publish a release or update a deployed runner.
Depends on #742 for the pre-existing Anthropic message-schema compatibility fix. The base branch keeps that prerequisite separate from this Responses change.
Validation:
Runlifecycle coverage of opt-in forwarding on both turns, opaque compaction output, continuation IDs, configuration serialization and the unchanged default.Note
Low Risk
Opt-in config passthrough to the Responses API with unchanged defaults; no auth, data, or pruning logic changes.
Overview
Adds optional
OpenAIConfig.context_managementso OpenAI Responses agents can opt into provider server-side compaction (and other context-management policies) instead of dropping that knob.OpenAIAgentreads the setting from config and passes it on everyresponses.createcall; when unset, requests still omit the parameter (unchanged behavior). The value round-trips throughagent.dump()/ hosted config forOpenAIConfig.model_validate.Docs describe enabling compaction with a
compact_thresholdbelow the model window; the agent still chains turns viaprevious_response_idand does not client-side prune. New tests cover per-turn forwarding, default omit, and config serialization across a multi-turn run (including opaque compaction output items).Reviewed by Cursor Bugbot for commit 0329b80. Bugbot is set up for automated code reviews on this repo. Configure here.