-
Notifications
You must be signed in to change notification settings - Fork 3.2k
fix(run): fail fast on incompatible handoff settings with server conversation #2457
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
fix(run): fail fast on incompatible handoff settings with server conversation #2457
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
💡 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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
💡 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.