-
Notifications
You must be signed in to change notification settings - Fork 2.6k
Open
Labels
Description
Describe the bug
Passing a callable to the is_enabled
to a Handoff
of a Realtime Agent doesn't work because RealtimeAgent
is not properly imported to the realtime handoffs file.
async def _is_enabled(ctx: RunContextWrapper[Any], agent_base: AgentBase[Any]) -> bool:
assert callable(is_enabled), "is_enabled must be non-null here"
> assert isinstance(agent_base, RealtimeAgent), "Can't handoff to a non-RealtimeAgent"
^^^^^^^^^^^^^
E NameError: name 'RealtimeAgent' is not defined
src/agents/realtime/handoffs.py:151: NameError
Debug information
- Agents SDK version: main branch
- Python 3.11
Repro steps
Remove the following lines from this test, which are forcing it to pass. This is the same issue that occurs when attempting to run the realtime handoff with a callable in a real application.
openai-agents-python/tests/realtime/test_realtime_handoffs.py
Lines 142 to 148 in 095496e
# Patch missing symbol in module to satisfy isinstance in closure | |
import agents.realtime.handoffs as rh | |
if not hasattr(rh, "RealtimeAgent"): | |
from agents.realtime import RealtimeAgent as _RT | |
rh.RealtimeAgent = _RT # type: ignore[attr-defined] |
Expected behavior
The Handoff should work as expected with a callable.