2025-09-09 16:52:33 -07:00
|
|
|
use crate::protocol::EventMsg;
|
2025-09-10 10:17:24 -07:00
|
|
|
use crate::protocol::RolloutItem;
|
2025-09-03 10:37:07 -07:00
|
|
|
use codex_protocol::models::ResponseItem;
|
|
|
|
|
|
2025-09-09 16:52:33 -07:00
|
|
|
/// Whether a rollout `item` should be persisted in rollout files.
|
|
|
|
|
#[inline]
|
|
|
|
|
pub(crate) fn is_persisted_response_item(item: &RolloutItem) -> bool {
|
|
|
|
|
match item {
|
|
|
|
|
RolloutItem::ResponseItem(item) => should_persist_response_item(item),
|
|
|
|
|
RolloutItem::EventMsg(ev) => should_persist_event_msg(ev),
|
|
|
|
|
// Always persist session meta
|
|
|
|
|
RolloutItem::SessionMeta(_) => true,
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2025-09-03 10:37:07 -07:00
|
|
|
/// Whether a `ResponseItem` should be persisted in rollout files.
|
|
|
|
|
#[inline]
|
2025-09-09 16:52:33 -07:00
|
|
|
pub(crate) fn should_persist_response_item(item: &ResponseItem) -> bool {
|
2025-09-03 10:37:07 -07:00
|
|
|
match item {
|
|
|
|
|
ResponseItem::Message { .. }
|
|
|
|
|
| ResponseItem::Reasoning { .. }
|
|
|
|
|
| ResponseItem::LocalShellCall { .. }
|
|
|
|
|
| ResponseItem::FunctionCall { .. }
|
|
|
|
|
| ResponseItem::FunctionCallOutput { .. }
|
|
|
|
|
| ResponseItem::CustomToolCall { .. }
|
|
|
|
|
| ResponseItem::CustomToolCallOutput { .. } => true,
|
|
|
|
|
ResponseItem::WebSearchCall { .. } | ResponseItem::Other => false,
|
|
|
|
|
}
|
|
|
|
|
}
|
2025-09-09 16:52:33 -07:00
|
|
|
|
|
|
|
|
/// Whether an `EventMsg` should be persisted in rollout files.
|
|
|
|
|
#[inline]
|
|
|
|
|
pub(crate) fn should_persist_event_msg(ev: &EventMsg) -> bool {
|
|
|
|
|
match ev {
|
|
|
|
|
EventMsg::UserMessage(_)
|
|
|
|
|
| EventMsg::AgentMessage(_)
|
|
|
|
|
| EventMsg::AgentReasoning(_)
|
|
|
|
|
| EventMsg::AgentReasoningRawContent(_)
|
|
|
|
|
| EventMsg::TokenCount(_) => true,
|
|
|
|
|
EventMsg::Error(_)
|
|
|
|
|
| EventMsg::TaskStarted(_)
|
|
|
|
|
| EventMsg::TaskComplete(_)
|
|
|
|
|
| EventMsg::AgentMessageDelta(_)
|
|
|
|
|
| EventMsg::AgentReasoningDelta(_)
|
|
|
|
|
| EventMsg::AgentReasoningRawContentDelta(_)
|
|
|
|
|
| EventMsg::AgentReasoningSectionBreak(_)
|
|
|
|
|
| EventMsg::SessionConfigured(_)
|
|
|
|
|
| EventMsg::McpToolCallBegin(_)
|
|
|
|
|
| EventMsg::McpToolCallEnd(_)
|
|
|
|
|
| EventMsg::WebSearchBegin(_)
|
|
|
|
|
| EventMsg::WebSearchEnd(_)
|
|
|
|
|
| EventMsg::ExecCommandBegin(_)
|
|
|
|
|
| EventMsg::ExecCommandOutputDelta(_)
|
|
|
|
|
| EventMsg::ExecCommandEnd(_)
|
|
|
|
|
| EventMsg::ExecApprovalRequest(_)
|
|
|
|
|
| EventMsg::ApplyPatchApprovalRequest(_)
|
|
|
|
|
| EventMsg::BackgroundEvent(_)
|
|
|
|
|
| EventMsg::StreamError(_)
|
|
|
|
|
| EventMsg::PatchApplyBegin(_)
|
|
|
|
|
| EventMsg::PatchApplyEnd(_)
|
|
|
|
|
| EventMsg::TurnDiff(_)
|
|
|
|
|
| EventMsg::GetHistoryEntryResponse(_)
|
|
|
|
|
| EventMsg::McpListToolsResponse(_)
|
|
|
|
|
| EventMsg::ListCustomPromptsResponse(_)
|
|
|
|
|
| EventMsg::PlanUpdate(_)
|
|
|
|
|
| EventMsg::TurnAborted(_)
|
|
|
|
|
| EventMsg::ShutdownComplete
|
|
|
|
|
| EventMsg::ConversationHistory(_) => false,
|
|
|
|
|
}
|
|
|
|
|
}
|