Skip to main content

build_session_title_prompt

Function build_session_title_prompt 

Source
pub fn build_session_title_prompt(
    current_title: &str,
    user_message: Option<&str>,
    activity: Option<&str>,
    word_target: u32,
) -> String
Expand description

Build the session-goal-title prompt, for the pane’s own request (session:activity_summary) and for the recovery sweep (tasks::generate_recovered_title).

What the model reads, each under its own label, so neither is mistaken for the other: the message the user just sent, the session’s recent activity, or both. An absent one is left out, not replaced by a stand-in sentence.

Two shapes, chosen by whether a USABLE current title exists. The caller passes an empty current_title for none, and also for a stored value that is not a real title (validate::is_usable_title), so a bad stored value is never fed back.

  • Create (no current title): there is no “Current title” line at all. A placeholder in the model’s input is a string the model can return: the first version wrote Current title: (none yet) and the model echoed it into the Swarm. Absence is represented by absence.
  • Maintain (a usable current title): the title is shown as data, and “no change” is SKIP, so the model never has to reproduce a string to say nothing changed.

docs/specs/SPEC_AMBIENT_SWARM_SUMMARY_HARDENING_2026_10_02.md section 5.2 and docs/specs/SPEC_AMBIENT_PANE_TITLE_OVERALL_GOAL_TRACKING_2026_08_17.md.