> For the complete documentation index, see [llms.txt](https://docs.wisej.com/ai/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.wisej.com/ai/components/api/smartprompt/wisej.ai.smartagentprompt.md).

# SmartAgentPrompt

Namespace: **Wisej.AI**

Assembly: **Wisej.AI** (3.5.0.0)

* [SmartObject](/ai/components/api/wisej.ai.smartobject.md)
  * [SmartPrompt](/ai/components/api/smartprompt.md)
    * [SmartAgentPrompt](/ai/components/api/smartprompt/wisej.ai.smartagentprompt.md)

TODO:

{% tabs %}
{% tab title="C#" %}

```csharp
public class SmartAgentPrompt : SmartPrompt
```

{% endtab %}

{% tab title="VB.NET" %}

```visual-basic
Public Class SmartAgentPrompt
    Inherits SmartPrompt
```

{% endtab %}
{% endtabs %}

## Constructors

### ![](/files/ptrKjmmRoQB76pvrIqh0) SmartAgentPrompt(text)

Initializes a new instance of the [SmartAgentPrompt](/ai/components/api/smartprompt/wisej.ai.smartagentprompt.md) class with optional text.

| Name     | Type                                                          | Description                                             |
| -------- | ------------------------------------------------------------- | ------------------------------------------------------- |
| **text** | [String](https://docs.microsoft.com/dotnet/api/system.string) | The text associated with the prompt. Default is `null`. |

## Methods

### ![](/files/ptrKjmmRoQB76pvrIqh0) RunAgentAsync(adapter, message)

Executes the agent request asynchronously with the specified sender and message.

| Parameter   | Type                                                                        | Description                                  |
| ----------- | --------------------------------------------------------------------------- | -------------------------------------------- |
| **adapter** | [SmartAdapter](/ai/components/api/smartadapter.md)                          | The sender adapter initiating the request.   |
| **message** | [Message](/ai/components/api/smartsession/wisej.ai.smartsession.message.md) | Message to send to the agent for processing. |

**Returns:** [Task\<Message>](https://docs.microsoft.com/dotnet/api/system.threading.tasks.task-1). A task representing the asynchronous operation, with a [Message](/ai/components/api/smartsession/wisej.ai.smartsession.message.md) as the result.

**Throws:**

* [InvalidOperationException](https://docs.microsoft.com/dotnet/api/system.invalidoperationexception)\
  Thrown when the SmartAdapter is busy.
* [ArgumentNullException](https://docs.microsoft.com/dotnet/api/system.argumentnullexception)\
  Thrown when the sender is null.

### ![](/files/ptrKjmmRoQB76pvrIqh0) Subscribe(adapter)

Subscribes the agent to the specified adapter.

| Parameter   | Type                                               | Description                                        |
| ----------- | -------------------------------------------------- | -------------------------------------------------- |
| **adapter** | [SmartAdapter](/ai/components/api/smartadapter.md) | The adapter to which the agent will be subscribed. |

**Throws:**

* [ArgumentNullException](https://docs.microsoft.com/dotnet/api/system.argumentnullexception)\
  Thrown when the adapter is null.

### ![](/files/ptrKjmmRoQB76pvrIqh0) Unsubscribe(adapter)

Unsubscribes the agent from the specified adapter.

| Parameter   | Type                                               | Description                                            |
| ----------- | -------------------------------------------------- | ------------------------------------------------------ |
| **adapter** | [SmartAdapter](/ai/components/api/smartadapter.md) | The adapter from which the agent will be unsubscribed. |

**Throws:**

* [ArgumentNullException](https://docs.microsoft.com/dotnet/api/system.argumentnullexception)\
  Thrown when the adapter is null.

## Implements

| Name                                                                              | Description                                |
| --------------------------------------------------------------------------------- | ------------------------------------------ |
| [IToolProvider](/ai/components/api/smarttool/wisej.ai.smarttool.itoolprovider.md) | Represents a provider that supplies tools. |


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://docs.wisej.com/ai/components/api/smartprompt/wisej.ai.smartagentprompt.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
