Skip to main content

Module session_title

Module session_title 

Source
Expand description

P4b (COMPOSABLE-HARNESS-DESIGN.md §5.2 “P4”, §1.6/§3.1 core.session.auto_title, catalog:150, D-9): auto-title / session summary — a small-model side-call that titles a session, mirroring crate::reduce::summarize’s plumbing exactly: an injectable trait (real implementations call out to a model; this crate’s own tests only ever inject deterministic fakes — no real network/model call anywhere in this crate, same posture as crate::reduce::summarize::SpanSummarizer), a fixed versioned prompt, and a “never blocks, never fails the caller” contract.

Small-model routing (D-9). Config::small_model (P4a) is “a knob a caller reads, not a routing loop this crate runs” — the same is true here: auto_title takes an already-constructed SessionTitler, and it is the CALLER’s job to have built that titler against config.small_model.clone().unwrap_or_else(|| config.model.clone()) (the D-9 main-model fallback) before installing it via crate::Agent::set_session_titler.

Persistence. The title TEXT this module produces is handed to crate::store::SessionStore::set_title (already existing, S14) by the caller — this module only produces the string; it never touches the filesystem itself.

Constants§

MAX_TITLE_CHARS
A produced title is trimmed and capped at this many characters — a runaway/uncooperative model response must not become an unreasonably long session name.
PROMPT_VERSION
The fixed, in-repo, VERSIONED titling prompt template (mirrors reduce::summarize::PROMPT_VERSION’s precedent — bump this any time render_prompt’s wording changes).

Traits§

SessionTitler
Injectable session-titling side-call (mirrors crate::reduce::summarize::SpanSummarizer exactly). Err — for any reason, including a caller-modeled timeout or budget exhaustion — means the caller must fall back to no title (or the session’s existing one); this call must never block or fail the surrounding session-save path.

Functions§

auto_title
Produce an auto-title for history via titler, or None if the side-call errors, returns empty text, or titler is unavailable. Trimmed and capped at MAX_TITLE_CHARS; never panics, never blocks longer than titler.title itself does.
render_prompt
Render the fixed prompt for titling transcript_preview.
render_transcript_preview
Render the first max_chars characters of the conversation (skipping the system prompt at index 0) as the titling input — bounded so a huge session doesn’t blow up the side-call’s own request size.