# AppFunctionAgentTools


```
@OptIn(markerClass = [ExperimentalAppFunctionsFeature])
public static class AppFunctionAgentTools
```

<br />

*** ** * ** ***

Utility for discovering in-app Android AppFunctions and exposing them as `https://developers.google.com/android/reference/com/google/mlkit/genai/agent/AgentTool`s.

This enables advanced use cases such as inspecting available functions, filtering them, or decorating them with confirmation / Human-in-the-Loop (HITL) callbacks before registering them with an `https://developers.google.com/android/reference/com/google/mlkit/genai/agent/Agent`.

Example:

```
val tools = AppFunctionAgentTools.discover()
val agent = Agent.builder()
    .addTools(tools)
    .build()
```

## Summary

| ### Public fields |
|---|---|
| `static @https://developer.android.com/reference/androidx/annotation/NonNull.html https://developers.google.com/android/reference/com/google/mlkit/genai/agent/AppFunctionAgentTools` | `https://developers.google.com/android/reference/com/google/mlkit/genai/agent/AppFunctionAgentTools#INSTANCE()` |

| ### Public methods |
|---|---|
| `static 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/AppFunctionAgentTools#discover(kotlinx.coroutines.CoroutineDispatcher)(@https://developer.android.com/reference/androidx/annotation/NonNull.html https://kotlin.github.io/kotlinx.coroutines/kotlinx-coroutines-core/kotlinx.coroutines/-coroutine-dispatcher/index.html coroutineDispatcher)` Discovers all in-app functions declared with `@androidx.appfunctions.AppFunction` using `MlKitContext.getInstance().applicationContext` and converts them into a list of `https://developers.google.com/android/reference/com/google/mlkit/genai/agent/AgentTool`s. |
| `static 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/AppFunctionAgentTools#discover(android.content.Context,kotlinx.coroutines.CoroutineDispatcher)( @https://developer.android.com/reference/androidx/annotation/NonNull.html https://developer.android.com/reference/android/content/Context.html context, @https://developer.android.com/reference/androidx/annotation/NonNull.html https://kotlin.github.io/kotlinx.coroutines/kotlinx-coroutines-core/kotlinx.coroutines/-coroutine-dispatcher/index.html coroutineDispatcher )` Discovers all in-app functions declared with `@androidx.appfunctions.AppFunction` for the given `https://developers.google.com/android/reference/com/google/mlkit/genai/agent/AppFunctionAgentTools#discover(android.content.Context,kotlinx.coroutines.CoroutineDispatcher)` and converts them into a list of `https://developers.google.com/android/reference/com/google/mlkit/genai/agent/AgentTool`s. |
| `static 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/AppFunctionAgentTools#discover(kotlin.collections.List,kotlinx.coroutines.CoroutineDispatcher)( @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, @https://developer.android.com/reference/androidx/annotation/NonNull.html https://kotlin.github.io/kotlinx.coroutines/kotlinx-coroutines-core/kotlinx.coroutines/-coroutine-dispatcher/index.html coroutineDispatcher )` Discovers in-app functions declared with `@androidx.appfunctions.AppFunction` matching `https://developers.google.com/android/reference/com/google/mlkit/genai/agent/AppFunctionAgentTools#discover(kotlin.collections.List,kotlinx.coroutines.CoroutineDispatcher)` using `MlKitContext.getInstance().applicationContext` and converts them into a list of `https://developers.google.com/android/reference/com/google/mlkit/genai/agent/AgentTool`s. |
| `static 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/AppFunctionAgentTools#discover(kotlin.String,kotlinx.coroutines.CoroutineDispatcher)( @https://developer.android.com/reference/androidx/annotation/NonNull.html https://developer.android.com/reference/java/lang/String.html functionId, @https://developer.android.com/reference/androidx/annotation/NonNull.html https://kotlin.github.io/kotlinx.coroutines/kotlinx-coroutines-core/kotlinx.coroutines/-coroutine-dispatcher/index.html coroutineDispatcher )` Discovers in-app functions declared with `@androidx.appfunctions.AppFunction` matching `https://developers.google.com/android/reference/com/google/mlkit/genai/agent/AppFunctionAgentTools#discover(kotlin.String,kotlinx.coroutines.CoroutineDispatcher)` using `MlKitContext.getInstance().applicationContext` and converts them into a list of `https://developers.google.com/android/reference/com/google/mlkit/genai/agent/AgentTool`s. |
| `static 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/AppFunctionAgentTools#discover(android.content.Context,kotlin.collections.List,kotlinx.coroutines.CoroutineDispatcher)( @https://developer.android.com/reference/androidx/annotation/NonNull.html https://developer.android.com/reference/android/content/Context.html context, @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, @https://developer.android.com/reference/androidx/annotation/NonNull.html https://kotlin.github.io/kotlinx.coroutines/kotlinx-coroutines-core/kotlinx.coroutines/-coroutine-dispatcher/index.html coroutineDispatcher )` Discovers functions declared with `@androidx.appfunctions.AppFunction` matching `https://developers.google.com/android/reference/com/google/mlkit/genai/agent/AppFunctionAgentTools#discover(android.content.Context,kotlin.collections.List,kotlinx.coroutines.CoroutineDispatcher)` for the given `https://developers.google.com/android/reference/com/google/mlkit/genai/agent/AppFunctionAgentTools#discover(android.content.Context,kotlin.collections.List,kotlinx.coroutines.CoroutineDispatcher)` and converts them into a list of `https://developers.google.com/android/reference/com/google/mlkit/genai/agent/AgentTool`s. |
| `static 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/AppFunctionAgentTools#discover(android.content.Context,kotlin.String,kotlinx.coroutines.CoroutineDispatcher)( @https://developer.android.com/reference/androidx/annotation/NonNull.html https://developer.android.com/reference/android/content/Context.html context, @https://developer.android.com/reference/androidx/annotation/NonNull.html https://developer.android.com/reference/java/lang/String.html functionId, @https://developer.android.com/reference/androidx/annotation/NonNull.html https://kotlin.github.io/kotlinx.coroutines/kotlinx-coroutines-core/kotlinx.coroutines/-coroutine-dispatcher/index.html coroutineDispatcher )` Discovers functions declared with `@androidx.appfunctions.AppFunction` matching `https://developers.google.com/android/reference/com/google/mlkit/genai/agent/AppFunctionAgentTools#discover(android.content.Context,kotlin.String,kotlinx.coroutines.CoroutineDispatcher)` for the given `https://developers.google.com/android/reference/com/google/mlkit/genai/agent/AppFunctionAgentTools#discover(android.content.Context,kotlin.String,kotlinx.coroutines.CoroutineDispatcher)` and converts them into a list of `https://developers.google.com/android/reference/com/google/mlkit/genai/agent/AgentTool`s. |

