# Agent


```
public final class Agent
```

<br />

*** ** * ** ***

Represents an AI Agent guided by system instructions and equipped with executable tools.

## Summary

| ### Nested types |
|---|
| `public final class https://developers.google.com/android/reference/com/google/mlkit/genai/agent/Agent.Builder` Builder for constructing `https://developers.google.com/android/reference/com/google/mlkit/genai/agent/Agent` instances. |

| ### Public constructors |
|---|
| `https://developers.google.com/android/reference/com/google/mlkit/genai/agent/Agent#Agent(kotlin.String,kotlin.String,kotlin.collections.List,kotlin.Int,kotlin.Boolean,kotlin.collections.List)( @https://developer.android.com/reference/androidx/annotation/NonNull.html https://developer.android.com/reference/java/lang/String.html name, @https://developer.android.com/reference/androidx/annotation/NonNull.html https://developer.android.com/reference/java/lang/String.html instructions, @https://developer.android.com/reference/androidx/annotation/NonNull.html https://developer.android.com/reference/java/util/List.html<@https://developer.android.com/reference/androidx/annotation/NonNull.html https://developers.google.com/android/reference/com/google/mlkit/genai/agent/AgentTool> tools, int maxTurns, boolean isAppFunctionsEnabled, @https://developer.android.com/reference/androidx/annotation/NonNull.html https://developer.android.com/reference/java/util/List.html<@https://developer.android.com/reference/androidx/annotation/NonNull.html https://developer.android.com/reference/java/lang/String.html> enabledAppFunctionIds )` |

| ### Public methods |
|---|---|
| `static final @https://developer.android.com/reference/androidx/annotation/NonNull.html https://developers.google.com/android/reference/com/google/mlkit/genai/agent/Agent.Builder` | `https://developers.google.com/android/reference/com/google/mlkit/genai/agent/Agent#builder()()` Returns a new `https://developers.google.com/android/reference/com/google/mlkit/genai/agent/Agent.Builder` for constructing an `https://developers.google.com/android/reference/com/google/mlkit/genai/agent/Agent`. |
| `boolean` | `https://developers.google.com/android/reference/com/google/mlkit/genai/agent/Agent#equals(kotlin.Any)(https://developer.android.com/reference/java/lang/Object.html other)` |
| `final @https://developer.android.com/reference/androidx/annotation/NonNull.html https://developer.android.com/reference/java/util/List.html<@https://developer.android.com/reference/androidx/annotation/NonNull.html https://developer.android.com/reference/java/lang/String.html>` | `https://developers.google.com/android/reference/com/google/mlkit/genai/agent/Agent#getEnabledAppFunctionIds()()` Specific AppFunction identifiers (full ID such as `"com.example.MyAppFunctionService#createNote"` or method name such as `"createNote"`) to scope the agent's AppFunction capabilities to, populated via `https://developers.google.com/android/reference/com/google/mlkit/genai/agent/Agent.Builder#addAppFunctionIds(kotlin.collections.List)`. |
| `final @https://developer.android.com/reference/androidx/annotation/NonNull.html https://developer.android.com/reference/java/lang/String.html` | `https://developers.google.com/android/reference/com/google/mlkit/genai/agent/Agent#getInstructions()()` The system instructions defining the agent's behavior and context. |
| `final int` | `https://developers.google.com/android/reference/com/google/mlkit/genai/agent/Agent#getMaxTurns()()` Maximum execution steps allowed per turn before forced termination. |
| `final @https://developer.android.com/reference/androidx/annotation/NonNull.html https://developer.android.com/reference/java/lang/String.html` | `https://developers.google.com/android/reference/com/google/mlkit/genai/agent/Agent#getName()()` The identifier name of the agent. |
| `final @https://developer.android.com/reference/androidx/annotation/NonNull.html https://developer.android.com/reference/java/util/List.html<@https://developer.android.com/reference/androidx/annotation/NonNull.html https://developers.google.com/android/reference/com/google/mlkit/genai/agent/AgentTool>` | `https://developers.google.com/android/reference/com/google/mlkit/genai/agent/Agent#getTools()()` The list of tools available for the agent to execute. |
| `int` | `https://developers.google.com/android/reference/com/google/mlkit/genai/agent/Agent#hashCode()()` |
| `final boolean` | `https://developers.google.com/android/reference/com/google/mlkit/genai/agent/Agent#getIsAppFunctionsActive()()` Returns whether any AppFunction capability (whole-application discovery or ID-scoped functions) is configured on this agent. |
| `final boolean` | `https://developers.google.com/android/reference/com/google/mlkit/genai/agent/Agent#getIsAppFunctionsEnabled()()` Whether automatic discovery and execution of Android AppFunctions is enabled across the calling application. |
| `@https://developer.android.com/reference/androidx/annotation/NonNull.html https://developer.android.com/reference/java/lang/String.html` | `https://developers.google.com/android/reference/com/google/mlkit/genai/agent/Agent#toString()()` |

## Public constructors

### Agent

```
public Agent(
    @NonNull String name,
    @NonNull String instructions,
    @NonNull List<@NonNull AgentTool> tools,
    int maxTurns,
    boolean isAppFunctionsEnabled,
    @NonNull List<@NonNull String> enabledAppFunctionIds
)
```

## Public methods

### builder

```
public static final @NonNull Agent.Builder builder()
```

Returns a new `https://developers.google.com/android/reference/com/google/mlkit/genai/agent/Agent.Builder` for constructing an `https://developers.google.com/android/reference/com/google/mlkit/genai/agent/Agent`.

### equals

```
public boolean equals(Object other)
```

### getEnabledAppFunctionIds

```
public final @NonNull List<@NonNull String> getEnabledAppFunctionIds()
```

Specific AppFunction identifiers (full ID such as `"com.example.MyAppFunctionService#createNote"` or method name such as `"createNote"`) to scope the agent's AppFunction capabilities to, populated via `https://developers.google.com/android/reference/com/google/mlkit/genai/agent/Agent.Builder#addAppFunctionIds(kotlin.collections.List)`. Useful when multiple `@AppFunction` methods reside in a single `AppFunctionService` class. Defaults to empty.

### getInstructions

```
public final @NonNull String getInstructions()
```

The system instructions defining the agent's behavior and context. Defaults to an empty string.

### getMaxTurns

```
public final int getMaxTurns()
```

Maximum execution steps allowed per turn before forced termination. Defaults to 10.

### getName

```
public final @NonNull String getName()
```

The identifier name of the agent. Defaults to "Assistant".

### getTools

```
public final @NonNull List<@NonNull AgentTool> getTools()
```

The list of tools available for the agent to execute. Defaults to empty.

### hashCode

```
public int hashCode()
```

### isAppFunctionsActive

```
public final boolean isAppFunctionsActive()
```

Returns whether any AppFunction capability (whole-application discovery or ID-scoped functions) is configured on this agent.

### isAppFunctionsEnabled

```
public final boolean isAppFunctionsEnabled()
```

Whether automatic discovery and execution of Android AppFunctions is enabled across the calling application. When enabled, discovered functions are executed automatically by `https://developers.google.com/android/reference/com/google/mlkit/genai/agent/AgentRunner` when invoked by the model. For functions requiring user confirmation or runtime permission prompts before execution, use `https://developers.google.com/android/reference/com/google/mlkit/genai/agent/AppFunctionAgentTools#discover(kotlinx.coroutines.CoroutineDispatcher)` and wrap `https://developers.google.com/android/reference/com/google/mlkit/genai/agent/AgentTool#execute(kotlin.collections.Map)` instead. Defaults to false.

### toString

```
public @NonNull String toString()
```