-
Notifications
You must be signed in to change notification settings - Fork 2.1k
Closed
Labels
documentationImprovements or additions to documentationImprovements or additions to documentationfeature:core
Description
The handoffs documentation mentions HandoffInputData
but lacks details such as:
- Exact types and structure of
pre_handoff_items
andnew_items
(RunItem
subtypes likeRunMessageOutputItem
,RunHandoffCallItem
). - Explanation of differences between
input_history
,pre_handoff_items
, andnew_items
. - How
allItems
is derived and affected by changes. - Streaming vs. non-streaming behavior.
- Examples of custom
input_filter
functions modifying these fields.
This leaves developers uncertain about how to use HandoffInputData
effectively, especially for compliance-related filters.
Steps to Reproduce
from openai.agents import Agent, handoff, HandoffInputData
def custom_filter(data: HandoffInputData) -> HandoffInputData:
print(data.pre_handoff_items) # Structure unclear
print(data.new_items) # Structure unclear
return data
target = Agent(name="Target")
source = Agent(
name="Source",
handoffs=[handoff(target, input_filter=custom_filter)]
)
from openai.agents import Runner
Runner.run_sync(source, "Test handoff")
Observed:
- No clear guidance on structure or streaming behavior of
HandoffInputData
.
Expected Behavior
Docs should include:
- Type definitions:
input_history
: tuple of message dictspre_handoff_items
: tuple ofRunItem
subtypes (before handoff turn)new_items
: tuple ofRunItem
subtypes (current turn)allItems
: concatenation of all above
- Purpose and when to modify each field.
- Streaming behavior details.
- Example of a custom
input_filter
:
def gdpr_filter(data: HandoffInputData) -> HandoffInputData:
filtered = [
msg for msg in data.input_history
if "account" not in msg.get("content", "").lower()
]
return HandoffInputData(
input_history=tuple(filtered),
pre_handoff_items=data.pre_handoff_items,
new_items=data.new_items
)
Suggested Fix
- Expand "Handoffs" section with type definitions, field purposes, and streaming notes.
- Add examples of custom filters in
examples/handoffs
. - Update
HandoffInputData
docstring insrc/agents/handoff.py
. - Add tests for
input_filter
field manipulation.
Environment
- SDK Version: Latest (July 29, 2025)
- Python Version: 3.8+
- OS: Any
Labels: documentation, enhancement
Metadata
Metadata
Assignees
Labels
documentationImprovements or additions to documentationImprovements or additions to documentationfeature:core