fix(run): fail fast on incompatible handoff settings with server conversation#2457
fix(run): fail fast on incompatible handoff settings with server conversation#2457OiPunk wants to merge 4 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: 2ddabfe993
ℹ️ 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".
|
Thanks, great catch. I updated the validation to skip disabled explicit handoffs (is_enabled=False) when collecting server-conversation constraints, so inactive handoffs no longer trigger false positives. I also added regression tests covering:
Local validation after the fix:
Fix commit: 95b4213. |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 95b4213ad1
ℹ️ 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".
|
Addressed in commit 482e17a. What I changed:
Local verification:
|
Summary
This PR adds an early validation guard for server-managed conversations to prevent unsupported handoff combinations from reaching the model API.
When
conversation_id,previous_response_id, orauto_previous_response_idis used, the SDK now raises aUserErrorif handoff settings require local history/tool-state rewriting that the server-managed flow cannot support.Specifically, it rejects:
nest_handoff_history=True(when no input filter is set on that handoff)remove_all_tools(handoff-local or globalrun_config.handoff_input_filter)Why
Issue:
#2151With server-managed conversation, these handoff options can produce invalid or conflicting assumptions about what is sent to downstream turns. The current behavior fails late. This change fails fast with a clear error message before execution starts.
Changes
validate_server_conversation_handoff_settings(...)inagent_runner_helpers.Agenthandoffs and explicitHandoffentries.Runner.runandRunner.run_streamed:remove_all_toolsrun_config.handoff_input_filter=remove_all_toolsValidation
uv run ruff check src/agents/run_internal/agent_runner_helpers.py src/agents/run.py tests/test_agent_runner.pyuv run mypy src/agents/run_internal/agent_runner_helpers.py src/agents/run.py tests/test_agent_runner.pyenv -u all_proxy -u ALL_PROXY -u http_proxy -u HTTP_PROXY -u https_proxy -u HTTPS_PROXY uv run pytest tests/test_agent_runner.py -k "server_conversation" -qenv -u all_proxy -u ALL_PROXY -u http_proxy -u HTTP_PROXY -u https_proxy -u HTTPS_PROXY uv run pytest tests/test_agent_runner.py -qenv -u all_proxy -u ALL_PROXY -u http_proxy -u HTTP_PROXY -u https_proxy -u HTTPS_PROXY uv run python -m trace --count --coverdir /tmp/openai_agents_2151_trace --module pytest tests/test_agent_runner.py -k "server_conversation" -qTrace output confirms the newly added validation paths in
src/agents/run_internal/agent_runner_helpers.pyand their call sites insrc/agents/run.pyare exercised.