mirror of
https://github.com/openai/codex.git
synced 2026-04-24 14:45:27 +00:00
progress
This commit is contained in:
@@ -587,25 +587,8 @@ impl Session {
|
||||
}
|
||||
}
|
||||
if !responses.is_empty() {
|
||||
self.record_conversation_items_internal(&responses, false)
|
||||
.await;
|
||||
self.record_conversation_items_internal(&responses, false).await;
|
||||
}
|
||||
|
||||
let mut msgs = Vec::new();
|
||||
for item in items {
|
||||
match item {
|
||||
RolloutItem::ResponseItem(responses) => msgs.extend(
|
||||
responses
|
||||
.iter()
|
||||
.flat_map(|ri| {
|
||||
map_response_item_to_event_messages(ri, self.show_raw_agent_reasoning)
|
||||
})
|
||||
.filter(|m| matches!(m, EventMsg::UserMessage(_))),
|
||||
),
|
||||
RolloutItem::Event(events) => msgs.extend(events.iter().map(|e| e.msg.clone())),
|
||||
}
|
||||
}
|
||||
msgs
|
||||
}
|
||||
|
||||
/// Sends the given event to the client and records it to the rollout (if enabled).
|
||||
|
||||
@@ -1,4 +1,6 @@
|
||||
use codex_protocol::models::ResponseItem;
|
||||
use codex_protocol::protocol::Event;
|
||||
use codex_protocol::protocol::EventMsg;
|
||||
|
||||
/// Whether a `ResponseItem` should be persisted in rollout files.
|
||||
#[inline]
|
||||
@@ -14,3 +16,42 @@ pub(crate) fn is_persisted_response_item(item: &ResponseItem) -> bool {
|
||||
ResponseItem::WebSearchCall { .. } | ResponseItem::Other => false,
|
||||
}
|
||||
}
|
||||
|
||||
pub(crate) fn is_persisted_event(event: &Event) -> bool {
|
||||
match event.msg {
|
||||
EventMsg::ExecApprovalRequest(_)
|
||||
| EventMsg::ApplyPatchApprovalRequest(_)
|
||||
| EventMsg::AgentReasoningDelta(_)
|
||||
| EventMsg::AgentReasoningRawContentDelta(_)
|
||||
| EventMsg::ExecCommandOutputDelta(_)
|
||||
| EventMsg::GetHistoryEntryResponse(_)
|
||||
| EventMsg::StreamError(_)
|
||||
| EventMsg::Error(_)
|
||||
| EventMsg::AgentMessageDelta(_)
|
||||
| EventMsg::SessionConfigured(_) => false,
|
||||
EventMsg::UserMessage(_)
|
||||
| EventMsg::AgentMessage(_)
|
||||
| EventMsg::AgentReasoning(_)
|
||||
| EventMsg::AgentReasoningRawContent(_)
|
||||
| EventMsg::TokenCount(_)
|
||||
| EventMsg::TaskStarted(_)
|
||||
| EventMsg::TaskComplete(_)
|
||||
| EventMsg::McpToolCallBegin(_)
|
||||
| EventMsg::McpToolCallEnd(_)
|
||||
| EventMsg::WebSearchBegin(_)
|
||||
| EventMsg::WebSearchEnd(_)
|
||||
| EventMsg::ExecCommandBegin(_)
|
||||
| EventMsg::ExecCommandEnd(_)
|
||||
| EventMsg::PatchApplyBegin(_)
|
||||
| EventMsg::PatchApplyEnd(_)
|
||||
| EventMsg::TurnDiff(_)
|
||||
| EventMsg::BackgroundEvent(_)
|
||||
| EventMsg::McpListToolsResponse(_)
|
||||
| EventMsg::ListCustomPromptsResponse(_)
|
||||
| EventMsg::ShutdownComplete
|
||||
| EventMsg::ConversationHistory(_)
|
||||
| EventMsg::PlanUpdate(_)
|
||||
| EventMsg::TurnAborted(_)
|
||||
| EventMsg::AgentReasoningSectionBreak(_) => true,
|
||||
}
|
||||
}
|
||||
|
||||
@@ -31,6 +31,7 @@ use crate::conversation_manager::InitialHistory;
|
||||
use crate::conversation_manager::ResumedHistory;
|
||||
use crate::git_info::GitInfo;
|
||||
use crate::git_info::collect_git_info;
|
||||
use crate::rollout::policy::is_persisted_event;
|
||||
use codex_protocol::models::ResponseItem;
|
||||
|
||||
#[derive(Serialize, Deserialize, Clone, Default)]
|
||||
@@ -215,8 +216,17 @@ impl RolloutRecorder {
|
||||
}
|
||||
|
||||
async fn record_event(&self, events: &[Event]) -> std::io::Result<()> {
|
||||
let mut filtered = Vec::new();
|
||||
for event in events {
|
||||
if is_persisted_event(event) {
|
||||
filtered.push(event.clone());
|
||||
}
|
||||
}
|
||||
if filtered.is_empty() {
|
||||
return Ok(());
|
||||
}
|
||||
self.tx
|
||||
.send(RolloutCmd::AddEvent(events.to_vec()))
|
||||
.send(RolloutCmd::AddEvent(filtered))
|
||||
.await
|
||||
.map_err(|e| IoError::other(format!("failed to queue rollout event: {e}")))
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user