Skip to content

MCQ 100 - Handoff Parameter Structure

The MCQ was intentionally big with useless scenario but the core question was: Which parameter structure correctly represents the difference between agent-level and run-level hook implementations?

Answer: D

Agent Hooks

Python
1
2
3
4
5
6
7
8
9
async def on_handoff(
    self,
    context: RunContextWrapper[TContext],
    agent: TAgent,
    source: TAgent,
) -> None:
    """Called when the agent is being handed off to. The `source` is the agent that is handing
    off to this agent."""
    pass

Run Hooks

Python
1
2
3
4
5
6
7
8
    async def on_handoff(
        self,
        context: RunContextWrapper[TContext],
        from_agent: TAgent,
        to_agent: TAgent,
    ) -> None:
        """Called when a handoff occurs."""
        pass

Note: Source Agent in on_handoff of RunHooks is the third parameter while fourth in AgentHooks.

Source: openai-agents-python/src/agents/lifecycle.py