# Agent


```
class Agent
```

<br />

*** ** * ** ***

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

## Summary

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

| ### Public companion functions |
|---|---|
| `https://developers.google.com/android/reference/kotlin/com/google/mlkit/genai/agent/Agent.Builder` | `https://developers.google.com/android/reference/kotlin/com/google/mlkit/genai/agent/Agent#builder()()` Returns a new `https://developers.google.com/android/reference/kotlin/com/google/mlkit/genai/agent/Agent.Builder` for constructing an `https://developers.google.com/android/reference/kotlin/com/google/mlkit/genai/agent/Agent`. |

| ### Public constructors |
|---|
| `https://developers.google.com/android/reference/kotlin/com/google/mlkit/genai/agent/Agent#Agent(kotlin.String,kotlin.String,kotlin.collections.List,kotlin.Int,kotlin.Boolean,kotlin.collections.List)( name: https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-string/index.html, instructions: https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-string/index.html, tools: https://kotlinlang.org/api/latest/jvm/stdlib/kotlin.collections/-list/index.html<https://developers.google.com/android/reference/kotlin/com/google/mlkit/genai/agent/AgentTool>, maxTurns: https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-int/index.html, isAppFunctionsEnabled: https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-boolean/index.html, enabledAppFunctionIds: https://kotlinlang.org/api/latest/jvm/stdlib/kotlin.collections/-list/index.html<https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-string/index.html> )` |

| ### Public functions |
|---|---|
| `open operator https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-boolean/index.html` | `https://developers.google.com/android/reference/kotlin/com/google/mlkit/genai/agent/Agent#equals(kotlin.Any)(other: https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-any/index.html?)` |
| `open https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-int/index.html` | `https://developers.google.com/android/reference/kotlin/com/google/mlkit/genai/agent/Agent#hashCode()()` |
| `open https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-string/index.html` | `https://developers.google.com/android/reference/kotlin/com/google/mlkit/genai/agent/Agent#toString()()` |

| ### Public properties |
|---|---|
| `https://kotlinlang.org/api/latest/jvm/stdlib/kotlin.collections/-list/index.html<https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-string/index.html>` | `https://developers.google.com/android/reference/kotlin/com/google/mlkit/genai/agent/Agent#enabledAppFunctionIds()` 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/kotlin/com/google/mlkit/genai/agent/Agent.Builder#addAppFunctionIds(kotlin.collections.List)`. |
| `https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-string/index.html` | `https://developers.google.com/android/reference/kotlin/com/google/mlkit/genai/agent/Agent#instructions()` The system instructions defining the agent's behavior and context. |
| `https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-boolean/index.html` | `https://developers.google.com/android/reference/kotlin/com/google/mlkit/genai/agent/Agent#isAppFunctionsActive()` Returns whether any AppFunction capability (whole-application discovery or ID-scoped functions) is configured on this agent. |
| `https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-boolean/index.html` | `https://developers.google.com/android/reference/kotlin/com/google/mlkit/genai/agent/Agent#isAppFunctionsEnabled()` Whether automatic discovery and execution of Android AppFunctions is enabled across the calling application. |
| `https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-int/index.html` | `https://developers.google.com/android/reference/kotlin/com/google/mlkit/genai/agent/Agent#maxTurns()` Maximum execution steps allowed per turn before forced termination. |
| `https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-string/index.html` | `https://developers.google.com/android/reference/kotlin/com/google/mlkit/genai/agent/Agent#name()` The identifier name of the agent. |
| `https://kotlinlang.org/api/latest/jvm/stdlib/kotlin.collections/-list/index.html<https://developers.google.com/android/reference/kotlin/com/google/mlkit/genai/agent/AgentTool>` | `https://developers.google.com/android/reference/kotlin/com/google/mlkit/genai/agent/Agent#tools()` The list of tools available for the agent to execute. |

## Public companion functions

### builder

```
fun builder(): Agent.Builder
```

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

## Public constructors

### Agent

```
Agent(
    name: String = "Assistant",
    instructions: String = "",
    tools: List<AgentTool> = emptyList(),
    maxTurns: Int = 10,
    isAppFunctionsEnabled: Boolean = false,
    enabledAppFunctionIds: List<String> = emptyList()
)
```

## Public functions

### equals

```
open operator fun equals(other: Any?): Boolean
```

### hashCode

```
open fun hashCode(): Int
```

### toString

```
open fun toString(): String
```

## Public properties

### enabledAppFunctionIds

```
val enabledAppFunctionIds: List<String>
```

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/kotlin/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.

### instructions

```
val instructions: String
```

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

### isAppFunctionsActive

```
val isAppFunctionsActive: Boolean
```

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

### isAppFunctionsEnabled

```
val isAppFunctionsEnabled: Boolean
```

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/kotlin/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/kotlin/com/google/mlkit/genai/agent/AppFunctionAgentTools#discover(kotlinx.coroutines.CoroutineDispatcher)` and wrap `https://developers.google.com/android/reference/kotlin/com/google/mlkit/genai/agent/AgentTool#execute(kotlin.collections.Map)` instead. Defaults to false.

### maxTurns

```
val maxTurns: Int
```

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

### name

```
val name: String
```

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

### tools

```
val tools: List<AgentTool>
```

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