Skip to main content
LangSmith Self-Hosted supports automatic TTL and data retention for traces. Use this to comply with data privacy regulations or to reduce storage by automatically cleaning up old traces. Run rules and other qualifying actions can also extend a trace’s retention period automatically.
Self-hosted Enterprise customers: You can configure extended data retention at the workspace level through the UI. No environment variable changes are required. See Customize extended retention policy. The system-wide TTL configuration on this page is still supported.

TTL configuration precedence

LangSmith determines how long to keep a trace in two steps: which retention tier the trace belongs to, and what period applies to that tier. The workspace retention restriction overrides tier assignment for new traces and blocks new upgrades. When active, new traces use shortlived even if the project’s saved default is longlived. It does not change retention periods or existing trace expiration dates. When the workspace allows extended retention, LangSmith assigns the tier in this order, highest precedence first:
  1. Trace upgrade: A run rule or other qualifying action promotes an individual trace to longlived, overriding whatever tier would otherwise apply.
  2. Environment tier: The tier configured for the agent environment.
  3. Workspace default: New agent environments inherit this tier. Changing it affects new environments only unless you apply it to all existing environments.
  4. Organization default: Applies to workspaces with no default of their own.
  5. shortlived: The fallback when no default is set.
LangSmith then resolves the retention period for the assigned tier:
  • longlived: The project extended retention period (if set, see Project-level extended retention for self-hosted), otherwise the workspace extended retention period (if set through the UI), otherwise the longlived value from the Helm configuration. A Base project set in the UI has no period of its own. Accordingly, its upgraded traces use the workspace period unless a period was set on the project through the API.
  • shortlived: The shortlived value from the Helm configuration.
The Helm chart defaults to 14 days for shortlived and 400 days for longlived.

Requirements

Configure retention through Helm or environment variable settings:
  • Enabled: Enable or disable automatic data retention. When enabled, set your default organization and project TTL tiers through the UI (see data retention guide).
  • Retention periods: Set system-wide retention periods for shortlived and longlived traces. Once set, manage retention at the project level or set an organization-wide default for new projects.
  • Per-project extended retention: Available from v0.18.0 and disabled by default. Set config.ttl.perProjectRetention.enabled: true to enable it. It takes effect only when config.ttl.enabled is also true. It works on both ClickHouse and SmithDB installs. On SmithDB installs, the same flag also turns on the job that syncs project periods to SmithDB. See Project-level extended retention for self-hosted.
  • Extended retention periods (optional): Set the periods, in days, that users can choose for extended retention. See Choose the extended retention periods users can pick.
Helm

Choose the extended retention periods users can pick

Configurable extended retention periods require LangSmith v0.18.0 or later.
Set config.ttl.longlivedAllowedDays to the periods, in days, that users can choose for extended retention on workspaces and projects. Use it to offer periods that the default options do not include, for example 2 years:
Helm
With this configuration, users choose from 30, 90, 180, 365, 400, and 730 days:
  • The list values: 30, 90, 180, 365, and 730 days.
  • The longlived period: 400 days. LangSmith always offers it, also when it is not in the list.
The longlived period is the default, not a limit. Workspaces and projects without a period of their own use it, and users can choose list values longer than it. Without longlivedAllowedDays, users choose from 30, 60, 90, 120, 150, 180, 240, 300, 365, and 400 days, up to your longlived period, plus the longlived period itself. The list must follow these rules, or the Helm chart and LangSmith refuse it:
  • At most 10 values.
  • Each value is at least 14 days.
Each value needs its own blob storage lifecycle rule for its ttl_<N>d/ prefix. Without that rule, blob data under the prefix is never deleted. See Custom retention prefixes.

ClickHouse TTL cleanup job

As of version 0.11, a cron job runs on weekends to delete expired data that ClickHouse’s built-in TTL mechanism may not have cleaned up.
This job uses mutations (ALTER TABLE DELETE), which are expensive operations that can affect ClickHouse performance. Run them only during off-peak hours (nights and weekends). Testing with 1 concurrent active mutation (the default) did not produce significant CPU, memory, or latency increases.

Default schedule

By default, the cleanup job runs:
  • Saturday: 8pm and 10pm UTC.
  • Sunday: 12am, 2am, and 4am UTC.

Disabling the job

To disable the cleanup job entirely:

Configuring the schedule

Customize when the cleanup job runs by modifying the cron expressions:
To use a single cron schedule, set both CLICKHOUSE_TTL_CLEANUP_CRON_WEEKEND_EVENING and CLICKHOUSE_TTL_CLEANUP_CRON_WEEKEND_MORNING to the same value. Job locking prevents overlapping executions.

Configuring minimum expired rows per part

The job works through the tables one at a time. Within each table it scans the parts and deletes data from any part holding at least a minimum number of expired rows. This threshold balances efficiency and thoroughness:
  • Too low: The job scans entire parts to clear minimal data (inefficient).
  • Too high: The job skips parts with significant expired data.

Checking expired rows

Run this query to see expired rows per table part, then tune your minimum value:

Configuring maximum active mutations

Delete operations can take around 50 minutes for a 100 GB part. Increase concurrent mutations to speed up cleanup:
More concurrent DELETE operations can significantly slow inserts and reads. Increase this value only if you can tolerate slower insert and read latencies, and monitor the system after you do.

Emergency: Stopping running mutations

If you see latency spikes and need to stop a running mutation:
  1. Find active mutations:
    Find the mutation_id where the command column contains a DELETE statement.
  2. Kill the mutation:

Backups and data retention

If disk space does not decrease after the job runs, or keeps growing, backups may be the cause. Backup processes create filesystem hard links that prevent ClickHouse from releasing data. Check these directories inside your ClickHouse pod:
  • /var/lib/clickhouse/backup
  • /var/lib/clickhouse/shadow
If backups are present, copy them to external storage (for example, S3), then clear the directories. Disk space should start releasing within a few minutes.

Keep run statistics after traces expire

After traces expire, LangSmith keeps their run statistics, such as run counts, latency, and error rates, until the extended (longlived) retention period passes. LangSmith then removes the remaining stored data, and those run statistics are no longer available. For how LangSmith resolves the longlived period, see TTL configuration precedence.
This applies to SmithDB installations on LangSmith 0.18 (Helm chart 0.18.0 or later).
To keep run statistics available for longer, set SMITHDB_COMPACTION__EXPIRY_CYCLE__RETENTION_CLEANUP_BUFFER to a duration such as 30d or 720h. LangSmith waits this long past the longlived period before it removes the data. The default is 0s. For example, with the default 400-day longlived period and a 30d buffer, run statistics stay available for at least 430 days after LangSmith receives a trace.
Helm
If SmithDB runs as a single pod, set the variable under smithdb.single.deployment.extraEnv instead.