session_core/
continuation.rs1use serde_json::{Value, json};
6use session_journal::repo::Metadata;
7
8pub const CONTINUATION: &str = "continuation";
10
11pub fn message(old: &Metadata, name: Option<&str>, timestamp: i64) -> Value {
13 let id = &old.id;
14 let named = name.map_or(String::new(), |name| format!(" (\"{name}\")"));
15 let content = format!(
16 "[continuation] This session continues session {id}{named}, last active {}. Its conversation is not in your \
17 context and was not summarized: when the user refers to earlier work, or you need a decision, path or result \
18 from it, look it up instead of guessing: `await sessions.search(\"regex\", sessions=[\"{id}\"])` (or \
19 `terms=[...]`) finds its turns, each hit with a `span`; `await sessions.read(span, around=5)` reads one; \
20 `await sessions.read(session=\"{id}\", limit=50)` reads it from the start.",
21 jsrt::date::iso_string(old.modified_at as i64)
22 );
23 json!({
24 "role": "custom",
25 "customType": CONTINUATION,
26 "content": content,
27 "display": true,
28 "details": {"session": id},
29 "timestamp": timestamp,
30 })
31}