Skip to main content

Module title

Module title 

Source
Expand description

Session titles (W031): a bounded, one-shot titler and its sanitiser.

A session’s title is the semantic name a human finds it by — a short phrase (“fix flaky retry backoff”) that beats the opaque {millis}_{uuid8} file id and the first user line. It lives in the transcript, not the file name: crate::session::SessionEntry::Title, last write wins, read back by crate::session::Session::title.

§Who calls this module (and who reads it)

  • crate::loop_ — the auto-trigger (W031 D1, block-inline): at the turn boundary immediately after AgentEvent::TurnEnd is sent, when the session has no Title entry yet and title_after_turns assistant turns exist (D2), and at most once per run (the latch). It appends the entry through its own &mut Session and streams AgentEvent::SessionTitle.
  • The CLI’s config.rs reads DEFAULT_TITLE_AFTER_TURNS to resolve [session] title_after_turns, and main.rs reads COMPACTION_SUMMARY_PREFIX (re-exported from message) to keep the --resume picker from printing a compaction summary as a first user line.
  • NOTHING calls generate to rename explicitly: /rename and --title go straight to Agent::set_title and never touch a model.

So this module is a public surface with two external readers plus the loop — it is not private to the loop.

Re-exports§

pub use crate::message::COMPACTION_SUMMARY_PREFIX;

Constants§

DEFAULT_TITLE_AFTER_TURNS
Auto-title once this many assistant turns exist (W031 D2). 0 = never auto-title. The CLI’s [session] title_after_turns / WCODE_TITLE_AFTER_TURNS override it; absent config resolves to this.
TITLE_CLAMP
Hard cap on a produced title, in chars (not bytes). A title is a name, so it is a hard cut with no ellipsis — see sanitize.

Functions§

generate
Ask the model for a session title and return the sanitized result.
sanitize
Reduce a raw model answer to a storable title, or reject it.