mirror of
https://github.com/openai/codex.git
synced 2026-10-30 19:18:49 +00:00
add summary operation
This commit is contained in:
@@ -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");
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user