add summary operation

This commit is contained in:
Ahmed Ibrahim
2025-07-10 19:37:50 -07:00
parent 9e58076cf5
commit 658d69e1a4
2 changed files with 27 additions and 0 deletions
+22
View File
@@ -782,6 +782,28 @@ async fn submission_loop(
}
});
}
Op::SummarizeContext => {
let sess = match sess.as_ref() {
Some(sess) => sess,
None => {
send_no_session_event(sub.id).await;
continue;
}
};
// Create a summarization request as user input
let summarization_prompt = vec![InputItem::Text {
text: "Please provide a summary of our conversation so far, highlighting key points, decisions made, and any important context that would be useful for future reference. This summary will be used to replace our conversation history with a more concise version so choose what details you will need to continue your work.".to_string(),
}];
// attempt to inject input into current task
if let Err(items) = sess.inject_input(summarization_prompt) {
// no current task, spawn a new one
let task = AgentTask::spawn(Arc::clone(sess), sub.id, items);
sess.set_task(task);
}
}
}
}
debug!("Agent loop exited");
+5
View File
@@ -108,6 +108,11 @@ pub enum Op {
/// Request a single history entry identified by `log_id` + `offset`.
GetHistoryEntryRequest { offset: usize, log_id: u64 },
/// Request the agent to summarize the current conversation context.
/// The agent will use its existing context (either conversation history or previous response id)
/// to generate a summary which will be returned as an AgentMessage event.
SummarizeContext,
}
/// Determines the conditions under which the user is consulted to approve