## Public fields

### INSTANCE

```
public static @NonNull AppFunctionAgentTools INSTANCE
```

## Public methods

### discover

```
public static final @NonNull List<@NonNull AgentTool> discover(@NonNull CoroutineDispatcher coroutineDispatcher)
```

Discovers all in-app functions declared with `@androidx.appfunctions.AppFunction` using `MlKitContext.getInstance().applicationContext` and converts them into a list of `https://developers.google.com/android/reference/com/google/mlkit/genai/agent/AgentTool`s.

| Parameters |
|---|---|
| `@https://developer.android.com/reference/androidx/annotation/NonNull.html https://kotlin.github.io/kotlinx.coroutines/kotlinx-coroutines-core/kotlinx.coroutines/-coroutine-dispatcher/index.html coroutineDispatcher` | Dispatcher on which discovery executes. Defaults to `https://kotlin.github.io/kotlinx.coroutines/kotlinx-coroutines-core/kotlinx.coroutines/-dispatchers/-i-o.html`. |

| Returns |
|---|---|
| `@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>` | List of discovered `https://developers.google.com/android/reference/com/google/mlkit/genai/agent/AgentTool` instances scoped to the calling application's package. |

### discover

```
public static final @NonNull List<@NonNull AgentTool> discover(
    @NonNull Context context,
    @NonNull CoroutineDispatcher coroutineDispatcher
)
```

