# Agent

# 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 Agent.Builder` Builder for constructing `Agent` instances. |

| ### Public constructors |
|---|
| `Agent( @NonNull String name, @NonNull String instructions, @NonNull List<@NonNull AgentTool> tools, int maxTurns, boolean isAppFunctionsEnabled, @NonNull List<@NonNull String> enabledAppFunctionIds )` |

| ### Public methods |
|---|---|
| `static final @NonNull Agent.Builder` | `builder()` Returns a new `Builder` for constructing an `Agent`. |
| `boolean` | `equals(Object other)` |
| `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 `Builder.addAppFunctionIds`. |
| `final @NonNull String` | `getInstructions()` The system instructions defining the agent's behavior and context. |
| `final int` | `getMaxTurns()` Maximum execution steps allowed per turn before forced termination. |
| `final @NonNull String` | `getName()` The identifier name of the agent. |
| `final @NonNull List<@NonNull AgentTool>` | `getTools()` The list of tools available for the agent to execute. |
| `int` | `hashCode()` |
| `final boolean` | `isAppFunctionsActive()` Returns whether any AppFunction capability (whole-application discovery or ID-scoped functions) is configured on this agent. |
| `final boolean` | `isAppFunctionsEnabled()` Whether automatic discovery and execution of Android AppFunctions is enabled across the calling application. |
| `@NonNull String` | `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 `Builder` for constructing an `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 `Builder.addAppFunctionIds`. 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 `AgentRunner` when invoked by the model. For functions requiring user confirmation or runtime permission prompts before execution, use `AppFunctionAgentTools.discover` and wrap `AgentTool.execute` instead. Defaults to false.

### toString

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