# com.google.mlkit.genai.agent

## Interfaces

|---|---|
| `https://developers.google.com/android/reference/kotlin/com/google/mlkit/genai/agent/AgentEvent` | Events emitted by the Agent during an execution session. |
| `https://developers.google.com/android/reference/kotlin/com/google/mlkit/genai/agent/AgentSession` | A scoped session handle representing an ongoing multi-turn conversational thread with an `https://developers.google.com/android/reference/kotlin/com/google/mlkit/genai/agent/AgentRunner`. |

## Classes

|---|---|
| `https://developers.google.com/android/reference/kotlin/com/google/mlkit/genai/agent/Agent` | Represents an AI Agent guided by system instructions and equipped with executable tools. |
| `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. |
| `https://developers.google.com/android/reference/kotlin/com/google/mlkit/genai/agent/AgentEvent.FunctionCall` | Emitted immediately before a function is invoked by the runner. |
| `https://developers.google.com/android/reference/kotlin/com/google/mlkit/genai/agent/AgentEvent.FunctionResponse` | Emitted immediately after a function invocation completes. |
| `https://developers.google.com/android/reference/kotlin/com/google/mlkit/genai/agent/AgentEvent.TextMessage` | The text message generated by the agent for the user. |
| `https://developers.google.com/android/reference/kotlin/com/google/mlkit/genai/agent/AgentRunner` | Manages agent execution sessions. |
| `https://developers.google.com/android/reference/kotlin/com/google/mlkit/genai/agent/AgentTool` | Base class for tools that the `https://developers.google.com/android/reference/kotlin/com/google/mlkit/genai/agent/Agent` can invoke automatically. |

## Objects

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

## Extension functions summary

|---|---|
| `https://kotlin.github.io/kotlinx.coroutines/kotlinx-coroutines-core/kotlinx.coroutines.flow/-flow/index.html<https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-string/index.html>` | `https://kotlin.github.io/kotlinx.coroutines/kotlinx-coroutines-core/kotlinx.coroutines.flow/-flow/index.html<https://developers.google.com/android/reference/kotlin/com/google/mlkit/genai/agent/AgentEvent>.https://developers.google.com/android/reference/kotlin/com/google/mlkit/genai/agent/package-summary#(kotlinx.coroutines.flow.Flow).textMessages()()` Filters and extracts completed text messages from non-partial `https://developers.google.com/android/reference/kotlin/com/google/mlkit/genai/agent/AgentEvent.TextMessage` events in this flow. |
| `https://kotlin.github.io/kotlinx.coroutines/kotlinx-coroutines-core/kotlinx.coroutines.flow/-flow/index.html<https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-string/index.html>` | `https://kotlin.github.io/kotlinx.coroutines/kotlinx-coroutines-core/kotlinx.coroutines.flow/-flow/index.html<https://developers.google.com/android/reference/kotlin/com/google/mlkit/genai/agent/AgentEvent>.https://developers.google.com/android/reference/kotlin/com/google/mlkit/genai/agent/package-summary#(kotlinx.coroutines.flow.Flow).textTokens()()` Filters and extracts streaming text token chunks from partial `https://developers.google.com/android/reference/kotlin/com/google/mlkit/genai/agent/AgentEvent.TextMessage` events in this flow. |

## Extension functions

### textMessages

```
fun Flow<AgentEvent>.textMessages(): Flow<String>
```

Filters and extracts completed text messages from non-partial `https://developers.google.com/android/reference/kotlin/com/google/mlkit/genai/agent/AgentEvent.TextMessage` events in this flow.

Convenience operator for standard text chat UIs or callers that display full text responses once generation finishes.

### textTokens

```
fun Flow<AgentEvent>.textTokens(): Flow<String>
```

Filters and extracts streaming text token chunks from partial `https://developers.google.com/android/reference/kotlin/com/google/mlkit/genai/agent/AgentEvent.TextMessage` events in this flow.

Convenience operator for standard text chat UIs (such as Jetpack Compose `Text`) that display incremental streaming text tokens as they arrive.