use crate::provider::{ContentPart, Message, Role};
pub(super) fn last_user_index(messages: &[Message]) -> Option<usize> {
messages
.iter()
.enumerate()
.rev()
.find(|(_, m)| matches!(m.role, Role::User))
.map(|(i, _)| i)
}
pub(super) fn build_reset_summary_message(summary: &str) -> Message {
Message {
role: Role::Assistant,
content: vec![ContentPart::Text {
text: format!(
"[CONTEXT RESET]\nEverything older than the current user turn was \
compressed into the summary below. Recent turns were \
intentionally discarded — call `session_recall` if you need \
a specific dropped detail.\n\n{summary}"
),
}],
}
}
#[cfg(test)]
mod tests;