From d9d909e73f813637cc38b6860543c186751d860e Mon Sep 17 00:00:00 2001 From: Randall Hidajat <3333321+l2and@users.noreply.github.com> Date: Thu, 6 Nov 2025 08:44:11 -0800 Subject: [PATCH] Add per-thread TTL configuration Since v0.4.11, we have been able to configure per-thread TTLs but this was never documented. --- src/langsmith/configure-ttl.mdx | 21 ++++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) diff --git a/src/langsmith/configure-ttl.mdx b/src/langsmith/configure-ttl.mdx index 58ce028c33..6560a04d60 100644 --- a/src/langsmith/configure-ttl.mdx +++ b/src/langsmith/configure-ttl.mdx @@ -1,7 +1,9 @@ --- title: How to add TTLs to your application sidebarTitle: Add TTLs to your application + --- + **Prerequisites** This guide assumes familiarity with [LangSmith](/langsmith/home), [Persistence](/oss/langgraph/persistence), and [Cross-thread persistence](/oss/langgraph/persistence#memory-store) concepts. @@ -11,6 +13,8 @@ LangSmith persists both [checkpoints](/oss/langgraph/persistence#checkpoints) (t ## Configuring checkpoint TTL + + Checkpoints capture the state of conversation threads. Setting a TTL ensures old checkpoints and threads are automatically deleted. Add a `checkpointer.ttl` configuration to your `langgraph.json` file: @@ -22,7 +26,7 @@ Add a `checkpointer.ttl` configuration to your `langgraph.json` file: "agent": "./agent.py:graph" }, "checkpointer": { - "ttl": { + "ttl": {c "strategy": "delete", "sweep_interval_minutes": 60, "default_ttl": 43200 @@ -88,6 +92,21 @@ You can configure TTLs for both checkpoints and store items in the same `langgra } ``` +## Configuring Per-Thread TTL + +From `langgraph-api` [v0.4.11](https://docs.langchain.com/langsmith/agent-server-changelog#v0-4-11) you are now able to apply TTL configurations per-thread via thread updates. Here is an example: + +```python +thread = await client.threads.create( + ttl={ + "strategy": "delete", + "ttl": 43200 # 30 days in minutes + } +) +``` + + + ## Runtime overrides The default `store.ttl` settings from `langgraph.json` can be overridden at runtime by providing specific TTL values in SDK method calls like `get`, `put`, and `search`.