Dela via


AgentChannel Class

Defines the communication protocol for a particular Agent type.

An agent provides it own AgentChannel via CreateChannel.

Note: This class is marked as 'experimental' and may change in the future.

Constructor

AgentChannel()

Methods

get_history

Retrieve the message history specific to this channel.

invoke

Perform a discrete incremental interaction between a single Agent and AgentChat.

invoke_stream

Perform a discrete incremental stream interaction between a single Agent and AgentChat.

receive

Receive the conversation messages.

Used when joining a conversation and also during each agent interaction.

reset

Reset any persistent state associated with the channel.

get_history

Retrieve the message history specific to this channel.

abstract get_history() -> AsyncIterable[ChatMessageContent]

Returns

Type Description

An async iterable of ChatMessageContent.

invoke

Perform a discrete incremental interaction between a single Agent and AgentChat.

abstract invoke(agent: Agent, **kwargs: Any) -> AsyncIterable[tuple[bool, ChatMessageContent]]

Parameters

Name Description
agent
Required

The agent to interact with.

kwargs
Required

The keyword arguments.

Returns

Type Description

An async iterable of a bool, ChatMessageContent.

invoke_stream

Perform a discrete incremental stream interaction between a single Agent and AgentChat.

abstract invoke_stream(agent: Agent, messages: list[ChatMessageContent], **kwargs: Any) -> AsyncIterable[ChatMessageContent]

Parameters

Name Description
agent
Required

The agent to interact with.

messages
Required

The history of messages in the conversation.

kwargs
Required

The keyword arguments.

Returns

Type Description

An async iterable ChatMessageContent.

receive

Receive the conversation messages.

Used when joining a conversation and also during each agent interaction.

abstract async receive(history: list[ChatMessageContent]) -> None

Parameters

Name Description
history
Required

The history of messages in the conversation.

reset

Reset any persistent state associated with the channel.

abstract async reset() -> None

Attributes

is_experimental

is_experimental = True

stage_status

stage_status = 'experimental'