loopd: a turn's speaker in the log, its number in SessionUpdated

Co-Authored-By: ornith-1.5-35b-a3b <agent@wntrmute.dev>
This commit is contained in:
2026-09-28 10:33:36 -07:00
co-authored by ornith-1.5-35b-a3b
parent c798714af1
commit 4866353ac9
10 changed files with 362 additions and 26 deletions
+7 -3
View File
@@ -113,19 +113,23 @@ fn map_event(event: &ChatEvent, on_event: &mut dyn FnMut(&TurnEvent)) {
}
}
/// One turn of `session`: `content` is the user's message, and `speaker` who spoke it, when one
/// person did. The speaker is logged on the `User` record, for `memoryd`, and never sent to the
/// model: the request is the same with a speaker and without one (M5c spec, section 11).
pub fn run_turn(
session: &mut Session,
rt: &Runtime<'_>,
content: &str,
speaker: Option<&str>,
on_event: &mut dyn FnMut(&TurnEvent),
) -> Result<TurnOutcome, TurnError> {
session
.append(LogRecord::User {
time: Timestamp::now(),
content: neutralise(content).into_owned(),
// Set in M5c-1 task 02, from the turn. `None` is not written: the record's bytes
// are as before.
speaker: None,
// As it came: not checked and not neutralised, since it never reaches the model.
// `None` is not written, so the record's bytes are as before M5c.
speaker: speaker.map(str::to_string),
})
.map_err(TurnError::Session)?;