openai/openai-agents-python

HandoffCallItem event is missing in v0.2.11

Closed this issue · 2 comments

Please read this first

  • Have you read the docs?Agents SDK docs
  • Have you searched for related issues? Others may have faced similar issues.

Yes

Describe the bug

code:

def handoff_message_filter(handoff_input_data: HandoffInputData) -> HandoffInputData:
    handoff_message_data = remove_handoff_tools(handoff_input_data)
    return HandoffInputData(
        input_history=handoff_input_data.input_history,
        pre_handoff_items=tuple(handoff_message_data.pre_handoff_items),
        new_items=tuple(handoff_message_data.new_items),
    )

# === remove HandoffCallItem and HandoffOutputItem 
def _remove_tools_from_items(items: tuple[RunItem, ...]) -> tuple[RunItem, ...]:
    filtered_items = []
    for item in items:
        if (
                isinstance(item, HandoffCallItem)
                or isinstance(item, HandoffOutputItem)
        ):
            continue
        filtered_items.append(item)
    return tuple(filtered_items)


agent = Agent(
        name='test',
        instructions=instructions
    )

  agent.handoffs = [handoff(
        agent= test2,
        tool_name_override=tool_key,
        tool_description_override=tool_description,
        input_filter=handoff_message_filter
    )]


agent_result = Runner.run_streamed(
            starting_agent=agent,
            input='xxx',
        )

async for event in agent_result.stream_events():
  if isinstance(event.item, HandoffCallItem):
     # ===  HandoffCallItem missing
     pass

HandoffCallItem is missing.
It might be caused by adding input_filter=handoff_message_filter in agent.handoffs.
Agents SDK v0.2.9 is good, but v0.2.11 is not

Debug information

  • Agents SDK version: (e.g. v0.0.3)
    v0.2.11
  • Python version (e.g. Python 3.10)
    3.12

Thanks for asking the question. Handing off can be done through function tool calling, so if you remove the items using a filter, the handoff data could be removed as well.

function

Agents SDK v0.2.9 is good, but v0.2.11 is not