fix #2151 shield server-managed handoffs from unsupported history rewrites#2747
fix #2151 shield server-managed handoffs from unsupported history rewrites#2747
Conversation
There was a problem hiding this comment.
💡 Codex Review
openai-agents-python/src/agents/run.py
Lines 657 to 666 in a2ffa47
resolve_interrupted_turn now relies on server_manages_conversation to block unsupported handoff history rewrites, but this non-streamed resume call never passes it. When resuming an interruption with conversation_id/previous_response_id/auto_previous_response_id, pending handoffs run with the default False, so nested handoff history (or filter checks) can be applied against a server-managed thread.
ℹ️ 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".
a2ffa47 to
ccef1d4
Compare
This pull request resolves #2151 by preserving the working handoff path under server-managed continuation instead of failing fast across the board.
#2746 correctly identifies that server-managed conversations cannot safely support local history rewrites, but it rejects both handoff input filters and nested handoff history. In practice, those two cases are not equally risky. Explicit handoff input filters can silently widen or reshape the receiving agent's context, so this change keeps them as a hard
UserError. Nested handoff history, however, can degrade safely to the existing delta-only handoff path that server-managed continuation already supports.As a result, users who opt into
nest_handoff_historyno longer get blocked by a hard error when a safe fallback exists. Server-managed runs continue to hand off successfully, emit a warning that nested history was disabled, and stay aligned with the server-owned transcript. This keeps the strict safety boundary from #2746 where it matters, while avoiding an unnecessary UX regression for the common nested-handoff case.The implementation applies that policy after run-level defaults and per-handoff overrides are merged, and adds regression coverage for non-streamed and streamed runs across both run-level and per-handoff settings.