Forking a Thread

Fork starts a fresh thread with almost no context. The old transcript stays on disk and is read only when needed.

view .md
for v0.9.57 · unchanged since v0.9.55
on this page
  1. Forking
  2. What the fork carries
  3. The transcript file
  4. Fork vs. compaction
  5. Provenance

Use Fork thread when a long conversation has filled the context window but you want to keep going. You get a fresh thread with almost no context. The old conversation is saved to a file, and the model reads parts of it only when it needs them.

Other options lose more: compaction summarizes old turns and drops detail, and a new thread starts with nothing. A fork costs about the same few tokens however long the old thread was.

Forking

  1. Press Ctrl+K and choose Fork thread.

  2. Choose how retrieval (RAG) should work in the new thread:

    Choice The fork's retrieval behaviour
    RAG per turn retrieve context before every turn
    First-turn RAG retrieve once, up front, then stay quiet
    RAG off no automatic retrieval (search tools still work)

    ↑↓ / j k choose, Esc cancels.

  3. Press Enter. The fork opens right away with a ⑃ Forked card at the top, and a toast confirms it.

You can't fork an empty thread, or while the agent is mid-turn. A toast tells you why.

What the fork carries

One message: the fork note. It shows as the ⑃ Forked card and tells the model it's a fork and where the old transcript is:

This conversation is a fork of an earlier one. Its full transcript is
saved at:
  ~/.agentty/threads/<parentId>.transcript.md
Read it with the `read` tool (or grep it) ONLY if you need earlier
context — don't read it pre-emptively.

The model always sees this note, so it knows the transcript exists. It only pays for the contents if it opens the file.

The transcript file

When you fork, agentty writes a readable Markdown copy of the old thread to ~/.agentty/threads/<parentId>.transcript.md, next to the thread files. It has ## user / ## assistant headers and the text, with each tool call shortened to one line. Tool output is left out, which keeps the file small and easy to grep.

The file has size limits, so even a huge thread gives a useful file:

  • 512 KB total, newest first. If the whole thread doesn't fit, the newest turns are kept and the oldest are replaced by a marker. The header still shows the real message count.
  • 16 KB per message, start and end kept. A huge pasted block is cut in the middle with a … bytes elided … marker.

The file is written atomically (temp file → fsync → rename), so a crash mid-fork can't leave it cut short.

The transcript is outside your workspace, so agentty lets the fork read that one file and nothing else in ~/.agentty/threads. That permission is restored whenever the fork is opened again: in a new session, from the thread list, over ACP or with agentty run --resume.

Fork vs. compaction

Both deal with a full context window, and they work together: you can fork a compacted thread, or compact a fork.

Compaction Fork
Thread same conversation new thread (records its parent)
Old context summary, kept in the window full text on disk, read when needed
Up-front token cost pays to summarize almost none (just the note)
Detail kept shortened to prose all of it, the transcript is word for word
Use it to keep one long thread going start clean without losing the past

Provenance

Forking doesn't change the original thread. The new thread records which thread it came from. Both are ordinary thread files under ~/.agentty/threads/ (see Threads & Persistence), and you can back up or delete either one on its own.