# Agent

## `autogen.Agent`

Bases: `Protocol`

(In preview) A protocol for Agent.

An agent can communicate with other agents and perform actions. Different agents can differ in what actions they perform in the `receive` method.

### `name` property

```
name
```

The name of the agent.

### `description` property

```
description
```

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

### `send`

```
send(message, recipient, request_reply=None)
```

Send a message to another agent.

| PARAMETER   | DESCRIPTION                                                                                                                                                                    |
|-------------|--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| `message`   | the message to send. If a dict, it should be a JSON-serializable and follows the OpenAI's ChatCompletion schema.<br>**TYPE:**`dict or str`                                     |
| `recipient` | the recipient of the message.<br>**TYPE:**`Agent`                                                                                                                             |
| `request_reply` | whether to request a reply from the recipient.<br>**TYPE:**`bool`**DEFAULT:**`None`                                                                                         |

Source code in `autogen/agentchat/agent.py`

|     |     |
|-----|-----|
|```  |```  |

### `a_send` async

```
a_send(message, recipient, request_reply=None)
```

(Async) Send a message to another agent.

Source code in `autogen/agentchat/agent.py`

|     |     |
|-----|-----|
|```  |```  |

### `receive`

```
receive(message, sender, request_reply=None)
```

Receive a message from another agent.

| PARAMETER   | DESCRIPTION                                                                                                                                                                    |
|-------------|--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| `message`   | the message received. If a dict, it should be a JSON-serializable and follows the OpenAI's ChatCompletion schema.<br>**TYPE:**`dict or str`                                     |
| `sender`    | the sender of the message.<br>**TYPE:**`Agent`                                                                                                                             |
| `request_reply` | whether the sender requests a reply.<br>**TYPE:**`bool`**DEFAULT:**`None`                                                                                                   |

Source code in `autogen/agentchat/agent.py`

|     |     |
|-----|-----|
|```  |```  |

### `a_receive` async

```
a_receive(message, sender, request_reply=None)
```

(Async) Receive a message from another agent.

Source code in `autogen/agentchat/agent.py`

|     |     |
|-----|-----|
|```  |```  |

### `generate_reply`

```
generate_reply(messages=None, sender=None)
```

Generate a reply based on the received messages.

| PARAMETER   | DESCRIPTION                                                                                                                                                                    |
|-------------|--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| `messages`  | a list of messages received from other agents. The messages are dictionaries that are JSON-serializable and follows the OpenAI's ChatCompletion schema.<br>**TYPE:**`list[dict[str, Any]]`**DEFAULT:**`None` |
| `sender`    | sender of an Agent instance.<br>**TYPE:**`Optional[Agent]`**DEFAULT:**`None`                                                                                                 |
| `**kwargs`  | Additional keyword arguments.                                                                                                                                                   |

| RETURNS                             | DESCRIPTION                                                                                                   |
|-------------------------------------|---------------------------------------------------------------------------------------------------------------|
| `str | dict[str, Any] | None` | str or dict or None: the generated reply. If None, no reply is generated.                                        |

Source code in `autogen/agentchat/agent.py`

|     |     |
|-----|-----|
|```  |```  |

### `a_generate_reply` async

```
a_generate_reply(messages=None, sender=None)
```

(Async) Generate a reply based on the received messages.

Source code in `autogen/agentchat/agent.py`

|     |     |
|-----|-----|
|```  |```  |

### `set_ui_tools`

```
set_ui_tools(tools)
```

Set the UI tools for the agent.

| PARAMETER   | DESCRIPTION                                                                                                                                                                    |
|-------------|--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| `tools`     | a list of UI tools to set.<br>**TYPE:**`list[Tool]`                                                                                                                         |

Source code in `autogen/agentchat/agent.py`

|     |     |
|-----|-----|
|```  |```  |

### `unset_ui_tools`

```
unset_ui_tools(tools)
```

Unset the UI tools for the agent.

Source code in `autogen/agentchat/agent.py`

|     |     |
|-----|-----|
|```  |```  |
