> ## Documentation Index
> Fetch the complete documentation index at: https://docs.openlayer.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Session context retention

> Learn how to use the session context retention test to evaluate whether the assistant maintains context across turns

## Definition

The session context retention test evaluates whether the assistant **maintains and
correctly uses context** across the turns of a conversation. An LLM-as-a-judge reads
the full session and scores it against four criteria:

* Remembers facts and preferences established in prior turns
* Builds upon previously established context rather than starting fresh each turn
* Avoids asking for information the user has already provided
* Doesn't contradict information given earlier in the session

## Taxonomy

* **Task types**: LLM.
* **Availability**: development (Continuously evaluate your models and datasets as you iterate on their versions.)
  and monitoring (Monitor a model in production, measure its health, check for drifts and set up alerts.).
* **Evaluation level**: session.
* **Polarity**: higher score = better. `0` = no context retention, `1` = perfect
  context retention.

## Why it matters

* Context-retention failures are a primary driver of user frustration in multi-turn
  assistants — especially re-asking for information already supplied.

## Required columns

* **Input**: The user's message in each turn.
* **Output**: The assistant's response in each turn.
* **Session ID**: Groups turns belonging to the same conversation.
* **Timestamp**: Used to reconstruct turn order within a session.

> [!NOTE]
>
> This metric relies on an LLM evaluator. On Openlayer you can configure the
> underlying LLM used to compute it. Check out the
> [OpenAI](https://docs.openlayer.com/integrations/openai.md#openai-llm-evaluator) or
> [Anthropic](https://docs.openlayer.com/integrations/anthropic.md#anthropic-llm-evaluator) integration
> guides for details.

## Test configuration examples

```json Monitoring theme={null}
[
  {
    "name": "Session context retention above 0.7",
    "description": "Ensure the assistant maintains context across session turns",
    "type": "performance",
    "subtype": "sessionContextRetention",
    "thresholds": [
      {
        "insightName": "sessionContextRetention",
        "measurement": "meanScore",
        "operator": ">=",
        "value": 0.7
      }
    ],
    "subpopulationFilters": null,
    "mode": "monitoring",
    "usesProductionData": true,
    "evaluationWindow": 3600,
    "delayWindow": 0
  }
]
```

## Related

* [Session coherence](https://docs.openlayer.com/tests/catalog/session-coherence.md) — broader consistency signal.


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.