Autocompact + One Shot Summarization algorithm (#3559)
Co-authored-by: Michael Neale <michael.neale@gmail.com>
This commit is contained in:
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user