Discovers all in-app functions declared with `@androidx.appfunctions.AppFunction` for the given `https://developers.google.com/android/reference/com/google/mlkit/genai/agent/AppFunctionAgentTools#discover(android.content.Context,kotlinx.coroutines.CoroutineDispatcher)` and converts them into a list of `https://developers.google.com/android/reference/com/google/mlkit/genai/agent/AgentTool`s.

| Parameters |
|---|---|
| `@https://developer.android.com/reference/androidx/annotation/NonNull.html https://developer.android.com/reference/android/content/Context.html context` | The Android context. |
| `@https://developer.android.com/reference/androidx/annotation/NonNull.html https://kotlin.github.io/kotlinx.coroutines/kotlinx-coroutines-core/kotlinx.coroutines/-coroutine-dispatcher/index.html coroutineDispatcher` | Dispatcher on which discovery executes. Defaults to `https://kotlin.github.io/kotlinx.coroutines/kotlinx-coroutines-core/kotlinx.coroutines/-dispatchers/-i-o.html`. |

| Returns |
|---|---|
| `@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>` | List of discovered `https://developers.google.com/android/reference/com/google/mlkit/genai/agent/AgentTool` instances scoped to the calling application's package. |

### discover

```
public static final @NonNull List<@NonNull AgentTool> discover(
    @NonNull List<@NonNull String> enabledAppFunctionIds,
    @NonNull CoroutineDispatcher coroutineDispatcher
)
```

Discovers in-app functions declared with `@androidx.appfunctions.AppFunction` matching `https://developers.google.com/android/reference/com/google/mlkit/genai/agent/AppFunctionAgentTools#discover(kotlin.collections.List,kotlinx.coroutines.CoroutineDispatcher)` using `MlKitContext.getInstance().applicationContext` and converts them into a list of `https://developers.google.com/android/reference/com/google/mlkit/genai/agent/AgentTool`s.

| Parameters |
|---|---|
| `@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` | The AppFunction identifiers or method names to discover. |
| `@https://developer.android.com/reference/androidx/annotation/NonNull.html https://kotlin.github.io/kotlinx.coroutines/kotlinx-coroutines-core/kotlinx.coroutines/-coroutine-dispatcher/index.html coroutineDispatcher` | Dispatcher on which discovery executes. Defaults to `https://kotlin.github.io/kotlinx.coroutines/kotlinx-coroutines-core/kotlinx.coroutines/-dispatchers/-i-o.html`. |

| Returns |
|---|---|
| `@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>` | List of discovered `https://developers.google.com/android/reference/com/google/mlkit/genai/agent/AgentTool` instances. |

### discover

```
public static final @NonNull List<@NonNull AgentTool> discover(
    @NonNull String functionId,
    @NonNull CoroutineDispatcher coroutineDispatcher
)
```

Discovers in-app functions declared with `@androidx.appfunctions.AppFunction` matching `https://developers.google.com/android/reference/com/google/mlkit/genai/agent/AppFunctionAgentTools#discover(kotlin.String,kotlinx.coroutines.CoroutineDispatcher)` using `MlKitContext.getInstance().applicationContext` and converts them into a list of `https://developers.google.com/android/reference/com/google/mlkit/genai/agent/AgentTool`s.

| Parameters |
|---|---|
| `@https://developer.android.com/reference/androidx/annotation/NonNull.html https://developer.android.com/reference/java/lang/String.html functionId` | The AppFunction identifier (e.g., `"com.example.MyService#createNote"`) or method name (e.g., `"createNote"`). |
| `@https://developer.android.com/reference/androidx/annotation/NonNull.html https://kotlin.github.io/kotlinx.coroutines/kotlinx-coroutines-core/kotlinx.coroutines/-coroutine-dispatcher/index.html coroutineDispatcher` | Dispatcher on which discovery executes. Defaults to `https://kotlin.github.io/kotlinx.coroutines/kotlinx-coroutines-core/kotlinx.coroutines/-dispatchers/-i-o.html`. |

