Skip to main content
Threads are the core persistence unit in Aegra. Each thread represents a conversation with its own state, message history, and checkpoints. Runs execute within threads, and state is automatically persisted after each node execution.

Creating threads

A client-provided thread_id must be 1–255 non-blank characters. Omit the field (or send null) to let the server generate a UUID. Longer or blank values are rejected with 422 before they hit PostgreSQL’s btree key limit (~2704 bytes).

Thread status

Threads have a status that reflects their current state:
The snippets below assume you are inside an async def function with an initialized client — see the example above.

Getting thread state

The state contains the current values of all state fields, information about what nodes will execute next, and any pending interrupts.

Updating thread state

You can modify thread state directly, for example to inject data or correct values:

Checkpoint history

Every state change creates a checkpoint. You can browse the full history:

Get state at a specific checkpoint

This is useful for debugging, replaying, or branching conversations from a previous point.

Run from a specific checkpoint

Pass checkpoint_id (or the full checkpoint object) to start a run from an earlier checkpoint. input is optional: without it the run replays from that point, with it the run branches with new input.
If both are set, keys in checkpoint win over checkpoint_id. A checkpoint_id that is not a UUID returns 422.

Checkpoint durability

By default LangGraph writes a checkpoint after every step of a run, in the background. Set durability on a run to change when checkpoints are written:
exit writes one checkpoint per run instead of one per step, which suits high-volume runs that never use time travel or mid-run recovery. It has two costs:
  • With Redis workers, a run requeued after a worker crash or a shutdown drain starts over from the thread’s last checkpoint, so its steps run a second time. See worker architecture.
  • The thread history holds one checkpoint per run, so you cannot inspect or fork from the steps inside it. Interrupts still write a checkpoint, so human-in-the-loop resumes work.
checkpoint_during is the deprecated form of the same setting: true means async and false means exit. If both are sent, durability wins. Creating a cron accepts both fields and updating one accepts durability; the cron applies them to every run it fires. An unknown value returns 422. To change the default for runs that do not set a mode, set checkpointer.durability in aegra.json or the AEGRA_CHECKPOINT_DURABILITY environment variable. See the configuration reference.

Searching threads

Find threads by status or metadata:
limit accepts 1 through MAX_SEARCH_LIMIT (default 1000, matching LangGraph Platform). Omitted or null limit uses min(20, MAX_SEARCH_LIMIT). Values above the cap return 422.

Listing threads

Deleting threads

Deleting a thread cancels any active runs and removes all state, including the checkpoint history stored in the graph backend:

Thread TTL

Threads can expire automatically. Configure a server-wide default under checkpointer.ttl in aegra.json (or the AEGRA_THREAD_TTL environment variable) — see the configuration reference. A background sweep then applies each thread’s policy:
  • delete — the thread, its runs and crons, and all checkpoint data are removed.
  • keep_latest — checkpoint history is compacted down to the latest state; the thread stays usable and the TTL re-arms, so history is pruned periodically.
Individual threads can override the default at creation:
Expired threads can also be cleaned up immediately for the calling user:
Threads with pending or running runs are never expired mid-run — they are picked up on a later sweep once their runs settle. TTL applies to threads created after it is enabled; pre-existing threads are not backfilled.

Thread metadata

Threads automatically track metadata about their usage:
  • owner: User identity at creation time (mirrors user_id on the Thread object, which is used for access control)
  • assistant_id: Last assistant used
  • graph_id: Last graph executed
You can add your own metadata at creation or update time:

User isolation

When authentication is enabled, threads are automatically scoped to the authenticated user. Users can only see and interact with their own threads.