Navigation
Copy page

Manage Long Conversations

On this page

A long session fills the model's context window. kli summarizes older history to make room, on demand or automatically, and keeps the recent part of the conversation intact. Compact when you want, let kli compact on its own near the limit, and label a session so you can find it later.

Compact the session now

Run /compact to summarize the conversation's older history immediately:

/compact

kli runs one summarizer model call over everything except the most recent turns, replaces that history with a structured summary, and keeps the recent turns verbatim. The summary records the goal, constraints, progress, key decisions, next steps, and critical context (file paths, function names, error messages), so the agent continues from a checkpoint rather than from raw transcript.

Compact when the session is idle. If a turn is still running, the command reports that the session is busy; wait for the turn to finish and run it again. When there is nothing older than the recent window to summarize, /compact reports that there is nothing to compact.

Focus the summary

Pass a tail to /compact to add a focus line to the summarizer's instructions:

/compact keep the database migration details and drop the UI styling discussion

The focus rides along with the standard summary format. Use it when one thread of the conversation matters more than the rest and you want the summary to preserve it.

Let kli compact automatically

You do not have to run /compact yourself. At the end of each turn, kli checks token usage against the context window. When usage reaches a configured fraction of the model's context window, kli compacts on its own: it keeps the recent tokens and summarizes everything older, the same operation /compact performs.

Automatic compaction stays quiet when there is nothing older than the recent window to summarize. A manual /compact is the way to summarize before the threshold, for instance right before handing the session a large new task.

To see current usage at any time, run /session, which prints the active session's id, file, model, and token count.

Name the session

Run /name with a label to set the session's display name:

/name fourier-series refactor

The name is written to the session header and persists to disk, so it identifies the session in /resume and /branches listings. Run /name with no argument to print the current name, or report that none is set.

  • Sessions — what a session is and how it is stored
  • The Agent Loop — how a turn runs and when usage is measured
  • Session Commands — the full reference for /compact, /name, /session, /resume, and /rewind