per-message context headers, memory notes, conversation continuity

conversations API path now injects per-message context headers with
live timestamps, room name, and memory notes. this replaces the
template variables in agent instructions which were frozen at
creation time.

memory notes (topical + recent backfill) loaded before each response
in the conversations path — was previously only in the legacy path.

context hint seeds new conversations with recent room history after
resets, so sol doesn't lose conversational continuity on sneeze.

tool call results now logged with preview + length for debugging.
reset_all() clears both in-memory and sqlite conversation state.
This commit is contained in:
2026-03-22 15:00:43 +00:00
parent 904ffa2d4d
commit 7bf9e25361
4 changed files with 170 additions and 29 deletions

View File

@@ -271,6 +271,29 @@ async fn handle_message(
let members = matrix_utils::room_member_names(&room).await;
let display_sender = sender_name.as_deref().unwrap_or(&sender);
// Build context hint for new conversations (last 50 messages for continuity)
let context_hint = if state.config.agents.use_conversations_api {
let conv_exists = state
.conversation_registry
.get_conversation_id(&room_id)
.await
.is_some();
if !conv_exists && !context.is_empty() {
let hint_messages: Vec<String> = context
.iter()
.rev()
.take(50)
.rev()
.map(|m| format!("{}: {}", m.sender, m.content))
.collect();
Some(hint_messages.join("\n"))
} else {
None
}
} else {
None
};
let response = if state.config.agents.use_conversations_api {
state
.responder
@@ -278,6 +301,7 @@ async fn handle_message(
&body,
display_sender,
&room_id,
&room_name,
is_dm,
is_spontaneous,
&state.mistral,
@@ -285,6 +309,7 @@ async fn handle_message(
&response_ctx,
&state.conversation_registry,
image_data_uri.as_deref(),
context_hint,
)
.await
} else {