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

# Thread retention

> Automatically delete AI agent threads after a period of inactivity

<Info>
  Thread retention is an Enterprise feature, enabled per organization on
  request — [contact us](/support) to turn it on. Self-hosted Enterprise
  deployments set `LIGHTDASH_ENABLE_FEATURE_FLAGS=ai-thread-retention` — see
  [feature flag environment
  variables](/self-host/customize-deployment/environment-variables#feature-flags).
</Info>

By default, Lightdash keeps AI agent threads forever. Organizations with
compliance or privacy requirements can set a retention window instead:
threads with no activity for the configured period are automatically and
permanently deleted, once per hour.

Retention only applies to threads, never to your warehouse data, which stays
in your warehouse under your own policies.

## How retention works

Retention is configured in whole hours (presets from 1 hour to 90 days, or a
custom value), at two levels:

* **Organization default** — applies to every agent in the organization,
  including threads that aren't linked to an agent.
* **Per-agent window** — an agent can set a *shorter* window than the
  organization default, making the organization value the ceiling.

The clock is based on **inactivity**: a thread expires only when it has
had no new messages for the whole window, measured from its latest activity.

## What gets deleted

When a thread expires, everything derived from it is deleted with it:

* prompts, responses, tool calls and tool results, and reasoning
* share links (revoked)
* agent memories learned from the thread
* evaluation prompts that reference the thread (evaluation suites may
  shrink), and past evaluation runs' threads

Content created from threads, like saved charts and dashboards, is
stored independently and is not affected.

Deletion is permanent. When an admin lowers the organization window, Lightdash
shows how many threads across how many agents will be deleted before the
change is confirmed.

## What retention does not cover

The retention window applies to AI agent thread content stored by
Lightdash. Adjacent stores keep their own, separately bounded retention:

| Store                                           | Retention                                                                            |
| ----------------------------------------------- | ------------------------------------------------------------------------------------ |
| Slack messages                                  | Live in your Slack workspace and follow its retention — Lightdash cannot delete them |
| MCP tool calls                                  | 90 days                                                                              |
| Query history (compiled SQL and metric queries) | 32 days by default, configurable per instance                                        |
| Query results cache                             | Up to 1 day (up to 31 days for deep research)                                        |

## Configuring retention

**Organization default**: go to **Organization settings** → **Ask AI** →
**General** → **Thread retention**. Lowering the window (or setting one
where there was none) asks for confirmation and shows how many existing
threads will be deleted.

<Frame>
  <img className="block dark:hidden" src="https://mintcdn.com/lightdash/_tikN_XrfiiG95i9/images/agents/conversation-retention-org-light.png?fit=max&auto=format&n=_tikN_XrfiiG95i9&q=85&s=3917081e3fd8ec30ac2de1de643f1acb" alt="Conversation retention setting in the organization Ask AI settings" width="1972" height="872" data-path="images/agents/conversation-retention-org-light.png" />

  <img className="hidden dark:block" src="https://mintcdn.com/lightdash/_tikN_XrfiiG95i9/images/agents/conversation-retention-org-dark.png?fit=max&auto=format&n=_tikN_XrfiiG95i9&q=85&s=2e2f876315eae5e1293e1b8991be4f69" alt="Conversation retention setting in the organization Ask AI settings" width="1972" height="872" data-path="images/agents/conversation-retention-org-dark.png" />
</Frame>

**Per-agent window**: in the agent's settings under **Permissions** →
**Thread retention**. When an organization default exists, it caps the
values you can pick, and leaving the agent setting empty inherits the
organization default.

<Frame>
  <img className="block dark:hidden" src="https://mintcdn.com/lightdash/_tikN_XrfiiG95i9/images/agents/conversation-retention-agent-light.png?fit=max&auto=format&n=_tikN_XrfiiG95i9&q=85&s=285f379ca9b808fe8c734d9e49e0b62a" alt="Conversation retention setting in the agent's Permissions section" width="1834" height="1454" data-path="images/agents/conversation-retention-agent-light.png" />

  <img className="hidden dark:block" src="https://mintcdn.com/lightdash/_tikN_XrfiiG95i9/images/agents/conversation-retention-agent-dark.png?fit=max&auto=format&n=_tikN_XrfiiG95i9&q=85&s=de343544054a42b61d9c236099d3e43f" alt="Conversation retention setting in the agent's Permissions section" width="1834" height="1454" data-path="images/agents/conversation-retention-agent-dark.png" />
</Frame>

## Agents as code

Agents managed [as code](/agents/agents-as-code) can set the per-agent window
with the optional `threadRetentionHours` field:

* a number sets the window (validated against the organization ceiling)
* an explicit `null` clears the agent's window, inheriting the organization
  default
* omitting the field leaves the stored setting unchanged

Uploads into an organization where retention is not enabled ignore the field
and return a warning instead of failing, so agent configuration stays portable
across organizations.
