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

# Conversation retention

> Delete finished conversations a set number of days after their last activity: the organization's period, agents' own periods, the agent's files, and the values for Hybrid and Air-Gapped installs.

Conversation retention deletes finished conversations a set number of days after their last activity. A conversation is kept forever unless a period applies to it: the organization's, one its main account sets, its agent's own, or your self-hosted install's [default](#install-default).

A conversation and its sub-tasks are one unit. When a conversation is deleted, its messages, skill calls, sub-tasks and run history go with it. Files in Files and uploads are kept.

## Set the organization's period

1. Open [Policies](https://platform.xpander.ai/governance/policies) (**Platform > AI governance > Policies**).
2. Select the **Conversation retention** row.
3. Under **Delete conversations after**, choose **Keep forever**, **7 days**, **30 days**, **90 days**, **1 year** or **Custom** (1 to 3,650 days). Next to the option you pick, the card says how many conversations will be deleted at the next run.
4. Confirm. A change that deletes more (a shorter period, or a period where there was none) first opens **Delete conversations older than 30 days?** (with the period you picked). It says how many conversations the next run deletes, and when. Typed **Custom** days save when you press Enter or choose **Save**.

![Conversation retention card with 30 days selected, the pinned and shared switch, Agents can set their own period, Also delete the agent's files for the conversation, Agents that override, Applies to and Next run](https://mintcdn.com/xpanderai-099931d1/31wsg5Kv-nhQs3a1/images/run/conversation-retention/conversation-retention-card.png?fit=max\&auto=format\&n=31wsg5Kv-nhQs3a1\&q=85\&s=75540da646a8e435af05c564e5200c9f)

The Conversation retention card with a 30-day period. Shown with sample data.

Deletion runs every night at 02:30 UTC. The card shows it as **Next run**, in your own time.

Changing the setting needs a role that may edit policies. Each change is written to the [Audit log](https://platform.xpander.ai/governance/audit) with who made it. A nightly run that deleted something writes one entry with counts, never content. A night with nothing to delete writes no entry.

## What is kept

* **Pinned and shared conversations.** Kept by default, including conversations in a [shared session](https://docs.xpander.ai/use/agents/shared-sessions.md). Turn on **Also delete pinned and shared conversations** to delete them with the rest. xpander asks you to confirm first (**Delete pinned and shared conversations too?**).
* **Running conversations.** A conversation that is running, waiting or paused is never deleted. Its age counts from its last activity, so a conversation someone keeps using is never due.
* **Files.** Files in Files and uploads are kept. The folder an agent worked in for the conversation is deleted with it only when you turn on [the agent's files](#agent-files).
* **Everything outside the conversation:** usage, credits and invoices, LLM Gateway request records (they follow [Request retention](#conversation-retention-or-request-retention)), the audit log, memories, agents and schedules.

## Conversation retention or request retention?

Both settings are on [Policies](https://docs.xpander.ai/run/llm-gateway/policies.md). They delete different things and never touch each other's data.

| | Conversation retention | [Request retention](https://docs.xpander.ai/run/llm-gateway/policies.md#request-retention) |
| - | - | - |
| **What it deletes** | Finished conversations with every turn and sub-task: the history people see in chat and in task lists | [Request records](https://docs.xpander.ai/run/llm-gateway/requests-and-costs.md): one per model call (model, tokens, cost) and its saved prompt and response text |
| **Counted from** | The conversation's last activity | When the request was made |
| **Default** | **Keep forever**, or your install's default | 90 days on xpander cloud, no limit on a self-hosted install |
| **Runs** | Nightly at 02:30 UTC | Every hour |

For example, with conversations at 30 days and requests at 1 year, a conversation from February is gone from the history in March. Its model calls still show in [Requests](https://docs.xpander.ai/run/llm-gateway/requests-and-costs.md) until next February. The reverse also holds: a conversation kept forever can show model calls whose request records were deleted after 90 days.

## Override the period for one agent

An agent can keep its conversations for a shorter or a longer time than the organization, or forever. In the agent's settings, open **Advanced > Retention** and choose:

| Choice | Effect |
| - | - |
| **Follow organization** | The default. The agent uses the organization's period. |
| **Custom for this agent** | The agent's own number of days. |
| **Keep forever** | The agent's conversations are never deleted. |

In the agent's settings, a person whose role may not edit policies can pick at most the organization's period. A pick that deletes more asks to confirm first.

The **Conversation retention** card lists every agent with its own period under **Agents that override**. An agent with its own period deletes on that period even while the organization is on **Keep forever**.

## Let agents set their own period

**Agents can set their own period** is on by default, so the choices above apply. Turn it off when one period must apply to every agent:

* Every agent follows the organization's period, including agents set to **Keep forever**.
* The periods agents saved are kept, not cleared. **Agents that override** lists them as **Not applied**, and they apply again if you turn the switch back on.
* In the agent's settings, **Custom for this agent** and **Keep forever** can't be picked, and a saved period shows as **(saved: 7 days, not applied)**. The note says **Your organization applies one period to every agent.** and who can change it. **Clear the saved period** removes the agent's own period, so it follows the organization when the switch is back on.

xpander asks you to confirm when the switch change deletes more:

* Turning it off while an agent keeps conversations longer than the organization opens **Apply one period to every agent?**. It says how many more conversations the next run deletes.
* Turning it on while an agent has a shorter period saved opens **Let agents set their own period?**. The next run deletes those agents' older conversations.

Otherwise the switch saves at once.

![Apply one period to every agent? dialog saying how many more conversations the next run deletes, with Turn off](https://mintcdn.com/xpanderai-099931d1/31wsg5Kv-nhQs3a1/images/run/conversation-retention/conversation-retention-agents-off-confirm.png?fit=max\&auto=format\&n=31wsg5Kv-nhQs3a1\&q=85\&s=df299513cb3a2fdb315889a1a20146c9)

Turning the switch off counts the conversations that agents with a longer period of their own lose at the next run. Shown with sample data.

![Agent Retention setting with Follow organization selected and Custom for this agent showing saved: 7 days, not applied](https://mintcdn.com/xpanderai-099931d1/31wsg5Kv-nhQs3a1/images/run/conversation-retention/conversation-retention-agent-off.png?fit=max\&auto=format\&n=31wsg5Kv-nhQs3a1\&q=85\&s=4ac7d4ff36184dc30eb1978ef532f3ba)

With the switch off, an agent's own saved period stays, and is not applied. Shown with sample data.

## Agent files

Agents that run on xpander's computers (Claude Code, Codex, OpenCode) keep a folder for each conversation on the agent's computer: plans, attachments, code checkouts and folders moved from a laptop. Without the switch below, that folder is cleared 14 days after the conversation's last activity. The agent's own session record for the conversation (its Claude Code or Codex transcript) stays on the agent's computer.

Turn on **Also delete the agent's files for the conversation** to delete them together with the conversation:

* **When:** at the nightly run, and when a person deletes a conversation themselves.
* **Removed:** the conversation's folder on the agent's computer and the agent's own session record of that conversation.
* **Kept:** shared folders, skills, files in Files and uploads, and every other conversation's folder.
* **Other agents:** agents that do not run on xpander's computers have no folder per conversation. The switch does not change anything for them.

Turning it on asks you to confirm (**Also delete the agent's files?**). Deleted folders cannot be restored. If the agent's computer is not running at the time, its folders are deleted once it is reachable again, within 30 days. After that, the 14-day clearing still removes the folder.

![Also delete the agent's files? dialog listing plans, attachments, code checkouts and folders moved from a laptop, with Delete files too](https://mintcdn.com/xpanderai-099931d1/31wsg5Kv-nhQs3a1/images/run/conversation-retention/conversation-retention-delete-files-confirm.png?fit=max\&auto=format\&n=31wsg5Kv-nhQs3a1\&q=85\&s=d08d691ca1380d617d555e055e8cc7e9)

Confirming the files switch: what goes with each deleted conversation, and what is kept. Shown with sample data.

The switch is set for the whole organization; an agent has no setting of its own for it. With it on, the **Retention** note of an agent that runs on xpander's computers says **The agent's files for each conversation are deleted with it.** Other agents keep saying **Files are kept.**

## Accounts

A main account can apply its period to its accounts under **Applies to**. An account's own period can then only be shorter: the shortest wins. When the main account's shorter period applies, the card shows a **Limited by** badge with the main account's name, and **This account's own** with the period the account set for itself.

Within one account, the period on the card is the default for its agents, not a maximum. An agent with its own period keeps it. To make one period apply to every agent, turn off [Agents can set their own period](#let-agents-set-their-own-period).

## What people see

In the last 7 days before its deletion date, a conversation in the list says when it goes, such as **deleted in 3 days** or **deleted tonight**. Narrow lists show **3d left** or **tonight**, with the full words on hover. While pinned and shared conversations are kept, the words are **may be deleted in 3 days**, because a teammate may have pinned or shared it. A running conversation, or one you pinned, says **kept** once its date has passed.

The conversations panel shows the period in a note at the top, such as **Conversations are deleted 30 days after their last activity. Pinned and shared ones are kept.** Filtered to one agent, it names that agent and its period.

A person can still delete their own conversation at any time, pinned or not. That delete removes it from every store at once, like the nightly run does, and with the files switch on, the agent's folder for it too.

## Cloud, Hybrid and Air-Gapped

The same setting applies on every deployment. Each install deletes what it stores.

* **xpander cloud:** xpander deletes the conversation from every store, and the agent's folder when the files switch is on.
* **Hybrid:** conversation content and the agents' computers are in your cluster, and your install deletes them there. Your install then reports the deleted conversation IDs to xpander cloud, which deletes the conversation list entries it keeps. Only IDs and counts leave your cluster, never content ([Calls that run through xpander cloud](https://docs.xpander.ai/resources/security-compliance/security-architecture-hybrid.md#calls-that-run-through-xpander-cloud)). If your install has not deleted a conversation a week past its cutoff, xpander cloud deletes its own list entry anyway.
* **Air-Gapped:** your install does everything inside the perimeter and never calls xpander. Each account in the install sets or inherits its own period.

### Self-hosted install values

These values control the nightly run on a self-hosted install. `enabled: false` and `dryRun: true` stop deletion whatever period is set in **Policies**. `defaultDays` applies only where no period is set; a period an admin picks in **Policies** wins over it.

`enabled` and `dryRun` came with Hybrid chart 0.22.8 and Air-Gapped chart 0.17.6. `defaultDays` and `defaultIncludePinned` need Hybrid chart 0.23.5 or later, or Air-Gapped chart 0.17.30 or later. An older chart ignores them without an error.

| Chart | Value | Default | Effect |
| - | - | - | - |
| Hybrid (`xpander`) | `conversations.retention.enabled` | `true` | `false` stops the nightly run on this install, and a person's Delete then removes only the conversation list entry. xpander cloud still deletes its list entries a week after the cutoff |
| Hybrid (`xpander`) | `conversations.retention.dryRun` | unset (deletes for real) | `true` records what would be deleted and deletes nothing |
| Hybrid (`xpander`) | `conversations.retention.defaultDays` | unset | The [install default](#install-default) period, 1 to 3650 days |
| Hybrid (`xpander`) | `conversations.retention.defaultIncludePinned` | `false` | `true` also deletes pinned and shared conversations under the install default |
| Air-Gapped (`xpander-airgap`) | `global.conversations.retention.enabled` | `true` | `false` stops the nightly run on this install, and a person's Delete then removes only the conversation list entry |
| Air-Gapped (`xpander-airgap`) | `global.conversations.retention.dryRun` | unset (deletes for real) | `true` records what would be deleted and deletes nothing |
| Air-Gapped (`xpander-airgap`) | `global.conversations.retention.defaultDays` | unset | The [install default](#install-default) period, 1 to 3650 days |
| Air-Gapped (`xpander-airgap`) | `global.conversations.retention.defaultIncludePinned` | `false` | `true` also deletes pinned and shared conversations under the install default |

With no period for the organization, its main account or any agent, and no `defaultDays`, the run deletes nothing for age. It still finishes deletes people already made.

### Install default

`defaultDays` gives a period to every organization that never picked one of its own and inherits none from a main account. It is a default, not a lock. Admins see it on the card, marked **install default**, with **Set by** saying **This install's default. Pick another option to set your own.** They can change it, including back to **Keep forever**. The Policies list shows it as **Conversations are kept for 90 days (install default)**.

```yaml theme={"dark"}
# Hybrid (xpander)
conversations:
  retention:
    defaultDays: 90
    defaultIncludePinned: false
---
# Air-Gapped (xpander-airgap)
global:
  conversations:
    retention:
      defaultDays: 90
      defaultIncludePinned: false
```

Write whole days from 1 to 3650 as a plain number. A value outside 1 to 3650 fails the install. A leading zero does not: YAML reads `030` as 24, and the install uses 24 days.

![Conversation retention card with 90 days install default selected and Set by: This install's default. Pick another option to set your own.](https://mintcdn.com/xpanderai-099931d1/31wsg5Kv-nhQs3a1/images/run/conversation-retention/conversation-retention-install-default.png?fit=max\&auto=format\&n=31wsg5Kv-nhQs3a1\&q=85\&s=75d7f9e4a3f2b9292e1cb22dde304e56)

An organization with no period of its own on an install whose default is 90 days. Shown with sample data.

> [!WARNING]
>
> On an install that already has history, the first nightly run after you set `defaultDays` deletes every conversation older than the default, in every organization with no period of its own. Check the count on the card first: pick the default's period, read the count in the confirm, then choose **Cancel**.
>
> A dry run is not a full rehearsal of the default. On Hybrid, the default is not written while `dryRun` is on, so the dry run does not count it. On Air-Gapped, the dry run's [Audit log](https://platform.xpander.ai/governance/audit) entry counts at most the first 500 conversations per organization. Remove `dryRun` when you are ready.

How the default behaves differs by install:

| | Hybrid | Air-Gapped |
| - | - | - |
| **How it applies** | Your install writes it into your organization's own setting at startup. It then applies everywhere the organization's conversations are kept, xpander cloud included. | Read live by the install. Nothing is written to the organizations. |
| **While `dryRun` is on** | Nothing is written. The default is written at the first start after you turn `dryRun` off. | The run only records what it would delete. |
| **Changing `defaultDays`** | An organization still on the install default moves to the new value at the next start. An organization whose admin picked a period keeps it. | Every organization still on the default follows the new value at the next upgrade. |
| **Removing `defaultDays`** | The organization keeps the period that was written. Change it on the card. | Organizations still on the default go back to **Keep forever**. |


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