> ## 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.Agent

<h2 id="autogen.Agent" class="doc doc-heading">
  <code class="doc-symbol doc-symbol-heading doc-symbol-class" />

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

```python theme={null}
Agent(*args, **kwargs)
```

(In preview) A protocol for Agent.<br />An agent can communicate with other agents and perform actions.<br />Different agents can differ in what actions they perform in the `receive` method.

<b>Parameters:</b>

| Name       | Description |
| ---------- | ----------- |
| `*args`    |             |
| `**kwargs` |             |

### Instance Attributes

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

#### description

<br />

The description of the agent. Used for the agent's introduction in
a group chat setting.

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

#### name

<br />

The name of the agent.

### Instance Methods

<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) Generate a reply based on the received messages.<br />

<b>Parameters:</b>

| Name       | Description                                                                                                                                                                                                                                                |
| ---------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `messages` | a list of messages received from other agents.<br /><br />The messages are dictionaries that are JSON-serializable and follows the OpenAI's ChatCompletion schema.<br /><br />**Type:** list\[dict\[str, typing.Any]] \| None<br /><br />**Default:** None |
| `sender`   | sender of an Agent instance.<br /><br />**Type:** ForwardRef('[Agent](/docs/api-reference/autogen/Agent)') \| None<br /><br />**Default:** None                                                                                                            |
| `**kwargs` | Additional keyword arguments.<br /><br />**Type:** Any                                                                                                                                                                                                     |

<b>Returns:</b>

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

<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
) -> None
```

(Async) Receive a message from another agent.<br />

<b>Parameters:</b>

| Name            | Description                                                                                                                                                                     |
| --------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `message`       | the message received.<br /><br />If a dict, it should be a JSON-serializable and follows the OpenAI's ChatCompletion schema.<br /><br />**Type:** dict\[str, typing.Any] \| str |
| `sender`        | the sender of the message.<br /><br />**Type:** [Agent](/docs/api-reference/autogen/Agent)                                                                                      |
| `request_reply` | whether the sender requests a reply.<br /><br />**Type:** bool \| None<br /><br />**Default:** None                                                                             |

<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
) -> None
```

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

<b>Parameters:</b>

| Name            | Description                                                                                                                                                                    |
| --------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
| `message`       | the message to send.<br /><br />If a dict, it should be a JSON-serializable and follows the OpenAI's ChatCompletion schema.<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                                                                  |

<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
```

Generate a reply based on the received messages.<br />

<b>Parameters:</b>

| Name       | Description                                                                                                                                                                                                                                                |
| ---------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `messages` | a list of messages received from other agents.<br /><br />The messages are dictionaries that are JSON-serializable and follows the OpenAI's ChatCompletion schema.<br /><br />**Type:** list\[dict\[str, typing.Any]] \| None<br /><br />**Default:** None |
| `sender`   | sender of an Agent instance.<br /><br />**Type:** ForwardRef('[Agent](/docs/api-reference/autogen/Agent)') \| None<br /><br />**Default:** None                                                                                                            |
| `**kwargs` | Additional keyword arguments.<br /><br />**Type:** Any                                                                                                                                                                                                     |

<b>Returns:</b>

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

<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
) -> None
```

Receive a message from another agent.<br />

<b>Parameters:</b>

| Name            | Description                                                                                                                                                                     |
| --------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `message`       | the message received.<br /><br />If a dict, it should be a JSON-serializable and follows the OpenAI's ChatCompletion schema.<br /><br />**Type:** dict\[str, typing.Any] \| str |
| `sender`        | the sender of the message.<br /><br />**Type:** [Agent](/docs/api-reference/autogen/Agent)                                                                                      |
| `request_reply` | whether the sender requests a reply.<br /><br />**Type:** bool \| None<br /><br />**Default:** None                                                                             |

<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
) -> None
```

Send a message to another agent.<br />

<b>Parameters:</b>

| Name            | Description                                                                                                                                                                    |
| --------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
| `message`       | the message to send.<br /><br />If a dict, it should be a JSON-serializable and follows the OpenAI's ChatCompletion schema.<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                                                                  |

<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 UI tools to set.<br /><br />**Type:** list\[\~Tool] |

<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 UI tools to set.<br /><br />**Type:** list\[\~Tool] |

<br />
