Autocompact + One Shot Summarization algorithm (#3559)

Co-authored-by: Michael Neale <michael.neale@gmail.com>
This commit is contained in:
David Katz
2025-07-31 14:23:06 -04:00
committed by GitHub
parent b5e73c4c89
commit 6f36c1f81e
13 changed files with 1076 additions and 171 deletions
+14 -1
View File
@@ -159,8 +159,15 @@ async fn reply_handler(
retry_config: None,
};
// Messages will be auto-compacted in agent.reply() if needed
let messages_to_process = messages.clone();
let mut stream = match agent
.reply(&messages, Some(session_config), Some(task_cancel.clone()))
.reply(
&messages_to_process,
Some(session_config),
Some(task_cancel.clone()),
)
.await
{
Ok(stream) => stream,
@@ -215,6 +222,12 @@ async fn reply_handler(
break;
}
}
Ok(Some(Ok(AgentEvent::HistoryReplaced(new_messages)))) => {
// Replace the message history with the compacted messages
all_messages = new_messages;
// Note: We don't send this as a stream event since it's an internal operation
// The client will see the compaction notification message that was sent before this event
}
Ok(Some(Ok(AgentEvent::ModelChange { model, mode }))) => {
if let Err(e) = stream_event(MessageEvent::ModelChange { model, mode }, &tx).await {
tracing::error!("Error sending model change through channel: {}", e);