# IMentorSessionManager interface

> The IMentorSessionManager interface of the global namespace: Manages the Agent Framework AgentSession for the current session. In Blazor Server: Scoped (one…

- URL: https://docs.mentoragent.net/api/global/imentorsessionmanager
- Verified with: MentorAgent 1.2.0
- Last updated: 2026-10-27
- Packages: Novior.MentorAgent

Manages the Agent Framework `AgentSession` for the current session. In Blazor Server: Scoped (one session per circuit/user). In Blazor WASM: Singleton (one session per tab). AgentSession is the container for the Agent Framework conversation history: we do not manage messages manually — the session handles that internally.

## Definition

Namespace: none, the global namespace. Package: `Novior.MentorAgent`.

`public interface IMentorSessionManager`

```shell
dotnet add package Novior.MentorAgent
```

## Methods

### `GetOrCreateSessionAsync`

`Task<AgentSession> GetOrCreateSessionAsync(AIAgent agent, CancellationToken ct = default)`

Returns the current session, creating it on first access.

### `ResetAsync`

`Task ResetAsync(AIAgent agent, CancellationToken ct = default)`

Resets the current session (starts a new conversation).

### `RestoreSessionAsync`

`Task RestoreSessionAsync(AIAgent agent, JsonElement serialized, CancellationToken ct = default)`

Restores a serialized session.

### `SerializeCurrentSessionAsync`

`Task<JsonElement?> SerializeCurrentSessionAsync(AIAgent agent)`

Serializes the current session for persistence (e.g. WASM localStorage).

## Events

### `OnSessionChanged`

`event Action? OnSessionChanged`

Event: the session has changed (reset or restore).

---

- Previous: [Declarative.ServiceCollectionExtensions](https://docs.mentoragent.net/api/novior-mentoragent-declarative/servicecollectionextensions.md)
- Next: [TeamMemberAttribute class](https://docs.mentoragent.net/api/global/teammemberattribute.md)
