AgentThread Class 
Base class for agent threads. An agent thread manages the lifecycle and contextual state of a conversation from the perspective of one or more participating agents. This includes creating the thread, deleting it, and notifying it of new messages from any participant.
Constructor
AgentThread()Methods
| create | Starts the thread and returns the thread ID. Raises RuntimeError if the thread has previously been deleted. | 
| delete | Ends the current thread. No operation if the thread has already been deleted or never created. | 
| on_new_message | Invoked when a new message has been contributed to the chat by any participant. If the thread is not created yet, create() is called first. | 
| _create | (Abstract) Internal hook to start the thread and retrieve its ID from an external or underlying system. | 
| _delete | (Abstract) Internal hook to end the thread in an external or underlying system. | 
| _on_new_message | (Abstract) Internal hook invoked whenever a new message is submitted to the thread. | 
create
Starts the thread and returns the thread ID. Raises RuntimeError if the thread has previously been deleted.
async create() -> str | NoneReturns
| Type | Description | 
|---|---|
| The string thread ID if created successfully, otherwise None. | 
delete
Ends the current thread. No operation if the thread has already been deleted or never created.
async delete() -> Noneon_new_message
Invoked when a new message has been contributed to the chat by any participant. If the thread is not created yet, create() is called first.
async on_new_message(new_message: ChatMessageContent) -> NoneParameters
| Name | Description | 
|---|---|
| new_message 
				Required
			 | The new message content contributed by a participant. | 
_create
(Abstract) Internal hook to start the thread and retrieve its ID from an external or underlying system.
abstract async _create() -> str_delete
(Abstract) Internal hook to end the thread in an external or underlying system.
abstract async _delete() -> None_on_new_message
(Abstract) Internal hook invoked whenever a new message is submitted to the thread.
abstract async _on_new_message(new_message: ChatMessageContent) -> NoneAttributes
id
The ID of the current thread. Raises RuntimeError if accessed after the thread has been deleted.
id: str | None