Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions src/agents/handoffs.py
Original file line number Diff line number Diff line change
Expand Up @@ -119,9 +119,9 @@ class Handoff(Generic[TContext, TAgent]):
True, as it increases the likelihood of correct JSON input.
"""

is_enabled: bool | Callable[[RunContextWrapper[Any], AgentBase[Any]], MaybeAwaitable[bool]] = (
True
)
is_enabled: bool | Callable[
[RunContextWrapper[Any], AgentBase[Any]], MaybeAwaitable[bool]
] = True
"""Whether the handoff is enabled. Either a bool or a Callable that takes the run context and
agent and returns whether the handoff is enabled. You can use this to dynamically enable/disable
a handoff based on your context/state."""
Expand Down Expand Up @@ -264,7 +264,7 @@ async def _invoke_handoff(
async def _is_enabled(ctx: RunContextWrapper[Any], agent_base: AgentBase[Any]) -> bool:
from .agent import Agent

assert callable(is_enabled), "is_enabled must be non-null here"
assert callable(is_enabled), "is_enabled must be callable here"
assert isinstance(agent_base, Agent), "Can't handoff to a non-Agent"
result = is_enabled(ctx, agent_base)

Expand Down