---
title: Sessions with weft/thread
description: 'When you need weft/thread and what it adds over the stateless core: durable multi-turn sessions on disk, one writer, branching, compaction, approvals and pools.'
url: https://weftgo.dev/docs/sessions/
type: concept
sources:
  - weft/AGENTS.md:552-589 (block 8), 725-752 (thread rules T1–T5)
  - weft/README.md:570-787 (Sessions — weft/thread)
  - weft/thread/doc.go (package documentation)
  - weft/docs/adr/0011-thread-sessions.md
  - weft/docs/thread-operations.md
---

# Sessions with weft/thread

The core is stateless: a run takes a transcript in and gives one back, and storing it between runs is your job ([Continue a conversation](https://weftgo.dev/docs/guides/conversations/)). Package [`weft/thread`](https://pkg.go.dev/github.com/weftgo/weft@v0.20.2/thread) is the layer above it. A [session](https://weftgo.dev/docs/reference/glossary/#session) is a conversation stored as an append-only tree of entries in a backend, with one writer, turns that are durable step by step, and branching, compaction, approvals and child sessions built on the same tree.

Use `weft/thread` when a conversation must outlive the process, survive a crash mid-turn, or be read by another process while it is written. Stay with `weft.Messages` when each request carries its whole history and nothing needs to be durable.

What it adds over the core:

- **Durability.** The prompt is written to the storage before the run starts, each step's messages as they join the run, and a turn entry at the end. A crash loses at most the step in flight and the turn's closing entry: the prompt and every finished step are already stored (thread rule T4).
- **One writer.** A `Session` value is its session's only writer until it closes; a second writer gets `thread.ErrLocked` (T1, T2).
- **A tree, not a list.** You branch back, fork into a new session and label entries; nothing is rewritten or deleted in place.
- **Busy policies.** A message sent while a turn runs is queued, rejected, steered into the turn, interrupts it, or rolls it back, and every message accepted that way is written to the storage first.
- **Compaction, approvals and pools.** Long sessions are summarized without deleting anything, parked tool calls survive restarts, and child sessions run under a bound.

`weft/thread` is a package of the framework module, `github.com/weftgo/weft`, so it comes with `go get github.com/weftgo/weft@v0.20.2`. It is pre-1.0: its API and stored format may change between minor versions, each change recorded in the CHANGELOG.

## The pages

The section has thirteen pages: this one and the twelve below, in reading order.

1. [What is a session?](https://weftgo.dev/docs/sessions/overview/): the entry tree, one writer per session, and what is durable when.
2. [Store sessions: JSONL, SQLite or memory](https://weftgo.dev/docs/sessions/storage/): pick a backend, list and delete sessions, tail one live.
3. [Write your own thread.Storage](https://weftgo.dev/docs/sessions/custom-storage/): the five methods, the optional capabilities, and `threadtest`.
4. [Send turns and wait for them](https://weftgo.dev/docs/sessions/turns/): `Send`, `Wait`, events, outcomes and run options.
5. [What happens when you send while a turn runs?](https://weftgo.dev/docs/sessions/busy-and-steering/): the busy policies, receipts and `Steer`.
6. [Label, branch and fork a session](https://weftgo.dev/docs/sessions/tree/): navigate the tree, fork, titles and public ids.
7. [Keep long sessions inside the context window (compaction)](https://weftgo.dev/docs/sessions/compaction/): summaries that replace old entries in the context.
8. [Approvals in sessions](https://weftgo.dev/docs/sessions/approvals/): parked calls that survive restarts, grants and approvers.
9. [Sign approval decisions](https://weftgo.dev/docs/sessions/signed-approvals/): decisions that cross a process boundary.
10. [Run bounded child sessions with a pool](https://weftgo.dev/docs/sessions/pools/): delegation with receipts.
11. [Operate sessions in production](https://weftgo.dev/docs/sessions/operations/): backups, locks, shutdown and crash recovery.
12. [The session log format](https://weftgo.dev/docs/sessions/format/): every entry kind and its fields.

## See also

- [What is a session?](https://weftgo.dev/docs/sessions/overview/)
- [Continue a conversation](https://weftgo.dev/docs/guides/conversations/): multi-turn without `weft/thread`
- [`docs/thread-operations.md`](https://github.com/weftgo/weft/blob/v0.20.2/docs/thread-operations.md): the operator's page
- [Package thread on pkg.go.dev](https://pkg.go.dev/github.com/weftgo/weft@v0.20.2/thread)
