> ## Documentation Index
> Fetch the complete documentation index at: https://docs.ag2.ai/llms.txt
> Use this file to discover all available pages before exploring further.

# autogen.agentchat.contrib.llamaindex_conversable_agent.LLamaIndexConversableAgent

<h2 id="autogen.agentchat.contrib.llamaindex_conversable_agent.LLamaIndexConversableAgent" class="doc doc-heading">
  <code class="doc-symbol doc-symbol-heading doc-symbol-class" />

  <span class="doc doc-object-name doc-class-name">LLamaIndexConversableAgent</span>
</h2>

```python theme={null}
LLamaIndexConversableAgent(
    name: str,
    llama_index_agent: AgentRunner,
    description: str | None = None,
    **kwargs: Any
)
```

(In preview) A class for generic conversable agents which can be configured as assistant or user proxy.<br />After receiving each message, the agent will send a reply to the sender unless the msg is a termination msg.<br />For example, AssistantAgent and UserProxyAgent are subclasses of this class,
configured with different default settings.<br />To modify auto reply, override `generate_reply` method.<br />To disable/enable human response in every turn, set `human_input_mode` to "NEVER" or "ALWAYS".<br />To modify the way to get human input, override `get_human_input` method.<br />To modify the way to execute code blocks, single code block, or function call, override `execute_code_blocks`,
`run_code`, and `execute_function` methods respectively.<br />

<b>Parameters:</b>

| Name                | Description                                        |
| ------------------- | -------------------------------------------------- |
| `name`              | **Type:** str                                      |
| `llama_index_agent` | **Type:** AgentRunner                              |
| `description`       | **Type:** str \| None<br /><br />**Default:** None |
| `**kwargs`          | **Type:** Any                                      |

### Class Attributes

<code class="doc-symbol doc-symbol-heading doc-symbol-attribute" />

#### DEFAULT\_CONFIG

<br />

<br />

<code class="doc-symbol doc-symbol-heading doc-symbol-attribute" />

#### DEFAULT\_SUMMARY\_METHOD

<br />

<br />

<code class="doc-symbol doc-symbol-heading doc-symbol-attribute" />

#### DEFAULT\_SUMMARY\_PROMPT

<br />

<br />

<code class="doc-symbol doc-symbol-heading doc-symbol-attribute" />

#### MAX\_CONSECUTIVE\_AUTO\_REPLY

<br />

<br />

### Instance Attributes

<code class="doc-symbol doc-symbol-heading doc-symbol-attribute" />

#### chat\_messages

<br />

A dictionary of conversations from agent to list of messages.

<code class="doc-symbol doc-symbol-heading doc-symbol-attribute" />

#### code\_executor

<br />

The code executor used by this agent. Returns None if code execution is disabled.

<code class="doc-symbol doc-symbol-heading doc-symbol-attribute" />

#### description

<br />

Get the description of the agent.

<code class="doc-symbol doc-symbol-heading doc-symbol-attribute" />

#### function\_map

<br />

Return the function map.

<code class="doc-symbol doc-symbol-heading doc-symbol-attribute" />

#### name

<br />

Get the name of the agent.

<code class="doc-symbol doc-symbol-heading doc-symbol-attribute" />

#### system\_message

<br />

Return the system message.

<code class="doc-symbol doc-symbol-heading doc-symbol-attribute" />

#### tools

<br />

Get the agent's tools (registered for LLM)

Note this is a copy of the tools list, use add\_tool and remove\_tool to modify the tools list.

<code class="doc-symbol doc-symbol-heading doc-symbol-attribute" />

#### use\_docker

<br />

Bool value of whether to use docker to execute the code,
or str value of the docker image name to use, or None when code execution is disabled.

### Instance Methods

<code class="doc-symbol doc-symbol-heading doc-symbol-method" />

#### a\_check\_termination\_and\_human\_reply

```python theme={null}
a_check_termination_and_human_reply(
    self,
    messages: list[dict[str, Any]] | None = None,
    sender: Agent | None = None,
    config: Any | None = None
) -> tuple[bool, str | None]
```

(async) Check if the conversation should be terminated, and if human reply is provided.<br />This method checks for conditions that require the conversation to be terminated, such as reaching
a maximum number of consecutive auto-replies or encountering a termination message. Additionally,
it prompts for and processes human input based on the configured human input mode, which can be
'ALWAYS', 'NEVER', or 'TERMINATE'. The method also manages the consecutive auto-reply counter
for the conversation and prints relevant messages based on the human input received.<br />

<b>Parameters:</b>

| Name       | Description                                                                                                                                                    |
| ---------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `messages` | A list of message dictionaries, representing the conversation history.<br /><br />**Type:** list\[dict\[str, typing.Any]] \| None<br /><br />**Default:** None |
| `sender`   | The agent object representing the sender of the message.<br /><br />**Type:** [Agent](/docs/api-reference/autogen/Agent) \| None<br /><br />**Default:** None  |
| `config`   | Configuration object, defaults to the current instance if not provided.<br /><br />**Type:** Any \| None<br /><br />**Default:** None                          |

<b>Returns:</b>

| Type                      | Description                                                                                                                                                                              |
| ------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| tuple\[bool, str \| None] | Tuple\[bool, Union\[str, Dict, None]]: A tuple containing a boolean indicating if the conversation should be terminated, and a human reply which can be a string, a dictionary, or None. |

<br />

<code class="doc-symbol doc-symbol-heading doc-symbol-method" />

#### a\_execute\_function

```python theme={null}
a_execute_function(
    self,
    func_call: dict[str, Any],
    call_id: str | None = None,
    verbose: bool = False
) -> tuple[bool, dict[str, Any]]
```

Execute an async function call and return the result.<br />Override this function to modify the way async functions and tools are executed.<br />

<b>Parameters:</b>

| Name        | Description                                                                                                                                                                                                                                                         |
| ----------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `func_call` | a dictionary extracted from openai message at key "function\_call" or "tool\_calls" with keys "name" and "arguments".<br /><br />**Type:** dict\[str, typing.Any]                                                                                                   |
| `call_id`   | a string to identify the tool call.<br /><br />**Type:** str \| None<br /><br />**Default:** None                                                                                                                                                                   |
| `verbose`   | Whether to send messages about the execution details to the output stream.<br /><br />When True, both the function call arguments and the execution result will be displayed.<br /><br />Defaults to False.<br /><br />**Type:** bool<br /><br />**Default:** False |

<b>Returns:</b>