| Returns |
|---|---|
| `@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>` | List of discovered `https://developers.google.com/android/reference/com/google/mlkit/genai/agent/AgentTool` instances. |

### discover

```
public static final @NonNull List<@NonNull AgentTool> discover(
    @NonNull Context context,
    @NonNull List<@NonNull String> enabledAppFunctionIds,
    @NonNull CoroutineDispatcher coroutineDispatcher
)
```

Discovers functions declared with `@androidx.appfunctions.AppFunction` matching `https://developers.google.com/android/reference/com/google/mlkit/genai/agent/AppFunctionAgentTools#discover(android.content.Context,kotlin.collections.List,kotlinx.coroutines.CoroutineDispatcher)` for the given `https://developers.google.com/android/reference/com/google/mlkit/genai/agent/AppFunctionAgentTools#discover(android.content.Context,kotlin.collections.List,kotlinx.coroutines.CoroutineDispatcher)` and converts them into a list of `https://developers.google.com/android/reference/com/google/mlkit/genai/agent/AgentTool`s.

| Parameters |
|---|---|
| `@https://developer.android.com/reference/androidx/annotation/NonNull.html https://developer.android.com/reference/android/content/Context.html context` | The Android context. |
| `@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` | The AppFunction identifiers or method names to discover. |
| `@https://developer.android.com/reference/androidx/annotation/NonNull.html https://kotlin.github.io/kotlinx.coroutines/kotlinx-coroutines-core/kotlinx.coroutines/-coroutine-dispatcher/index.html coroutineDispatcher` | Dispatcher on which discovery executes. Defaults to `https://kotlin.github.io/kotlinx.coroutines/kotlinx-coroutines-core/kotlinx.coroutines/-dispatchers/-i-o.html`. |

| Returns |
|---|---|
| `@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>` | List of discovered `https://developers.google.com/android/reference/com/google/mlkit/genai/agent/AgentTool` instances. |

### discover

```
public static final @NonNull List<@NonNull AgentTool> discover(
    @NonNull Context context,
    @NonNull String functionId,
    @NonNull CoroutineDispatcher coroutineDispatcher
)
```

Discovers functions declared with `@androidx.appfunctions.AppFunction` matching `https://developers.google.com/android/reference/com/google/mlkit/genai/agent/AppFunctionAgentTools#discover(android.content.Context,kotlin.String,kotlinx.coroutines.CoroutineDispatcher)` for the given `https://developers.google.com/android/reference/com/google/mlkit/genai/agent/AppFunctionAgentTools#discover(android.content.Context,kotlin.String,kotlinx.coroutines.CoroutineDispatcher)` and converts them into a list of `https://developers.google.com/android/reference/com/google/mlkit/genai/agent/AgentTool`s.

| Parameters |
|---|---|
| `@https://developer.android.com/reference/androidx/annotation/NonNull.html https://developer.android.com/reference/android/content/Context.html context` | The Android context. |
| `@https://developer.android.com/reference/androidx/annotation/NonNull.html https://developer.android.com/reference/java/lang/String.html functionId` | The AppFunction identifier (e.g., `"com.example.MyService#createNote"`) or method name (e.g., `"createNote"`). |
| `@https://developer.android.com/reference/androidx/annotation/NonNull.html https://kotlin.github.io/kotlinx.coroutines/kotlinx-coroutines-core/kotlinx.coroutines/-coroutine-dispatcher/index.html coroutineDispatcher` | Dispatcher on which discovery executes. Defaults to `https://kotlin.github.io/kotlinx.coroutines/kotlinx-coroutines-core/kotlinx.coroutines/-dispatchers/-i-o.html`. |

| Returns |
|---|---|
| `@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>` | List of discovered `https://developers.google.com/android/reference/com/google/mlkit/genai/agent/AgentTool` instances. |