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 timerender_prompt’s wording changes).
Traits§
- Session
Titler - Injectable session-titling side-call (mirrors
crate::reduce::summarize::SpanSummarizerexactly).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
historyviatitler, orNoneif the side-call errors, returns empty text, ortitleris unavailable. Trimmed and capped atMAX_TITLE_CHARS; never panics, never blocks longer thantitler.titleitself does. - render_
prompt - Render the fixed prompt for titling
transcript_preview. - render_
transcript_ preview - Render the first
max_charscharacters 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.