| Type                                 | Description                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                             |
| ------------------------------------ | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| tuple\[bool, dict\[str, typing.Any]] | A tuple of (is\_exec\_success, result\_dict). is\_exec\_success (boolean): whether the execution is successful. result\_dict: a dictionary with keys "name", "role", and "content". Value of "role" is "function". "function\_call" deprecated as of [OpenAI API v1.1.0](https://github.com/openai/openai-python/releases/tag/v1.1.0) See [https://platform.openai.com/docs/api-reference/chat/create#chat-create-function\_call](https://platform.openai.com/docs/api-reference/chat/create#chat-create-function_call) |

<br />

<code class="doc-symbol doc-symbol-heading doc-symbol-method" />

#### a\_generate\_function\_call\_reply

```python theme={null}
a_generate_function_call_reply(
    self,
    messages: list[dict[str, Any]] | None = None,
    sender: Agent | None = None,
    config: Any | None = None
) -> tuple[bool, dict[str, Any] | None]
```

Generate a reply using async function call.<br />"function\_call" replaced by "tool\_calls" as of [OpenAI API v1.1.0](https://github.com/openai/openai-python/releases/tag/v1.1.0)
See [https://platform.openai.com/docs/api-reference/chat/create#chat-create-functions](https://platform.openai.com/docs/api-reference/chat/create#chat-create-functions)

<b>Parameters:</b>

| Name       | Description                                                                               |
| ---------- | ----------------------------------------------------------------------------------------- |
| `messages` | **Type:** list\[dict\[str, typing.Any]] \| None<br /><br />**Default:** None              |
| `sender`   | **Type:** [Agent](/docs/api-reference/autogen/Agent) \| None<br /><br />**Default:** None |
| `config`   | **Type:** Any \| None<br /><br />**Default:** None                                        |

<br />

<code class="doc-symbol doc-symbol-heading doc-symbol-method" />

#### a\_generate\_init\_message

```python theme={null}
a_generate_init_message(
    self,
    message: str | dict[str, Any] | None,
    **kwargs: Any
) -> dict[str, Any] | str
```

Generate the initial message for the agent.<br />If message is None, input() will be called to get the initial message.<br />

<b>Parameters:</b>

| Name       | Description                                                                                                                                                                                                                                                                                                                                                                                    |
| ---------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `message`  | the message to be processed.<br /><br />**Type:** str \| dict\[str, typing.Any] \| None                                                                                                                                                                                                                                                                                                        |
| `**kwargs` | any additional information.<br /><br />It has the following reserved fields: "carryover": a string or a list of string to specify the carryover information to be passed to this chat.<br /><br />It can be a string or a list of string.<br /><br />If provided, we will combine this carryover with the "message" content when generating the initial chat message.<br /><br />**Type:** Any |

<b>Returns:</b>

| Type                          | Description                         |
| ----------------------------- | ----------------------------------- |
| dict\[str, typing.Any] \| str | str or dict: the processed message. |

<br />

<code class="doc-symbol doc-symbol-heading doc-symbol-method" />

#### a\_generate\_oai\_reply

```python theme={null}
a_generate_oai_reply(
    self,
    messages: list[dict[str, Any]] | None = None,
    sender: Agent | None = None,
    config: Any | None = None
) -> tuple[bool, str | dict[str, Any] | None]
```

Generate a reply using autogen.oai asynchronously.

<b>Parameters:</b>

| Name       | Description                                                                               |
| ---------- | ----------------------------------------------------------------------------------------- |
| `messages` | **Type:** list\[dict\[str, typing.Any]] \| None<br /><br />**Default:** None              |
| `sender`   | **Type:** [Agent](/docs/api-reference/autogen/Agent) \| None<br /><br />**Default:** None |
| `config`   | **Type:** Any \| None<br /><br />**Default:** None                                        |

<br />

<code class="doc-symbol doc-symbol-heading doc-symbol-method" />

#### a\_generate\_reply

```python theme={null}
a_generate_reply(
    self,
    messages: list[dict[str, Any]] | None = None,
    sender: ForwardRef('Agent') | None = None,
    **kwargs: Any
) -> str | dict[str, Any] | None
```

(async) Reply based on the conversation history and the sender.<br />Either messages or sender must be provided.<br />Register a reply\_func with `None` as one trigger for it to be activated when `messages` is non-empty and `sender` is `None`.<br />Use registered auto reply functions to generate replies.<br />By default, the following functions are checked in order: <br />1. check\_termination\_and\_human\_reply
2\. generate\_function\_call\_reply
3\. generate\_tool\_calls\_reply
4\. generate\_code\_execution\_reply
5\. generate\_oai\_reply
Every function returns a tuple (final, reply).<br />When a function returns final=False, the next function will be checked.<br />So by default, termination and human reply will be checked first.<br />If not terminating and human reply is skipped, execute function or code and return the result.<br />AI replies are generated only when no code execution is performed.<br />

<b>Parameters:</b>

| Name       | Description                                                                                                                                                                                                                                                                                                           |
| ---------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `messages` | a list of messages in the conversation history.<br /><br />**Type:** list\[dict\[str, typing.Any]] \| None<br /><br />**Default:** None                                                                                                                                                                               |
| `sender`   | sender of an Agent instance.<br /><br />**Type:** ForwardRef('Agent') \| None<br /><br />**Default:** None                                                                                                                                                                                                            |
| `**kwargs` | Additional arguments to customize reply generation.<br /><br />Supported kwargs: - exclude (List\[Callable\[..., Any]]): A list of reply functions to exclude from the reply generation process.<br /><br />Functions in this list will be skipped even if they would normally be triggered.<br /><br />**Type:** Any |

<b>Returns:</b>

| Type                                  | Description                                                |
| ------------------------------------- | ---------------------------------------------------------- |
| str \| dict\[str, typing.Any] \| None | str or dict or None: reply. None if no reply is generated. |

<br />

<code class="doc-symbol doc-symbol-heading doc-symbol-method" />

#### a\_generate\_tool\_calls\_reply

```python theme={null}
a_generate_tool_calls_reply(
    self,
    messages: list[dict[str, Any]] | None = None,
    sender: Agent | None = None,
    config: Any | None = None
) -> tuple[bool, dict[str, Any] | None]
```

Generate a reply using async function call.

<b>Parameters:</b>

| Name       | Description                                                                               |
| ---------- | ----------------------------------------------------------------------------------------- |
| `messages` | **Type:** list\[dict\[str, typing.Any]] \| None<br /><br />**Default:** None              |
| `sender`   | **Type:** [Agent](/docs/api-reference/autogen/Agent) \| None<br /><br />**Default:** None |
| `config`   | **Type:** Any \| None<br /><br />**Default:** None                                        |

<br />

<code class="doc-symbol doc-symbol-heading doc-symbol-method" />

#### a\_get\_human\_input

```python theme={null}
a_get_human_input(self, prompt: str) -> str
```

(Async) Get human input.<br />Override this method to customize the way to get human input.<br />

<b>Parameters:</b>

| Name     | Description                                          |
| -------- | ---------------------------------------------------- |
| `prompt` | prompt for the human input.<br /><br />**Type:** str |

<b>Returns:</b>

| Type | Description       |
| ---- | ----------------- |
| str  | str: human input. |

<br />

<code class="doc-symbol doc-symbol-heading doc-symbol-method" />

#### a\_initiate\_chat

```python theme={null}
a_initiate_chat(
    self,
    recipient: ConversableAgent,
    clear_history: bool = True,
    silent: bool | None = False,
    cache: AbstractCache | None = None,
    max_turns: int | None = None,
    summary_method: str | Callable[..., Any] | None = 'last_msg',
    summary_args: dict[str, Any] | None = {},
    message: str | Callable[..., Any] | None = None,
    **kwargs: Any
) -> ChatResult
```

(async) Initiate a chat with the recipient agent.<br />Reset the consecutive auto reply counter.<br />If `clear_history` is True, the chat history with the recipient agent will be cleared.<br />`a_generate_init_message` is called to generate the initial message for the agent.<br />

<b>Parameters:</b>

| Name             | Description                                                                                                     |
| ---------------- | --------------------------------------------------------------------------------------------------------------- |
| `recipient`      | **Type:** ConversableAgent                                                                                      |
| `clear_history`  | **Type:** bool<br /><br />**Default:** True                                                                     |
| `silent`         | **Type:** bool \| None<br /><br />**Default:** False                                                            |
| `cache`          | **Type:** [AbstractCache](/docs/api-reference/autogen/cache/AbstractCache) \| None<br /><br />**Default:** None |
| `max_turns`      | **Type:** int \| None<br /><br />**Default:** None                                                              |
| `summary_method` | **Type:** str \| Callable\[..., Any] \| None<br /><br />**Default:** 'last\_msg'                                |
| `summary_args`   | **Type:** dict\[str, typing.Any] \| None<br /><br />**Default:** \{}                                            |
| `message`        | **Type:** str \| Callable\[..., Any] \| None<br /><br />**Default:** None                                       |
| `**kwargs`       | **Type:** Any                                                                                                   |

<b>Returns:</b>

| Type                                                 | Description                       |
| ---------------------------------------------------- | --------------------------------- |
| [ChatResult](/docs/api-reference/autogen/ChatResult) | ChatResult: an ChatResult object. |

<br />

<code class="doc-symbol doc-symbol-heading doc-symbol-method" />

#### a\_initiate\_chats

```python theme={null}
a_initiate_chats(self, chat_queue: list[dict[str, Any]]) -> dict[int, ChatResult]
```

<b>Parameters:</b>

| Name         | Description                             |
| ------------ | --------------------------------------- |
| `chat_queue` | **Type:** list\[dict\[str, typing.Any]] |

<br />

<code class="doc-symbol doc-symbol-heading doc-symbol-method" />

#### a\_receive

```python theme={null}
a_receive(
    self,
    message: dict[str, Any] | str,
    sender: Agent,
    request_reply: bool | None = None,
    silent: bool | None = False
) -> 
```

(async) Receive a message from another agent.<br />Once a message is received, this function sends a reply to the sender or stop.<br />The reply can be generated automatically or entered manually by a human.<br />

<b>Parameters:</b>

| Name            | Description                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                         |
| --------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `message`       | message from the sender.<br /><br />If the type is dict, it may contain the following reserved fields (either content or function\_call need to be provided).<br /><br />1. "content": content of the message, can be None.<br /><br />2. "function\_call": a dictionary containing the function name and arguments.<br /><br />(deprecated in favor of "tool\_calls") 3. "tool\_calls": a list of dictionaries containing the function name and arguments.<br /><br />4. "role": role of the message, can be "assistant", "user", "function".<br /><br />This field is only needed to distinguish between "function" or "assistant"/"user".<br /><br />5. "name": In most cases, this field is not needed.<br /><br />When the role is "function", this field is needed to indicate the function name.<br /><br />6. "context" (dict): the context of the message, which will be passed to [OpenAIWrapper.create](https://docs.ag2.ai/latest/docs/api-reference/autogen/OpenAIWrapper/#create).<br /><br />**Type:** dict\[str, typing.Any] \| str |
| `sender`        | sender of an Agent instance.<br /><br />**Type:** [Agent](/docs/api-reference/autogen/Agent)                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        |
| `request_reply` | whether a reply is requested from the sender.<br /><br />If None, the value is determined by `self.reply_at_receive[sender]`.<br /><br />**Type:** bool \| None<br /><br />**Default:** None                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        |
| `silent`        | (Experimental) whether to print the message received.<br /><br />**Type:** bool \| None<br /><br />**Default:** False                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                               |

<br />

<code class="doc-symbol doc-symbol-heading doc-symbol-method" />

#### a\_run

```python theme={null}
a_run(
    self,
    recipient: ForwardRef('ConversableAgent') | None = None,
    clear_history: bool = True,
    silent: bool | None = False,
    cache: AbstractCache | None = None,
    max_turns: int | None = None,
    summary_method: str | Callable[..., Any] | None = 'last_msg',
    summary_args: dict[str, Any] | None = {},
    message: dict[str, Any] | str | Callable[..., Any] | None = None,
    executor_kwargs: dict[str, Any] | None = None,
    tools: Tool | Iterable[Tool] | None = None,
    user_input: bool | None = False,
    msg_to: str | None = 'agent',
    **kwargs: Any
) -> AsyncRunResponseProtocol
```

<b>Parameters:</b>

| Name              | Description                                                                                                                                                |
| ----------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `recipient`       | **Type:** ForwardRef('ConversableAgent') \| None<br /><br />**Default:** None                                                                              |
| `clear_history`   | **Type:** bool<br /><br />**Default:** True                                                                                                                |
| `silent`          | **Type:** bool \| None<br /><br />**Default:** False                                                                                                       |
| `cache`           | **Type:** [AbstractCache](/docs/api-reference/autogen/cache/AbstractCache) \| None<br /><br />**Default:** None                                            |
| `max_turns`       | **Type:** int \| None<br /><br />**Default:** None                                                                                                         |
| `summary_method`  | **Type:** str \| Callable\[..., Any] \| None<br /><br />**Default:** 'last\_msg'                                                                           |
| `summary_args`    | **Type:** dict\[str, typing.Any] \| None<br /><br />**Default:** \{}                                                                                       |
| `message`         | **Type:** dict\[str, typing.Any] \| str \| Callable\[..., Any] \| None<br /><br />**Default:** None                                                        |
| `executor_kwargs` | **Type:** dict\[str, typing.Any] \| None<br /><br />**Default:** None                                                                                      |
| `tools`           | **Type:** [Tool](/docs/api-reference/autogen/tools/Tool) \| Iterable\[[Tool](/docs/api-reference/autogen/tools/Tool)] \| None<br /><br />**Default:** None |
| `user_input`      | **Type:** bool \| None<br /><br />**Default:** False                                                                                                       |
| `msg_to`          | **Type:** str \| None<br /><br />**Default:** 'agent'                                                                                                      |
| `**kwargs`        | **Type:** Any                                                                                                                                              |

<br />

<code class="doc-symbol doc-symbol-heading doc-symbol-method" />

#### a\_send

```python theme={null}
a_send(
    self,
    message: dict[str, Any] | str,
    recipient: Agent,
    request_reply: bool | None = None,
    silent: bool | None = False
) -> 
```

(async) Send a message to another agent.<br />

<b>Parameters:</b>

| Name            | Description                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                  |
| --------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `message`       | message to be sent.<br /><br />The message could contain the following fields: - content (str or List): Required, the content of the message.<br /><br />(Can be None) - function\_call (str): the name of the function to be called.<br /><br />- name (str): the name of the function to be called.<br /><br />- role (str): the role of the message, any role that is not "function" will be modified to "assistant".<br /><br />- context (dict): the context of the message, which will be passed to [OpenAIWrapper.create](https://docs.ag2.ai/latest/docs/api-reference/autogen/OpenAIWrapper/#create).<br /><br />For example, one agent can send a message A as:<br /><br />**Type:** dict\[str, typing.Any] \| str |
| `recipient`     | the recipient of the message.<br /><br />**Type:** [Agent](/docs/api-reference/autogen/Agent)                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                |
| `request_reply` | whether to request a reply from the recipient.<br /><br />**Type:** bool \| None<br /><br />**Default:** None                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                |
| `silent`        | (Experimental) whether to print the message sent.<br /><br />**Type:** bool \| None<br /><br />**Default:** False                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                            |

<br />

<code class="doc-symbol doc-symbol-heading doc-symbol-method" />

#### a\_sequential\_run

```python theme={null}
a_sequential_run(self, chat_queue: list[dict[str, Any]]) -> list[AsyncRunResponseProtocol]
```

(Experimental) Initiate chats with multiple agents sequentially.<br />

<b>Parameters:</b>

| Name         | Description                                                                                                                                                                                                            |
| ------------ | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `chat_queue` | a list of dictionaries containing the information of the chats.<br /><br />Each dictionary should contain the input arguments for [`initiate_chat`](#initiate-chat)<br /><br />**Type:** list\[dict\[str, typing.Any]] |

<b>Returns:</b>

| Type                                                                                                    | Description                                                                          |
| ------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------ |
| list\[[AsyncRunResponseProtocol](/docs/api-reference/autogen/io/run_response/AsyncRunResponseProtocol)] | a list of ChatResult objects corresponding to the finished chats in the chat\_queue. |

<br />

<code class="doc-symbol doc-symbol-heading doc-symbol-method" />

#### can\_execute\_function

```python theme={null}
can_execute_function(self, name: list[str] | str) -> bool
```

Whether the agent can execute the function.

<b>Parameters:</b>

| Name   | Description                 |
| ------ | --------------------------- |
| `name` | **Type:** list\[str] \| str |

<br />

<code class="doc-symbol doc-symbol-heading doc-symbol-method" />

#### chat\_messages\_for\_summary

```python theme={null}
chat_messages_for_summary(self, agent: Agent) -> list[dict[str, Any]]
```

A list of messages as a conversation to summarize.

<b>Parameters:</b>

| Name    | Description                                          |
| ------- | ---------------------------------------------------- |
| `agent` | **Type:** [Agent](/docs/api-reference/autogen/Agent) |

<br />

<code class="doc-symbol doc-symbol-heading doc-symbol-method" />

#### check\_termination\_and\_human\_reply

```python theme={null}
check_termination_and_human_reply(
    self,
    messages: list[dict[str, Any]] | None = None,
    sender: Agent | None = None,
    config: Any | None = None
) -> tuple[bool, str | None]
```

Check if the conversation should be terminated, and if human reply is provided.<br />This method checks for conditions that require the conversation to be terminated, such as reaching
a maximum number of consecutive auto-replies or encountering a termination message. Additionally,
it prompts for and processes human input based on the configured human input mode, which can be
'ALWAYS', 'NEVER', or 'TERMINATE'. The method also manages the consecutive auto-reply counter
for the conversation and prints relevant messages based on the human input received.<br />

<b>Parameters:</b>

| Name       | Description                                                                                                                                                    |
| ---------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `messages` | A list of message dictionaries, representing the conversation history.<br /><br />**Type:** list\[dict\[str, typing.Any]] \| None<br /><br />**Default:** None |
| `sender`   | The agent object representing the sender of the message.<br /><br />**Type:** [Agent](/docs/api-reference/autogen/Agent) \| None<br /><br />**Default:** None  |
| `config`   | Configuration object, defaults to the current instance if not provided.<br /><br />**Type:** Any \| None<br /><br />**Default:** None                          |

<b>Returns:</b>

| Type                      | Description                                                                                                                                       |
| ------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------- |
| tuple\[bool, str \| None] | A tuple containing a boolean indicating if the conversation should be terminated, and a human reply which can be a string, a dictionary, or None. |

<br />

<code class="doc-symbol doc-symbol-heading doc-symbol-method" />

#### clear\_history

```python theme={null}
clear_history(
    self,
    recipient: Agent | None = None,
    nr_messages_to_preserve: int | None = None
) -> 
```

Clear the chat history of the agent.<br />

<b>Parameters:</b>

| Name                      | Description                                                                                                                                                                                                     |
| ------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `recipient`               | the agent with whom the chat history to clear.<br /><br />If None, clear the chat history with all agents.<br /><br />**Type:** [Agent](/docs/api-reference/autogen/Agent) \| None<br /><br />**Default:** None |
| `nr_messages_to_preserve` | the number of newest messages to preserve in the chat history.<br /><br />**Type:** int \| None<br /><br />**Default:** None                                                                                    |

<br />

<code class="doc-symbol doc-symbol-heading doc-symbol-method" />

#### execute\_code\_blocks

```python theme={null}
execute_code_blocks(self, code_blocks) -> 
```

Execute the code blocks and return the result.

<b>Parameters:</b>

| Name          | Description |
| ------------- | ----------- |
| `code_blocks` |             |

<br />

<code class="doc-symbol doc-symbol-heading doc-symbol-method" />

#### execute\_function

```python theme={null}
execute_function(
    self,
    func_call: dict[str, Any],
    call_id: str | None = None,
    verbose: bool = False
) -> tuple[bool, dict[str, Any]]
```

Execute a function call and return the result.<br />Override this function to modify the way to execute function and tool calls.<br />

<b>Parameters:</b>

| Name        | Description                                                                                                                                                                                                                                                         |
| ----------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `func_call` | a dictionary extracted from openai message at "function\_call" or "tool\_calls" with keys "name" and "arguments".<br /><br />**Type:** dict\[str, typing.Any]                                                                                                       |
| `call_id`   | a string to identify the tool call.<br /><br />**Type:** str \| None<br /><br />**Default:** None                                                                                                                                                                   |
| `verbose`   | Whether to send messages about the execution details to the output stream.<br /><br />When True, both the function call arguments and the execution result will be displayed.<br /><br />Defaults to False.<br /><br />**Type:** bool<br /><br />**Default:** False |

<b>Returns:</b>

| Type                                 | Description                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                             |
| ------------------------------------ | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| tuple\[bool, dict\[str, typing.Any]] | A tuple of (is\_exec\_success, result\_dict). is\_exec\_success (boolean): whether the execution is successful. result\_dict: a dictionary with keys "name", "role", and "content". Value of "role" is "function". "function\_call" deprecated as of [OpenAI API v1.1.0](https://github.com/openai/openai-python/releases/tag/v1.1.0) See [https://platform.openai.com/docs/api-reference/chat/create#chat-create-function\_call](https://platform.openai.com/docs/api-reference/chat/create#chat-create-function_call) |

<br />

<code class="doc-symbol doc-symbol-heading doc-symbol-method" />

#### generate\_code\_execution\_reply

```python theme={null}
generate_code_execution_reply(
    self,
    messages: list[dict[str, Any]] | None = None,
    sender: Agent | None = None,
    config: dict[str, Any] | Literal[False] | None = None
) -> 
```

Generate a reply using code execution.

<b>Parameters:</b>

| Name       | Description                                                                               |
| ---------- | ----------------------------------------------------------------------------------------- |
| `messages` | **Type:** list\[dict\[str, typing.Any]] \| None<br /><br />**Default:** None              |
| `sender`   | **Type:** [Agent](/docs/api-reference/autogen/Agent) \| None<br /><br />**Default:** None |
| `config`   | **Type:** dict\[str, typing.Any] \| Literal\[False] \| None<br /><br />**Default:** None  |

<br />

<code class="doc-symbol doc-symbol-heading doc-symbol-method" />

#### generate\_function\_call\_reply

```python theme={null}
generate_function_call_reply(
    self,
    messages: list[dict[str, Any]] | None = None,
    sender: Agent | None = None,
    config: Any | None = None
) -> tuple[bool, dict[str, Any] | None]
```

Generate a reply using function call.<br />"function\_call" replaced by "tool\_calls" as of [OpenAI API v1.1.0](https://github.com/openai/openai-python/releases/tag/v1.1.0)
See [https://platform.openai.com/docs/api-reference/chat/create#chat-create-functions](https://platform.openai.com/docs/api-reference/chat/create#chat-create-functions)

<b>Parameters:</b>

| Name       | Description                                                                               |
| ---------- | ----------------------------------------------------------------------------------------- |
| `messages` | **Type:** list\[dict\[str, typing.Any]] \| None<br /><br />**Default:** None              |
| `sender`   | **Type:** [Agent](/docs/api-reference/autogen/Agent) \| None<br /><br />**Default:** None |
| `config`   | **Type:** Any \| None<br /><br />**Default:** None                                        |

<br />

<code class="doc-symbol doc-symbol-heading doc-symbol-method" />

#### generate\_init\_message

```python theme={null}
generate_init_message(
    self,
    message: str | dict[str, Any] | None,
    **kwargs: Any
) -> dict[str, Any] | str
```

Generate the initial message for the agent.<br />If message is None, input() will be called to get the initial message.<br />

<b>Parameters:</b>

| Name       | Description                                                                                                                                                                                                                                                                                                                                                                                    |
| ---------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `message`  | the message to be processed.<br /><br />**Type:** str \| dict\[str, typing.Any] \| None                                                                                                                                                                                                                                                                                                        |
| `**kwargs` | any additional information.<br /><br />It has the following reserved fields: "carryover": a string or a list of string to specify the carryover information to be passed to this chat.<br /><br />It can be a string or a list of string.<br /><br />If provided, we will combine this carryover with the "message" content when generating the initial chat message.<br /><br />**Type:** Any |

<b>Returns:</b>

| Type                          | Description                         |
| ----------------------------- | ----------------------------------- |
| dict\[str, typing.Any] \| str | str or dict: the processed message. |

<br />

<code class="doc-symbol doc-symbol-heading doc-symbol-method" />

#### generate\_oai\_reply

```python theme={null}
generate_oai_reply(
    self,
    messages: list[dict[str, Any]] | None = None,
    sender: Agent | None = None,
    config: OpenAIWrapper | None = None
) -> tuple[bool, str | dict[str, Any] | None]
```

Generate a reply using autogen.oai.

<b>Parameters:</b>

| Name       | Description                                                                                               |
| ---------- | --------------------------------------------------------------------------------------------------------- |
| `messages` | **Type:** list\[dict\[str, typing.Any]] \| None<br /><br />**Default:** None                              |
| `sender`   | **Type:** [Agent](/docs/api-reference/autogen/Agent) \| None<br /><br />**Default:** None                 |
| `config`   | **Type:** [OpenAIWrapper](/docs/api-reference/autogen/OpenAIWrapper) \| None<br /><br />**Default:** None |

<br />

<code class="doc-symbol doc-symbol-heading doc-symbol-method" />

#### generate\_reply

```python theme={null}
generate_reply(
    self,
    messages: list[dict[str, Any]] | None = None,
    sender: ForwardRef('Agent') | None = None,
    **kwargs: Any
) -> str | dict[str, Any] | None
```

Reply based on the conversation history and the sender.<br />Either messages or sender must be provided.<br />Register a reply\_func with `None` as one trigger for it to be activated when `messages` is non-empty and `sender` is `None`.<br />Use registered auto reply functions to generate replies.<br />By default, the following functions are checked in order: <br />1. check\_termination\_and\_human\_reply
2\. generate\_function\_call\_reply (deprecated in favor of tool\_calls)
3\. generate\_tool\_calls\_reply
4\. generate\_code\_execution\_reply
5\. generate\_oai\_reply
Every function returns a tuple (final, reply).<br />When a function returns final=False, the next function will be checked.<br />So by default, termination and human reply will be checked first.<br />If not terminating and human reply is skipped, execute function or code and return the result.<br />AI replies are generated only when no code execution is performed.<br />

<b>Parameters:</b>

| Name       | Description                                                                                                                                                                                                                                                                                                           |
| ---------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `messages` | a list of messages in the conversation history.<br /><br />**Type:** list\[dict\[str, typing.Any]] \| None<br /><br />**Default:** None                                                                                                                                                                               |
| `sender`   | sender of an Agent instance.<br /><br />**Type:** ForwardRef('Agent') \| None<br /><br />**Default:** None                                                                                                                                                                                                            |
| `**kwargs` | Additional arguments to customize reply generation.<br /><br />Supported kwargs: - exclude (List\[Callable\[..., Any]]): A list of reply functions to exclude from the reply generation process.<br /><br />Functions in this list will be skipped even if they would normally be triggered.<br /><br />**Type:** Any |

<b>Returns:</b>

| Type                                  | Description                                                |
| ------------------------------------- | ---------------------------------------------------------- |
| str \| dict\[str, typing.Any] \| None | str or dict or None: reply. None if no reply is generated. |

<br />

<code class="doc-symbol doc-symbol-heading doc-symbol-method" />

#### generate\_tool\_calls\_reply

```python theme={null}
generate_tool_calls_reply(
    self,
    messages: list[dict[str, Any]] | None = None,
    sender: Agent | None = None,
    config: Any | None = None
) -> tuple[bool, dict[str, Any] | None]
```

Generate a reply using tool call.

<b>Parameters:</b>

| Name       | Description                                                                               |
| ---------- | ----------------------------------------------------------------------------------------- |
| `messages` | **Type:** list\[dict\[str, typing.Any]] \| None<br /><br />**Default:** None              |
| `sender`   | **Type:** [Agent](/docs/api-reference/autogen/Agent) \| None<br /><br />**Default:** None |
| `config`   | **Type:** Any \| None<br /><br />**Default:** None                                        |

<br />

<code class="doc-symbol doc-symbol-heading doc-symbol-method" />

#### get\_actual\_usage

```python theme={null}
get_actual_usage(self) -> dict[str, int] | None
```

Get the actual usage summary.

<br />

<code class="doc-symbol doc-symbol-heading doc-symbol-method" />

#### get\_chat\_results

```python theme={null}
get_chat_results(self, chat_index: int | None = None) -> list[ChatResult] | ChatResult
```

A summary from the finished chats of particular agents.

<b>Parameters:</b>

| Name         | Description                                        |
| ------------ | -------------------------------------------------- |
| `chat_index` | **Type:** int \| None<br /><br />**Default:** None |

<br />

<code class="doc-symbol doc-symbol-heading doc-symbol-method" />

#### get\_human\_input

```python theme={null}
get_human_input(self, prompt: str) -> str
```

Get human input.<br />Override this method to customize the way to get human input.<br />

<b>Parameters:</b>

| Name     | Description                                          |
| -------- | ---------------------------------------------------- |
| `prompt` | prompt for the human input.<br /><br />**Type:** str |

<b>Returns:</b>

| Type | Description       |
| ---- | ----------------- |
| str  | str: human input. |

<br />

<code class="doc-symbol doc-symbol-heading doc-symbol-method" />

#### get\_total\_usage

```python theme={null}
get_total_usage(self) -> dict[str, int] | None
```

Get the total usage summary.

<br />

<code class="doc-symbol doc-symbol-heading doc-symbol-method" />

#### initiate\_chat

```python theme={null}
initiate_chat(
    self,
    recipient: ConversableAgent,
    clear_history: bool = True,
    silent: bool | None = False,
    cache: AbstractCache | None = None,
    max_turns: int | None = None,
    summary_method: str | Callable[..., Any] | None = 'last_msg',
    summary_args: dict[str, Any] | None = {},
    message: dict[str, Any] | str | Callable[..., Any] | None = None,
    **kwargs: Any
) -> ChatResult
```

Initiate a chat with the recipient agent.<br />Reset the consecutive auto reply counter.<br />If `clear_history` is True, the chat history with the recipient agent will be cleared.<br />

<b>Parameters:</b>

| Name             | Description                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                      |
| ---------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
| `recipient`      | the recipient agent.<br /><br />**Type:** ConversableAgent                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                       |
| `clear_history`  | whether to clear the chat history with the agent.<br /><br />Default is True.<br /><br />**Type:** bool<br /><br />**Default:** True                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                             |
| `silent`         | (Experimental) whether to print the messages for this conversation.<br /><br />Default is False.<br /><br />**Type:** bool \| None<br /><br />**Default:** False                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                 |
| `cache`          | the cache client to be used for this conversation.<br /><br />Default is None.<br /><br />**Type:** [AbstractCache](/docs/api-reference/autogen/cache/AbstractCache) \| None<br /><br />**Default:** None                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        |
| `max_turns`      | the maximum number of turns for the chat between the two agents.<br /><br />One turn means one conversation round trip.<br /><br />Note that this is different from `max_consecutive_auto_reply` which is the maximum number of consecutive auto replies; and it is also different from `max_rounds` in GroupChat which is the maximum number of rounds in a group chat session.<br /><br />If max\_turns is set to None, the chat will continue until a termination condition is met.<br /><br />Default is None.<br /><br />**Type:** int \| None<br /><br />**Default:** None                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                 |
| `summary_method` | a method to get a summary from the chat.<br /><br />Default is DEFAULT\_SUMMARY\_METHOD, i.e., "last\_msg".<br /><br />Supported strings are "last\_msg" and "reflection\_with\_llm": - when set to "last\_msg", it returns the last message of the dialog as the summary.<br /><br />- when set to "reflection\_with\_llm", it returns a summary extracted using an llm client.<br /><br />`llm_config` must be set in either the recipient or sender.<br /><br />A callable summary\_method should take the recipient and sender agent in a chat as input and return a string of summary.<br /><br />E.g., `def my_summary_method( sender: ConversableAgent, recipient: ConversableAgent, summary_args: dict, ): return recipient.last_message(sender)["content"] `<br /><br />**Type:** str \| Callable\[..., Any] \| None<br /><br />**Default:** 'last\_msg'                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                |
| `summary_args`   | a dictionary of arguments to be passed to the summary\_method.<br /><br />One example key is "summary\_prompt", and value is a string of text used to prompt a LLM-based agent (the sender or recipient agent) to reflect on the conversation and extract a summary when summary\_method is "reflection\_with\_llm".<br /><br />The default summary\_prompt is DEFAULT\_SUMMARY\_PROMPT, i.e., "Summarize takeaway from the conversation.<br /><br />Do not add any introductory phrases.<br /><br />If the intended request is NOT properly addressed, please point it out." Another available key is "summary\_role", which is the role of the message sent to the agent in charge of summarizing.<br /><br />Default is "system".<br /><br />**Type:** dict\[str, typing.Any] \| None<br /><br />**Default:** \{}                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                             |
| `message`        | the initial message to be sent to the recipient.<br /><br />Needs to be provided.<br /><br />Otherwise, input() will be called to get the initial message.<br /><br />- If a string or a dict is provided, it will be used as the initial message.<br /><br />`generate_init_message` is called to generate the initial message for the agent based on this string and the context.<br /><br />If dict, it may contain the following reserved fields (either content or tool\_calls need to be provided).<br /><br />1. "content": content of the message, can be None.<br /><br />2. "function\_call": a dictionary containing the function name and arguments.<br /><br />(deprecated in favor of "tool\_calls") 3. "tool\_calls": a list of dictionaries containing the function name and arguments.<br /><br />4. "role": role of the message, can be "assistant", "user", "function".<br /><br />This field is only needed to distinguish between "function" or "assistant"/"user".<br /><br />5. "name": In most cases, this field is not needed.<br /><br />When the role is "function", this field is needed to indicate the function name.<br /><br />6. "context" (dict): the context of the message, which will be passed to `OpenAIWrapper.create`.<br /><br />- If a callable is provided, it will be called to get the initial message in the form of a string or a dict.<br /><br />If the returned type is dict, it may contain the reserved fields mentioned above.<br /><br />Example of a callable message (returning a string): `def my_message( sender: ConversableAgent, recipient: ConversableAgent, context: dict ) -> Union[str, Dict]: carryover = context.get("carryover", "") if isinstance(message, list): carryover = carryover[-1] final_msg = "Write a blogpost." + "\nContext: \n" + carryover return final_msg ` Example of a callable message (returning a dict): `def my_message( sender: ConversableAgent, recipient: ConversableAgent, context: dict ) -> Union[str, Dict]: final_msg = \{} carryover = context.get("carryover", "") if isinstance(message, list): carryover = carryover[-1] final_msg["content"] = "Write a blogpost." + "\nContext: \n" + carryover final_msg["context"] = \{"prefix": "Today I feel"} return final_msg `<br /><br />**Type:** dict\[str, typing.Any] \| str \| Callable\[..., Any] \| None<br /><br />**Default:** None |
| `**kwargs`       | any additional information.<br /><br />It has the following reserved fields: - "carryover": a string or a list of string to specify the carryover information to be passed to this chat.<br /><br />If provided, we will combine this carryover (by attaching a "context: " string and the carryover content after the message content) with the "message" content when generating the initial chat message in `generate_init_message`.<br /><br />- "verbose": a boolean to specify whether to print the message and carryover in a chat.<br /><br />Default is False.<br /><br />**Type:** Any                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                 |

<b>Returns:</b>

| Type                                                 | Description                       |
| ---------------------------------------------------- | --------------------------------- |
| [ChatResult](/docs/api-reference/autogen/ChatResult) | ChatResult: an ChatResult object. |

<br />

<code class="doc-symbol doc-symbol-heading doc-symbol-method" />

#### initiate\_chats

```python theme={null}
initiate_chats(self, chat_queue: list[dict[str, Any]]) -> list[ChatResult]
```

(Experimental) Initiate chats with multiple agents.<br />

<b>Parameters:</b>

| Name         | Description                                                                                                                                                                                                            |
| ------------ | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `chat_queue` | a list of dictionaries containing the information of the chats.<br /><br />Each dictionary should contain the input arguments for [`initiate_chat`](#initiate-chat)<br /><br />**Type:** list\[dict\[str, typing.Any]] |

<b>Returns:</b>

| Type                                                        | Description                                                                          |
| ----------------------------------------------------------- | ------------------------------------------------------------------------------------ |
| list\[[ChatResult](/docs/api-reference/autogen/ChatResult)] | a list of ChatResult objects corresponding to the finished chats in the chat\_queue. |

<br />

<code class="doc-symbol doc-symbol-heading doc-symbol-method" />

#### last\_message

```python theme={null}
last_message(self, agent: Agent | None = None) -> dict[str, Any] | None
```

The last message exchanged with the agent.<br />

<b>Parameters:</b>

| Name    | Description                                                                                                                                                                                                                                                                                                                                           |
| ------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `agent` | The agent in the conversation.<br /><br />If None and more than one agent's conversations are found, an error will be raised.<br /><br />If None and only one conversation is found, the last message of the only conversation will be returned.<br /><br />**Type:** [Agent](/docs/api-reference/autogen/Agent) \| None<br /><br />**Default:** None |

<b>Returns:</b>

| Type                           | Description                                |
| ------------------------------ | ------------------------------------------ |
| dict\[str, typing.Any] \| None | The last message exchanged with the agent. |

<br />

<code class="doc-symbol doc-symbol-heading doc-symbol-method" />

#### max\_consecutive\_auto\_reply

```python theme={null}
max_consecutive_auto_reply(self, sender: Agent | None = None) -> int
```

The maximum number of consecutive auto replies.

<b>Parameters:</b>

| Name     | Description                                                                               |
| -------- | ----------------------------------------------------------------------------------------- |
| `sender` | **Type:** [Agent](/docs/api-reference/autogen/Agent) \| None<br /><br />**Default:** None |

<br />

<code class="doc-symbol doc-symbol-heading doc-symbol-method" />

#### print\_usage\_summary

```python theme={null}
print_usage_summary(self, mode: list[str] | str = ['actual', 'total']) -> None
```

Print the usage summary.

<b>Parameters:</b>

| Name   | Description                                                              |
| ------ | ------------------------------------------------------------------------ |
| `mode` | **Type:** list\[str] \| str<br /><br />**Default:** \['actual', 'total'] |

<br />

<code class="doc-symbol doc-symbol-heading doc-symbol-method" />

#### process\_all\_messages\_before\_reply

```python theme={null}
process_all_messages_before_reply(self, messages: list[dict[str, Any]]) -> list[dict[str, Any]]
```

Calls any registered capability hooks to process all messages, potentially modifying the messages.

<b>Parameters:</b>

| Name       | Description                             |
| ---------- | --------------------------------------- |
| `messages` | **Type:** list\[dict\[str, typing.Any]] |

<br />

<code class="doc-symbol doc-symbol-heading doc-symbol-method" />

#### process\_last\_received\_message

```python theme={null}
process_last_received_message(self, messages: list[dict[str, Any]]) -> list[dict[str, Any]]
```

Calls any registered capability hooks to use and potentially modify the text of the last message,
as long as the last message is not a function call or exit command.

<b>Parameters:</b>

| Name       | Description                             |
| ---------- | --------------------------------------- |
| `messages` | **Type:** list\[dict\[str, typing.Any]] |

<br />

<code class="doc-symbol doc-symbol-heading doc-symbol-method" />

#### receive

```python theme={null}
receive(
    self,
    message: dict[str, Any] | str,
    sender: Agent,
    request_reply: bool | None = None,
    silent: bool | None = False
) -> 
```

Receive a message from another agent.<br />Once a message is received, this function sends a reply to the sender or stop.<br />The reply can be generated automatically or entered manually by a human.<br />

<b>Parameters:</b>

| Name            | Description                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                 |
| --------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `message`       | message from the sender.<br /><br />If the type is dict, it may contain the following reserved fields (either content or function\_call need to be provided).<br /><br />1. "content": content of the message, can be None.<br /><br />2. "function\_call": a dictionary containing the function name and arguments.<br /><br />(deprecated in favor of "tool\_calls") 3. "tool\_calls": a list of dictionaries containing the function name and arguments.<br /><br />4. "role": role of the message, can be "assistant", "user", "function", "tool".<br /><br />This field is only needed to distinguish between "function" or "assistant"/"user".<br /><br />5. "name": In most cases, this field is not needed.<br /><br />When the role is "function", this field is needed to indicate the function name.<br /><br />6. "context" (dict): the context of the message, which will be passed to [OpenAIWrapper.create](https://docs.ag2.ai/latest/docs/api-reference/autogen/OpenAIWrapper/#create).<br /><br />**Type:** dict\[str, typing.Any] \| str |
| `sender`        | sender of an Agent instance.<br /><br />**Type:** [Agent](/docs/api-reference/autogen/Agent)                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                |
| `request_reply` | whether a reply is requested from the sender.<br /><br />If None, the value is determined by `self.reply_at_receive[sender]`.<br /><br />**Type:** bool \| None<br /><br />**Default:** None                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                |
| `silent`        | (Experimental) whether to print the message received.<br /><br />**Type:** bool \| None<br /><br />**Default:** False                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                       |

<br />

<code class="doc-symbol doc-symbol-heading doc-symbol-method" />

#### register\_for\_execution

```python theme={null}
register_for_execution(
    self,
    name: str | None = None,
    description: str | None = None,
    *,
    serialize: bool = True,
    silent_override: bool = False
) -> Callable[[~F | Tool], Tool]
```

Decorator factory for registering a function to be executed by an agent.<br />It's return value is used to decorate a function to be registered to the agent.<br />

<b>Parameters:</b>

| Name              | Description                                                                                                                                             |
| ----------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `name`            | name of the function.<br /><br />If None, the function name will be used (default: None).<br /><br />**Type:** str \| None<br /><br />**Default:** None |
| `description`     | description of the function (default: None).<br /><br />**Type:** str \| None<br /><br />**Default:** None                                              |
| `serialize`       | whether to serialize the return value<br /><br />**Type:** bool<br /><br />**Default:** True                                                            |
| `silent_override` | whether to suppress any override warning messages<br /><br />**Type:** bool<br /><br />**Default:** False                                               |

<b>Returns:</b>

| Type                                                                                                                | Description                                                      |
| ------------------------------------------------------------------------------------------------------------------- | ---------------------------------------------------------------- |
| Callable\[\[\~F \| [Tool](/docs/api-reference/autogen/tools/Tool)], [Tool](/docs/api-reference/autogen/tools/Tool)] | The decorator for registering a function to be used by an agent. |

<br />

<code class="doc-symbol doc-symbol-heading doc-symbol-method" />

#### register\_for\_llm

```python theme={null}
register_for_llm(
    self,
    *,
    name: str | None = None,
    description: str | None = None,
    api_style: Literal['function', 'tool'] = 'tool',
    silent_override: bool = False
) -> Callable[[~F | Tool], Tool]
```

Decorator factory for registering a function to be used by an agent.<br />It's return value is used to decorate a function to be registered to the agent. The function uses type hints to
specify the arguments and return type. The function name is used as the default name for the function,
but a custom name can be provided. The function description is used to describe the function in the
agent's configuration.<br />

<b>Parameters:</b>

| Name              | Description                                                                                                                                                                                                                                                                                                                                                                                                                                                                                 |
| ----------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `name`            | name of the function.<br /><br />If None, the function name will be used (default: None).<br /><br />**Type:** str \| None<br /><br />**Default:** None                                                                                                                                                                                                                                                                                                                                     |
| `description`     | description of the function (default: None).<br /><br />It is mandatory for the initial decorator, but the following ones can omit it.<br /><br />**Type:** str \| None<br /><br />**Default:** None                                                                                                                                                                                                                                                                                        |
| `api_style`       | (literal): the API style for function call.<br /><br />For Azure OpenAI API, use version 2023-12-01-preview or later.<br /><br />`"function"` style will be deprecated.<br /><br />For earlier version use `"function"` if `"tool"` doesn't work.<br /><br />See [Azure OpenAI documentation](https://learn.microsoft.com/en-us/azure/ai-services/openai/how-to/function-calling?tabs=python) for details.<br /><br />**Type:** Literal\['function', 'tool']<br /><br />**Default:** 'tool' |
| `silent_override` | whether to suppress any override warning messages.<br /><br />**Type:** bool<br /><br />**Default:** False                                                                                                                                                                                                                                                                                                                                                                                  |

<b>Returns:</b>

| Type                                                                                                                | Description                                                      |
| ------------------------------------------------------------------------------------------------------------------- | ---------------------------------------------------------------- |
| Callable\[\[\~F \| [Tool](/docs/api-reference/autogen/tools/Tool)], [Tool](/docs/api-reference/autogen/tools/Tool)] | The decorator for registering a function to be used by an agent. |

<br />

<code class="doc-symbol doc-symbol-heading doc-symbol-method" />

#### register\_function

```python theme={null}
register_function(
    self,
    function_map: dict[str, Callable[..., Any]],
    silent_override: bool = False
) -> 
```

Register functions to the agent.<br />

<b>Parameters:</b>

| Name              | Description                                                                                                                                                                                                           |
| ----------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `function_map`    | a dictionary mapping function names to functions.<br /><br />if function\_map\[name] is None, the function will be removed from the function\_map.<br /><br />**Type:** dict\[str, typing.Callable\[..., typing.Any]] |
| `silent_override` | whether to print warnings when overriding functions.<br /><br />**Type:** bool<br /><br />**Default:** False                                                                                                          |

<br />

<code class="doc-symbol doc-symbol-heading doc-symbol-method" />

#### register\_handoff

```python theme={null}
register_handoff(self, condition: ForwardRef('OnContextCondition') | ForwardRef('OnCondition')) -> 
```

Register a single handoff condition (OnContextCondition or OnCondition).<br />

<b>Parameters:</b>

| Name        | Description                                                                                                                               |
| ----------- | ----------------------------------------------------------------------------------------------------------------------------------------- |
| `condition` | The condition to add (OnContextCondition, OnCondition)<br /><br />**Type:** ForwardRef('OnContextCondition') \| ForwardRef('OnCondition') |

<br />

<code class="doc-symbol doc-symbol-heading doc-symbol-method" />

#### register\_handoffs

```python theme={null}
register_handoffs(self, conditions: list[ForwardRef('OnContextCondition') | ForwardRef('OnCondition')]) -> 
```

Register multiple handoff conditions (OnContextCondition or OnCondition).<br />

<b>Parameters:</b>

| Name         | Description                                                                                                         |
| ------------ | ------------------------------------------------------------------------------------------------------------------- |
| `conditions` | List of conditions to add<br /><br />**Type:** list\[ForwardRef('OnContextCondition') \| ForwardRef('OnCondition')] |

<br />

<code class="doc-symbol doc-symbol-heading doc-symbol-method" />

#### register\_hook

```python theme={null}
register_hook(
    self,
    hookable_method: str,
    hook: Callable
) -> 
```

Registers a hook to be called by a hookable method, in order to add a capability to the agent.<br />Registered hooks are kept in lists (one per hookable method), and are called in their order of registration.<br />

<b>Parameters:</b>

| Name              | Description                                                                          |
| ----------------- | ------------------------------------------------------------------------------------ |
| `hookable_method` | A hookable method name implemented by ConversableAgent.<br /><br />**Type:** str     |
| `hook`            | A method implemented by a subclass of AgentCapability.<br /><br />**Type:** Callable |

<br />

<code class="doc-symbol doc-symbol-heading doc-symbol-method" />

#### register\_model\_client

```python theme={null}
register_model_client(
    self,
    model_client_cls: ModelClient,
    **kwargs: Any
) -> 
```

Register a model client.<br />

<b>Parameters:</b>

| Name               | Description                                                                                                                         |
| ------------------ | ----------------------------------------------------------------------------------------------------------------------------------- |
| `model_client_cls` | A custom client class that follows the Client interface<br /><br />**Type:** [ModelClient](/docs/api-reference/autogen/ModelClient) |
| `**kwargs`         | The kwargs for the custom client class to be initialized with<br /><br />**Type:** Any                                              |

<br />

<code class="doc-symbol doc-symbol-heading doc-symbol-method" />

#### register\_nested\_chats

```python theme={null}
register_nested_chats(
    self,
    chat_queue: list[dict[str, Any]],
    trigger: type[Agent] | str | Agent | Callable[[Agent], bool] | list,
    reply_func_from_nested_chats: str | Callable[..., Any] = 'summary_from_nested_chats',
    position: int = 2,
    use_async: bool | None = None,
    **kwargs: Any
) -> None
```

Register a nested chat reply function.<br />

<b>Parameters:</b>

| Name                           | Description                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                               |
| ------------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `chat_queue`                   | a list of chat objects to be initiated.<br /><br />If use\_async is used, then all messages in chat\_queue must have a chat-id associated with them.<br /><br />**Type:** list\[dict\[str, typing.Any]]                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                   |
| `trigger`                      | refer to `register_reply` for details.<br /><br />**Type:** type\[[Agent](/docs/api-reference/autogen/Agent)] \| str \| [Agent](/docs/api-reference/autogen/Agent) \| Callable\[\[[Agent](/docs/api-reference/autogen/Agent)], bool] \| list                                                                                                                                                                                                                                                                                                                                                                                                                                                                              |
| `reply_func_from_nested_chats` | the reply function for the nested chat.<br /><br />The function takes a chat\_queue for nested chat, recipient agent, a list of messages, a sender agent and a config as input and returns a reply message.<br /><br />Default to "summary\_from\_nested\_chats", which corresponds to a built-in reply function that get summary from the nested chat\_queue.<br /><br />`def reply_func_from_nested_chats( chat_queue: List[Dict], recipient: ConversableAgent, messages: Optional[List[Dict]] = None, sender: Optional[Agent] = None, config: Optional[Any] = None, ) -> Tuple[bool, Union[str, Dict, None]]: `<br /><br />**Type:** str \| Callable\[..., Any]<br /><br />**Default:** 'summary\_from\_nested\_chats' |
| `position`                     | Ref to `register_reply` for details.<br /><br />Default to 2. It means we first check the termination and human reply, then check the registered nested chat reply.<br /><br />**Type:** int<br /><br />**Default:** 2                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                    |
| `use_async`                    | Uses a\_initiate\_chats internally to start nested chats.<br /><br />If the original chat is initiated with a\_initiate\_chats, you may set this to true so nested chats do not run in sync.<br /><br />**Type:** bool \| None<br /><br />**Default:** None                                                                                                                                                                                                                                                                                                                                                                                                                                                               |
| `**kwargs`                     | **Type:** Any                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                             |

<br />

<code class="doc-symbol doc-symbol-heading doc-symbol-method" />

#### register\_reply

```python theme={null}
register_reply(
    self,
    trigger: type[Agent] | str | Agent | Callable[[Agent], bool] | list,
    reply_func: Callable,
    position: int = 0,
    config: Any | None = None,
    reset_config: Callable[..., Any] | None = None,
    *,
    ignore_async_in_sync_chat: bool = False,
    remove_other_reply_funcs: bool = False
) -> 
```

Register a reply function.<br />The reply function will be called when the trigger matches the sender.<br />The function registered later will be checked earlier by default.<br />To change the order, set the position to a positive integer.<br />Both sync and async reply functions can be registered. The sync reply function will be triggered
from both sync and async chats. However, an async reply function will only be triggered from async
chats (initiated with `ConversableAgent.a_initiate_chat`). If an `async` reply function is registered
and a chat is initialized with a sync function, `ignore_async_in_sync_chat` determines the behaviour as follows: <br />    if `ignore_async_in_sync_chat` is set to `False` (default value), an exception will be raised, and
if `ignore_async_in_sync_chat` is set to `True`, the reply function will be ignored.<br />

<b>Parameters:</b>

| Name                        | Description                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        |
| --------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
| `trigger`                   | the trigger.<br /><br />If a class is provided, the reply function will be called when the sender is an instance of the class.<br /><br />If a string is provided, the reply function will be called when the sender's name matches the string.<br /><br />If an agent instance is provided, the reply function will be called when the sender is the agent instance.<br /><br />If a callable is provided, the reply function will be called when the callable returns True.<br /><br />If a list is provided, the reply function will be called when any of the triggers in the list is activated.<br /><br />If None is provided, the reply function will be called only when the sender is None.<br /><br />Note: Be sure to register `None` as a trigger if you would like to trigger an auto-reply function with non-empty messages and `sender=None`.<br /><br />**Type:** type\[[Agent](/docs/api-reference/autogen/Agent)] \| str \| [Agent](/docs/api-reference/autogen/Agent) \| Callable\[\[[Agent](/docs/api-reference/autogen/Agent)], bool] \| list |
| `reply_func`                | the reply function.<br /><br />The function takes a recipient agent, a list of messages, a sender agent and a config as input and returns a reply message.<br /><br />`def reply_func( recipient: ConversableAgent, messages: Optional[List[Dict]] = None, sender: Optional[Agent] = None, config: Optional[Any] = None, ) -> Tuple[bool, Union[str, Dict, None]]: `<br /><br />**Type:** Callable                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                 |
| `position`                  | the position of the reply function in the reply function list.<br /><br />The function registered later will be checked earlier by default.<br /><br />To change the order, set the position to a positive integer.<br /><br />**Type:** int<br /><br />**Default:** 0                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                             |
| `config`                    | the config to be passed to the reply function.<br /><br />When an agent is reset, the config will be reset to the original value.<br /><br />**Type:** Any \| None<br /><br />**Default:** None                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                    |
| `reset_config`              | the function to reset the config.<br /><br />The function returns None.<br /><br />Signature: `def reset_config(config: Any)`<br /><br />**Type:** Callable\[..., Any] \| None<br /><br />**Default:** None                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        |
| `ignore_async_in_sync_chat` | whether to ignore the async reply function in sync chats.<br /><br />If `False`, an exception will be raised if an async reply function is registered and a chat is initialized with a sync function.<br /><br />**Type:** bool<br /><br />**Default:** False                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                      |
| `remove_other_reply_funcs`  | whether to remove other reply functions when registering this reply function.<br /><br />**Type:** bool<br /><br />**Default:** False                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                              |

<br />

<code class="doc-symbol doc-symbol-heading doc-symbol-method" />

#### remove\_tool\_for\_llm

```python theme={null}
remove_tool_for_llm(self, tool: Tool) -> None
```

Remove a tool (register for LLM tool)

<b>Parameters:</b>

| Name   | Description                                              |
| ------ | -------------------------------------------------------- |
| `tool` | **Type:** [Tool](/docs/api-reference/autogen/tools/Tool) |

<br />

<code class="doc-symbol doc-symbol-heading doc-symbol-method" />

#### replace\_reply\_func

```python theme={null}
replace_reply_func(
    self,
    old_reply_func: Callable,
    new_reply_func: Callable
) -> 
```

Replace a registered reply function with a new one.<br />

<b>Parameters:</b>

| Name             | Description                                                                  |
| ---------------- | ---------------------------------------------------------------------------- |
| `old_reply_func` | the old reply function to be replaced.<br /><br />**Type:** Callable         |
| `new_reply_func` | the new reply function to replace the old one.<br /><br />**Type:** Callable |

<br />

<code class="doc-symbol doc-symbol-heading doc-symbol-method" />

#### reset

```python theme={null}
reset(self) -> None
```

Reset the agent.

<br />

<code class="doc-symbol doc-symbol-heading doc-symbol-method" />

#### reset\_consecutive\_auto\_reply\_counter

```python theme={null}
reset_consecutive_auto_reply_counter(self, sender: Agent | None = None) -> 
```

Reset the consecutive\_auto\_reply\_counter of the sender.

<b>Parameters:</b>

| Name     | Description                                                                               |
| -------- | ----------------------------------------------------------------------------------------- |
| `sender` | **Type:** [Agent](/docs/api-reference/autogen/Agent) \| None<br /><br />**Default:** None |

<br />

<code class="doc-symbol doc-symbol-heading doc-symbol-method" />

#### run

```python theme={null}
run(
    self,
    recipient: ForwardRef('ConversableAgent') | None = None,
    clear_history: bool = True,
    silent: bool | None = False,
    cache: AbstractCache | None = None,
    max_turns: int | None = None,
    summary_method: str | Callable[..., Any] | None = 'last_msg',
    summary_args: dict[str, Any] | None = {},
    message: dict[str, Any] | str | Callable[..., Any] | None = None,
    executor_kwargs: dict[str, Any] | None = None,
    tools: Tool | Iterable[Tool] | None = None,
    user_input: bool | None = False,
    msg_to: str | None = 'agent',
    **kwargs: Any
) -> RunResponseProtocol
```

<b>Parameters:</b>

| Name              | Description                                                                                                                                                |
| ----------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `recipient`       | **Type:** ForwardRef('ConversableAgent') \| None<br /><br />**Default:** None                                                                              |
| `clear_history`   | **Type:** bool<br /><br />**Default:** True                                                                                                                |
| `silent`          | **Type:** bool \| None<br /><br />**Default:** False                                                                                                       |
| `cache`           | **Type:** [AbstractCache](/docs/api-reference/autogen/cache/AbstractCache) \| None<br /><br />**Default:** None                                            |
| `max_turns`       | **Type:** int \| None<br /><br />**Default:** None                                                                                                         |
| `summary_method`  | **Type:** str \| Callable\[..., Any] \| None<br /><br />**Default:** 'last\_msg'                                                                           |
| `summary_args`    | **Type:** dict\[str, typing.Any] \| None<br /><br />**Default:** \{}                                                                                       |
| `message`         | **Type:** dict\[str, typing.Any] \| str \| Callable\[..., Any] \| None<br /><br />**Default:** None                                                        |
| `executor_kwargs` | **Type:** dict\[str, typing.Any] \| None<br /><br />**Default:** None                                                                                      |
| `tools`           | **Type:** [Tool](/docs/api-reference/autogen/tools/Tool) \| Iterable\[[Tool](/docs/api-reference/autogen/tools/Tool)] \| None<br /><br />**Default:** None |
| `user_input`      | **Type:** bool \| None<br /><br />**Default:** False                                                                                                       |
| `msg_to`          | **Type:** str \| None<br /><br />**Default:** 'agent'                                                                                                      |
| `**kwargs`        | **Type:** Any                                                                                                                                              |

<br />

<code class="doc-symbol doc-symbol-heading doc-symbol-method" />

#### run\_code

```python theme={null}
run_code(
    self,
    code: str,
    **kwargs: Any
) -> tuple[int, str, str | None]
```

Run the code and return the result.<br />Override this function to modify the way to run the code.<br />

<b>Parameters:</b>

| Name       | Description                                       |
| ---------- | ------------------------------------------------- |
| `code`     | the code to be executed.<br /><br />**Type:** str |
| `**kwargs` | other keyword arguments.<br /><br />**Type:** Any |

<b>Returns:</b>

| Type                          | Description                                                                                                                                                                                             |
| ----------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| tuple\[int, str, str \| None] | A tuple of (exitcode, logs, image). exitcode (int): the exit code of the code execution. logs (str): the logs of the code execution. image (str or None): the docker image used for the code execution. |

<br />

<code class="doc-symbol doc-symbol-heading doc-symbol-method" />

#### send

```python theme={null}
send(
    self,
    message: dict[str, Any] | str,
    recipient: Agent,
    request_reply: bool | None = None,
    silent: bool | None = False
) -> 
```

Send a message to another agent.<br />

<b>Parameters:</b>

| Name            | Description                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                  |
| --------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `message`       | message to be sent.<br /><br />The message could contain the following fields: - content (str or List): Required, the content of the message.<br /><br />(Can be None) - function\_call (str): the name of the function to be called.<br /><br />- name (str): the name of the function to be called.<br /><br />- role (str): the role of the message, any role that is not "function" will be modified to "assistant".<br /><br />- context (dict): the context of the message, which will be passed to [OpenAIWrapper.create](https://docs.ag2.ai/latest/docs/api-reference/autogen/OpenAIWrapper/#create).<br /><br />For example, one agent can send a message A as:<br /><br />**Type:** dict\[str, typing.Any] \| str |
| `recipient`     | the recipient of the message.<br /><br />**Type:** [Agent](/docs/api-reference/autogen/Agent)                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                |
| `request_reply` | whether to request a reply from the recipient.<br /><br />**Type:** bool \| None<br /><br />**Default:** None                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                |
| `silent`        | (Experimental) whether to print the message sent.<br /><br />**Type:** bool \| None<br /><br />**Default:** False                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                            |

<br />

<code class="doc-symbol doc-symbol-heading doc-symbol-method" />

#### sequential\_run

```python theme={null}
sequential_run(self, chat_queue: list[dict[str, Any]]) -> list[RunResponseProtocol]
```

(Experimental) Initiate chats with multiple agents sequentially.<br />

<b>Parameters:</b>

| Name         | Description                                                                                                                                                                                                            |
| ------------ | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `chat_queue` | a list of dictionaries containing the information of the chats.<br /><br />Each dictionary should contain the input arguments for [`initiate_chat`](#initiate-chat)<br /><br />**Type:** list\[dict\[str, typing.Any]] |

<b>Returns:</b>

| Type                                                                                          | Description                                                                          |
| --------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------ |
| list\[[RunResponseProtocol](/docs/api-reference/autogen/io/run_response/RunResponseProtocol)] | a list of ChatResult objects corresponding to the finished chats in the chat\_queue. |

<br />

<code class="doc-symbol doc-symbol-heading doc-symbol-method" />

#### set\_ui\_tools

```python theme={null}
set_ui_tools(self, tools: list[Tool]) -> None
```

Set the UI tools for the agent.<br />

<b>Parameters:</b>

| Name    | Description                                                                                           |
| ------- | ----------------------------------------------------------------------------------------------------- |
| `tools` | a list of tools to be set.<br /><br />**Type:** list\[[Tool](/docs/api-reference/autogen/tools/Tool)] |

<br />

<code class="doc-symbol doc-symbol-heading doc-symbol-method" />

#### stop\_reply\_at\_receive

```python theme={null}
stop_reply_at_receive(self, sender: Agent | None = None) -> 
```

Reset the reply\_at\_receive of the sender.

<b>Parameters:</b>

| Name     | Description                                                                               |
| -------- | ----------------------------------------------------------------------------------------- |
| `sender` | **Type:** [Agent](/docs/api-reference/autogen/Agent) \| None<br /><br />**Default:** None |

<br />

<code class="doc-symbol doc-symbol-heading doc-symbol-method" />

#### unset\_ui\_tools

```python theme={null}
unset_ui_tools(self, tools: list[Tool]) -> None
```

Unset the UI tools for the agent.<br />

<b>Parameters:</b>

| Name    | Description                                                                                             |
| ------- | ------------------------------------------------------------------------------------------------------- |
| `tools` | a list of tools to be unset.<br /><br />**Type:** list\[[Tool](/docs/api-reference/autogen/tools/Tool)] |

<br />

<code class="doc-symbol doc-symbol-heading doc-symbol-method" />

#### update\_agent\_state\_before\_reply

```python theme={null}
update_agent_state_before_reply(self, messages: list[dict[str, Any]]) -> None
```

Calls any registered capability hooks to update the agent's state.<br />Primarily used to update context variables.<br />Will, potentially, modify the messages.

<b>Parameters:</b>

| Name       | Description                             |
| ---------- | --------------------------------------- |
| `messages` | **Type:** list\[dict\[str, typing.Any]] |

<br />

<code class="doc-symbol doc-symbol-heading doc-symbol-method" />

#### update\_function\_signature

```python theme={null}
update_function_signature(
    self,
    func_sig: dict[str, Any] | str,
    is_remove: None,
    silent_override: bool = False
) -> 
```

Update a function\_signature in the LLM configuration for function\_call.<br />

<b>Parameters:</b>

| Name              | Description                                                                                                                                                                                                                                                                                             |
| ----------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `func_sig`        | description/name of the function to update/remove to the model.<br /><br />See: [https://platform.openai.com/docs/api-reference/chat/create#chat/create-functions](https://platform.openai.com/docs/api-reference/chat/create#chat/create-functions)<br /><br />**Type:** dict\[str, typing.Any] \| str |
| `is_remove`       | whether removing the function from llm\_config with name 'func\_sig'<br /><br />**Type:** None                                                                                                                                                                                                          |
| `silent_override` | whether to print warnings when overriding functions.<br /><br />**Type:** bool<br /><br />**Default:** False                                                                                                                                                                                            |

<br />

<code class="doc-symbol doc-symbol-heading doc-symbol-method" />

#### update\_max\_consecutive\_auto\_reply

```python theme={null}
update_max_consecutive_auto_reply(
    self,
    value: int,
    sender: Agent | None = None
) -> 
```

Update the maximum number of consecutive auto replies.<br />

<b>Parameters:</b>

| Name     | Description                                                                                                                                                                                      |
| -------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
| `value`  | the maximum number of consecutive auto replies.<br /><br />**Type:** int                                                                                                                         |
| `sender` | when the sender is provided, only update the max\_consecutive\_auto\_reply for that sender.<br /><br />**Type:** [Agent](/docs/api-reference/autogen/Agent) \| None<br /><br />**Default:** None |

<br />

<code class="doc-symbol doc-symbol-heading doc-symbol-method" />

#### update\_system\_message

```python theme={null}
update_system_message(self, system_message: str) -> None
```

Update the system message.<br />

<b>Parameters:</b>

| Name             | Description                                                               |
| ---------------- | ------------------------------------------------------------------------- |
| `system_message` | system message for the ChatCompletion inference.<br /><br />**Type:** str |

<br />

<code class="doc-symbol doc-symbol-heading doc-symbol-method" />

#### update\_tool\_signature

```python theme={null}
update_tool_signature(
    self,
    tool_sig: dict[str, Any] | str,
    is_remove: bool,
    silent_override: bool = False
) -> 
```

Update a tool\_signature in the LLM configuration for tool\_call.<br />

<b>Parameters:</b>

| Name              | Description                                                                                                                                                                                                                                                                                 |
| ----------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `tool_sig`        | description/name of the tool to update/remove to the model.<br /><br />See: [https://platform.openai.com/docs/api-reference/chat/create#chat-create-tools](https://platform.openai.com/docs/api-reference/chat/create#chat-create-tools)<br /><br />**Type:** dict\[str, typing.Any] \| str |
| `is_remove`       | whether removing the tool from llm\_config with name 'tool\_sig'<br /><br />**Type:** bool                                                                                                                                                                                                  |
| `silent_override` | whether to print warnings when overriding functions.<br /><br />**Type:** bool<br /><br />**Default:** False                                                                                                                                                                                |

<br />
