fix: send realtime tool failure outputs#3435
Closed
pragnyanramtha wants to merge 1 commit into
Closed
Conversation
4 tasks
seratch
reviewed
May 17, 2026
| RealtimeModelSendToolOutput( | ||
| tool_call=event, | ||
| output=f"Tool {event.name} failed: {error}", | ||
| start_response=True, |
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.
Summary
Known realtime function tool and handoff failures could leave the model-visible tool call incomplete. When tool execution ran in the background, the SDK emitted a local
RealtimeError, but it did not send aRealtimeModelSendToolOutputback to the model, so the realtime session could wait until the server-side tool timeout.This PR keeps the existing exception path intact while completing the model-visible tool call:
RealtimeModelSendToolOutput(start_response=True)when a known function tool raises, includingtimeout_behavior="raise_exception"Test plan
Passed:
make formatmake format-checkmake lintuv run pytest tests/realtime/test_session.py::TestToolCallExecution::test_function_tool_timeout_raise_exception_propagates tests/realtime/test_session.py::TestToolCallExecution::test_function_call_event_timeout_raise_exception_enqueues_error tests/realtime/test_session.py::TestToolCallExecution::test_function_call_event_exception_sends_model_visible_output tests/realtime/test_session.py::TestToolCallExecution::test_handoff_tool_failure_sends_model_visible_output -quv run pytest tests/realtime/test_session.py -q(78 passed)uv run pytest tests/realtime -q(246 passed)uv run mypy src/agents/realtime/session.py tests/realtime/test_session.pyuv run pyright src/agents/realtime/session.py tests/realtime/test_session.pygit diff --checkAttempted:
make typecheckwas attempted, but repo-wide checks failed outside this patch on existing optional-extra/baseline issues, including missingnumpy,litellm,temporalio,sqlalchemy,boto3/botocore, and existingrunloopsandbox type-form errors. The touched realtime files pass targeted mypy and pyright as listed above.Issue number
Fixes #3356
Checks
make lintandmake format