fix(compaction): context freeze preserved message must stay user-visible (#12692)

This commit is contained in:
Abhijay Jain
2026-10-15 10:17:32 +00:00
committed by GitHub
parent dd17bf2021
commit 716bb92ce7
2 changed files with 19 additions and 5 deletions
+6 -4
View File
@@ -31,12 +31,14 @@ pub struct SlashCommand<'a> {
pub fn messages_since_kickoff(conversation: &Conversation) -> Result<&[Message]> {
let messages = conversation.messages();
let is_kickoff = |msg: &Message| msg.role == rmcp::model::Role::User && !msg.is_tool_response();
let start = messages
.iter()
.rposition(|message| {
message.role == rmcp::model::Role::User
&& message.is_user_visible()
&& !message.is_tool_response()
.rposition(|msg| is_kickoff(msg) && msg.is_user_visible())
.or_else(|| {
messages
.iter()
.rposition(|msg| is_kickoff(msg) && msg.is_agent_visible())
})
.ok_or_else(|| anyhow!("state machine conversation has no kickoff message"))?;
Ok(&messages[start..])
+13 -1
View File
@@ -2209,7 +2209,19 @@ impl GooseAcpAgent {
warn!(session_id, ?error, "Failed to send mid-turn usage update");
}
}
Ok(_) => {}
Ok(crate::agents::AgentEvent::HistoryReplaced(_)) => {
if self.supports_goose_custom_notifications() {
cx.send_notification(GooseSessionNotification {
session_id: session_id.to_string(),
update: GooseSessionUpdate::StatusMessage(StatusMessageUpdate {
status: StatusMessage::Notice {
message: "Context compacted — earlier messages archived"
.to_string(),
},
}),
})?;
}
}
Err(error) => {
return Err(agent_client_protocol::Error::internal_error()
.data(format!("Error in agent response stream: {error}")));