# AgentSession

# AgentSession


```
public interface AgentSession extends AutoCloseable
```

<br />

*** ** * ** ***

A scoped session handle representing an ongoing multi-turn conversational thread with an `AgentRunner`.

Encapsulates the `sessionId`, turn execution via `runAsync`, and session history lifecycle. Closing the session evicts its in-memory dialogue history.

## Summary

| ### Public methods |
|---|---|
| `abstract void` | `close()` Closes this session handle and asynchronously evicts its in-memory dialogue history. |
| `abstract void` | `delete()` Deletes this session's in-memory conversation history and cancels active turns. |
| `abstract @NonNull String` | `getSessionId()` The unique identifier tracking conversation history in memory for this session. |
| `abstract @NonNull Flow<@NonNull AgentEvent>` | `runAsync(@NonNull Content content)` Executes an interaction turn within this session using multimodal `Content`. |

## Public methods

### close

```
abstract void close()
```

Closes this session handle and asynchronously evicts its in-memory dialogue history.

Dialogue history cleanup is dispatched asynchronously in the background. If you require guaranteed synchronous eviction before immediately recreating a session with the same `sessionId`, invoke `delete` instead.

### delete

```
abstract void delete()
```

Deletes this session's in-memory conversation history and cancels active turns.

This suspending call synchronously completes in-memory and ADK history deletion before returning. Use this when you require guaranteed immediate history eviction before recreating a session with the same `sessionId`.

### getSessionId

```
abstract @NonNull String getSessionId()
```

The unique identifier tracking conversation history in memory for this session.

### runAsync

```
abstract @NonNull Flow<@NonNull AgentEvent> runAsync(@NonNull Content content)
```

Executes an interaction turn within this session using multimodal `Content`.

| Parameters |
|---|---|
| `@NonNull Content content` | The multimodal content (text, images, etc.). |

| Returns |
|---|---|
| `@NonNull Flow<@NonNull AgentEvent>` | A cold `Flow` of `AgentEvent`s emitted during execution. |