# IMentorQueryEmbedding interface

> The embedding of the message MentorAgent is answering right now, computed once per turn.

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

Model routing, semantic tool filtering and memory relevance already share it. A host's [`IMentorRagSource`](https://docs.mentoragent.net/api/novior-mentoragent-rag/imentorragsource) is the fourth consumer of the same sentence and the only one outside the library, so it is offered here: ask for the vector instead of embedding the query again, and the turn makes one round trip instead of two.

```text title="Example"
public sealed class MyRagSource(IMentorQueryEmbedding query, IEmbeddingGenerator<string, Embedding<float>> embeddings)
    : IMentorRagSource
{
    public async Task<IReadOnlyList<MentorRagResult>> SearchAsync(string q, int maxResults, CancellationToken ct = default)
    {
        var vector = await query.GetAsync(q, embeddings, ct);   // free if something already embedded it
        return Search(vector, maxResults);
    }
}
```

Scoped: the vector belongs to the session that asked for it and is replaced by the next message. Registered by `AddMentorAgent()`; the generator you pass is the one used on a cache miss.

## Definition

Namespace: `Novior.MentorAgent.Rag`. Package: `Novior.MentorAgent`.

`public interface IMentorQueryEmbedding`

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

## Methods

### `GetAsync`

`Task<ReadOnlyMemory<float>> GetAsync(string text, IEmbeddingGenerator<string, Embedding<float>> generator, CancellationToken ct = default)`

Returns the vector for `text`, generating it only if it is not the one already computed for this turn. An empty text returns an empty vector without calling out.

---

- Previous: [MentorSessionContextPlacement enum](https://docs.mentoragent.net/api/novior-mentoragent-options/mentorsessioncontextplacement.md)
- Next: [IMentorRagSource interface](https://docs.mentoragent.net/api/novior-mentoragent-rag/imentorragsource.md)
