- items
- TResponse
- TResponseInputItem
- TResponseOutputItem
- TResponseStreamEvent
- ToolCallItemTypes
- RunItem
- RunItemBase
- MessageOutputItem
- HandoffCallItem
- HandoffOutputItem
- ToolCallItem
- ToolCallOutputItem
- ReasoningItem
- MCPListToolsItem
- MCPApprovalRequestItem
- MCPApprovalResponseItem
- ModelResponse
- ItemHelpers
Items
TResponseInputItemmodule-attribute
A type alias for the ResponseInputItemParam type from the OpenAI SDK.
TResponseOutputItemmodule-attribute
A type alias for the ResponseOutputItem type from the OpenAI SDK.
TResponseStreamEventmodule-attribute
A type alias for the ResponseStreamEvent type from the OpenAI SDK.
ToolCallItemTypesmodule-attribute
ToolCallItemTypes:TypeAlias=Union[ResponseFunctionToolCall,ResponseComputerToolCall,ResponseFileSearchToolCall,ResponseFunctionWebSearch,McpCall,ResponseCodeInterpreterToolCall,ImageGenerationCall,LocalShellCall,dict[str,Any],]A type that represents a tool call item.
RunItemmodule-attribute
RunItem:TypeAlias=Union[MessageOutputItem,HandoffCallItem,HandoffOutputItem,ToolCallItem,ToolCallOutputItem,ReasoningItem,MCPListToolsItem,MCPApprovalRequestItem,MCPApprovalResponseItem,]An item generated by an agent.
RunItemBasedataclass
Bases:Generic[T],ABC
Source code insrc/agents/items.py
raw_iteminstance-attribute
The raw Responses item from the run. This will always be either an output item (i.e.openai.types.responses.ResponseOutputItem or an input item(i.e.openai.types.responses.ResponseInputItemParam).
release_agent
Release the strong reference to the agent while keeping a weak reference.
Source code insrc/agents/items.py
to_input_item
to_input_item()->TResponseInputItemConverts this item into an input item suitable for passing to the model.
Source code insrc/agents/items.py
MessageOutputItemdataclass
Bases:RunItemBase[ResponseOutputMessage]
Represents a message from the LLM.
Source code insrc/agents/items.py
release_agent
Release the strong reference to the agent while keeping a weak reference.
Source code insrc/agents/items.py
to_input_item
to_input_item()->TResponseInputItemConverts this item into an input item suitable for passing to the model.
Source code insrc/agents/items.py
HandoffCallItemdataclass
Bases:RunItemBase[ResponseFunctionToolCall]
Represents a tool call for a handoff from one agent to another.
Source code insrc/agents/items.py
raw_iteminstance-attribute
The raw response function tool call that represents the handoff.
release_agent
Release the strong reference to the agent while keeping a weak reference.
Source code insrc/agents/items.py
to_input_item
to_input_item()->TResponseInputItemConverts this item into an input item suitable for passing to the model.
Source code insrc/agents/items.py
HandoffOutputItemdataclass
Bases:RunItemBase[TResponseInputItem]
Represents the output of a handoff.
Source code insrc/agents/items.py
raw_iteminstance-attribute
raw_item:TResponseInputItemThe raw input item that represents the handoff taking place.
to_input_item
to_input_item()->TResponseInputItemConverts this item into an input item suitable for passing to the model.
Source code insrc/agents/items.py
ToolCallItemdataclass
Bases:RunItemBase[Any]
Represents a tool call e.g. a function call or computer action call.
Source code insrc/agents/items.py
release_agent
Release the strong reference to the agent while keeping a weak reference.
Source code insrc/agents/items.py
to_input_item
to_input_item()->TResponseInputItemConverts this item into an input item suitable for passing to the model.
Source code insrc/agents/items.py
ToolCallOutputItemdataclass
Bases:RunItemBase[Any]
Represents the output of a tool call.
Source code insrc/agents/items.py
outputinstance-attribute
The output of the tool call. This is whatever the tool call returned; theraw_itemcontains a string representation of the output.
to_input_item
to_input_item()->TResponseInputItemConverts the tool output into an input item for the next model turn.
Hosted tool outputs (e.g. shell/apply_patch) carry astatus field for the SDK'sbook-keeping, but the Responses API does not yet accept that parameter. Strip it from thepayload we send back to the model while keeping the original raw item intact.
Source code insrc/agents/items.py
release_agent
Release the strong reference to the agent while keeping a weak reference.
Source code insrc/agents/items.py
ReasoningItemdataclass
Bases:RunItemBase[ResponseReasoningItem]
Represents a reasoning item.
Source code insrc/agents/items.py
release_agent
Release the strong reference to the agent while keeping a weak reference.
Source code insrc/agents/items.py
to_input_item
to_input_item()->TResponseInputItemConverts this item into an input item suitable for passing to the model.
Source code insrc/agents/items.py
MCPListToolsItemdataclass
Bases:RunItemBase[McpListTools]
Represents a call to an MCP server to list tools.
Source code insrc/agents/items.py
release_agent
Release the strong reference to the agent while keeping a weak reference.
Source code insrc/agents/items.py
to_input_item
to_input_item()->TResponseInputItemConverts this item into an input item suitable for passing to the model.
Source code insrc/agents/items.py
MCPApprovalRequestItemdataclass
Bases:RunItemBase[McpApprovalRequest]
Represents a request for MCP approval.
Source code insrc/agents/items.py
release_agent
Release the strong reference to the agent while keeping a weak reference.
Source code insrc/agents/items.py
to_input_item
to_input_item()->TResponseInputItemConverts this item into an input item suitable for passing to the model.
Source code insrc/agents/items.py
MCPApprovalResponseItemdataclass
Bases:RunItemBase[McpApprovalResponse]
Represents a response to an MCP approval request.
Source code insrc/agents/items.py
release_agent
Release the strong reference to the agent while keeping a weak reference.
Source code insrc/agents/items.py
to_input_item
to_input_item()->TResponseInputItemConverts this item into an input item suitable for passing to the model.
Source code insrc/agents/items.py
ModelResponse
Source code insrc/agents/items.py
outputinstance-attribute
output:list[TResponseOutputItem]A list of outputs (messages, tool calls, etc) generated by the model
response_idinstance-attribute
An ID for the response which can be used to refer to the response in subsequent calls to themodel. Not supported by all model providers.If using OpenAI models via the Responses API, this is theresponse_id parameter, and it canbe passed toRunner.run.
to_input_items
to_input_items()->list[TResponseInputItem]Convert the output into a list of input items suitable for passing to the model.
Source code insrc/agents/items.py
ItemHelpers
Source code insrc/agents/items.py
367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522 | |
extract_last_contentclassmethod
extract_last_content(message:TResponseOutputItem)->strExtracts the last text content or refusal from a message.
Source code insrc/agents/items.py
extract_last_textclassmethod
extract_last_text(message:TResponseOutputItem,)->str|NoneExtracts the last text content from a message, if any. Ignores refusals.
Source code insrc/agents/items.py
input_to_new_input_listclassmethod
input_to_new_input_list(input:str|list[TResponseInputItem],)->list[TResponseInputItem]Converts a string or list of input items into a list of input items.
Source code insrc/agents/items.py
text_message_outputsclassmethod
text_message_outputs(items:list[RunItem])->strConcatenates all the text content from a list of message output items.
Source code insrc/agents/items.py
text_message_outputclassmethod
text_message_output(message:MessageOutputItem)->strExtracts all the text content from a single message output item.
Source code insrc/agents/items.py
tool_call_output_itemclassmethod
Creates a tool call output item from a tool call and its output.
Accepts either plain values (stringified) or structured outputs usinginput_text/input_image/input_file shapes. Structured outputs may beprovided as Pydantic models or dicts, or an iterable of such items.