Share via


AgentResponseItem Class

Represents a response item from an agent. An AgentResponseItem includes a message payload (ChatMessageContent) and the conversation thread that produced it.

Constructor

AgentResponseItem(*, message: TMessage, thread: AgentThread)

Keyword-Only Parameters

Name Description
message
Required
thread
Required

Methods

__str__

Returns the string representation of the response item, equivalent to its content string.

__hash__

Returns a hash of the response item based on its message and thread.

__str__

Returns the string representation of the response item, equivalent to its content string.

__str__() -> str

__hash__

Returns a hash of the response item based on its message and thread.

__hash__() -> int

Attributes

message

The message content of the response item. This is typically a ChatMessageContent or subclass instance.

message: TMessage

thread

The conversation thread instance associated with this response item. Holds contextual or ephemeral state for the conversation.

thread: AgentThread

content

A property returning the entire message content of this response item.

content: TMessage

items

A property returning the list of item segments in the message content. For example, multiple text or function-call blocks.

items: list[CMC_ITEM_TYPES]

metadata

A property returning metadata associated with the message content, such as tokens, function call statuses, or any additional fields.

metadata: dict[str, Any]

name

A property returning the optional name assigned to the message content (e.g., function name or user label).

name: str | None

role

A property returning the role of this message content (e.g., "user", "assistant", or "system").

role: str | None