Move sleep items to the extension-owned lifecycle path (#33159)

## What changed

- Define `SleepItem` in `codex-extension-items` and carry `clock.sleep` events through `TurnItem::Extension`.
- Preserve sleep persistence, thread-history reconstruction, and the app-server's `type: "sleep"` schema while reusing the extension-owned type.

## Testing

- Add serialization coverage for the `clock.sleep` extension wire shape and its protocol wrapper.
- Update sleep lifecycle and thread-history tests to exercise the extension-owned item.

GitOrigin-RevId: 34bb33ed9b90a09bf4744aafdb56e019c717a168
This commit is contained in:
pakrym-oai
2026-07-14 21:01:54 +00:00
committed by copyberry
parent 83a4187837
commit 5d325ba223
41 changed files with 141 additions and 55 deletions
+1
View File
@@ -3848,6 +3848,7 @@ version = "0.0.0"
dependencies = [
"anyhow",
"chrono",
"codex-extension-items",
"codex-file-search",
"codex-git-utils",
"codex-otel",
+2 -2
View File
@@ -410,7 +410,7 @@ impl TurnToolCounts {
| ThreadItem::Plan { .. }
| ThreadItem::Reasoning { .. }
| ThreadItem::ImageView { .. }
| ThreadItem::Sleep { .. }
| ThreadItem::Sleep(_)
| ThreadItem::EnteredReviewMode { .. }
| ThreadItem::ExitedReviewMode { .. }
| ThreadItem::ContextCompaction { .. } => return,
@@ -1747,7 +1747,7 @@ fn tracked_tool_item_id(item: &ThreadItem) -> Option<&str> {
| ThreadItem::Reasoning { .. }
| ThreadItem::SubAgentActivity { .. }
| ThreadItem::ImageView { .. }
| ThreadItem::Sleep { .. }
| ThreadItem::Sleep(_)
| ThreadItem::EnteredReviewMode { .. }
| ThreadItem::ExitedReviewMode { .. }
| ThreadItem::ContextCompaction { .. } => None,
@@ -4569,6 +4569,7 @@
"type": "object"
},
{
"description": "Display item emitted by the interruptible `clock.sleep` tool.",
"properties": {
"durationMs": {
"format": "uint64",
@@ -18648,6 +18648,7 @@
"type": "object"
},
{
"description": "Display item emitted by the interruptible `clock.sleep` tool.",
"properties": {
"durationMs": {
"format": "uint64",
@@ -16427,6 +16427,7 @@
"type": "object"
},
{
"description": "Display item emitted by the interruptible `clock.sleep` tool.",
"properties": {
"durationMs": {
"format": "uint64",
@@ -1152,6 +1152,7 @@
"type": "object"
},
{
"description": "Display item emitted by the interruptible `clock.sleep` tool.",
"properties": {
"durationMs": {
"format": "uint64",
@@ -1152,6 +1152,7 @@
"type": "object"
},
{
"description": "Display item emitted by the interruptible `clock.sleep` tool.",
"properties": {
"durationMs": {
"format": "uint64",
@@ -1297,6 +1297,7 @@
"type": "object"
},
{
"description": "Display item emitted by the interruptible `clock.sleep` tool.",
"properties": {
"durationMs": {
"format": "uint64",
@@ -1825,6 +1825,7 @@
"type": "object"
},
{
"description": "Display item emitted by the interruptible `clock.sleep` tool.",
"properties": {
"durationMs": {
"format": "uint64",
@@ -1616,6 +1616,7 @@
"type": "object"
},
{
"description": "Display item emitted by the interruptible `clock.sleep` tool.",
"properties": {
"durationMs": {
"format": "uint64",
@@ -1616,6 +1616,7 @@
"type": "object"
},
{
"description": "Display item emitted by the interruptible `clock.sleep` tool.",
"properties": {
"durationMs": {
"format": "uint64",
@@ -1616,6 +1616,7 @@
"type": "object"
},
{
"description": "Display item emitted by the interruptible `clock.sleep` tool.",
"properties": {
"durationMs": {
"format": "uint64",
@@ -1825,6 +1825,7 @@
"type": "object"
},
{
"description": "Display item emitted by the interruptible `clock.sleep` tool.",
"properties": {
"durationMs": {
"format": "uint64",
@@ -1616,6 +1616,7 @@
"type": "object"
},
{
"description": "Display item emitted by the interruptible `clock.sleep` tool.",
"properties": {
"durationMs": {
"format": "uint64",
@@ -1825,6 +1825,7 @@
"type": "object"
},
{
"description": "Display item emitted by the interruptible `clock.sleep` tool.",
"properties": {
"durationMs": {
"format": "uint64",
@@ -1616,6 +1616,7 @@
"type": "object"
},
{
"description": "Display item emitted by the interruptible `clock.sleep` tool.",
"properties": {
"durationMs": {
"format": "uint64",
@@ -1616,6 +1616,7 @@
"type": "object"
},
{
"description": "Display item emitted by the interruptible `clock.sleep` tool.",
"properties": {
"durationMs": {
"format": "uint64",
@@ -1297,6 +1297,7 @@
"type": "object"
},
{
"description": "Display item emitted by the interruptible `clock.sleep` tool.",
"properties": {
"durationMs": {
"format": "uint64",
@@ -1297,6 +1297,7 @@
"type": "object"
},
{
"description": "Display item emitted by the interruptible `clock.sleep` tool.",
"properties": {
"durationMs": {
"format": "uint64",
@@ -1297,6 +1297,7 @@
"type": "object"
},
{
"description": "Display item emitted by the interruptible `clock.sleep` tool.",
"properties": {
"durationMs": {
"format": "uint64",
@@ -0,0 +1,8 @@
// GENERATED CODE! DO NOT MODIFY BY HAND!
// This file was generated by [ts-rs](https://github.com/Aleph-Alpha/ts-rs). Do not edit this file manually.
/**
* Display item emitted by the interruptible `clock.sleep` tool.
*/
export type SleepItem = { id: string, durationMs: number, };
+1
View File
@@ -77,6 +77,7 @@ export type { ServerNotificationEnvelope } from "./ServerNotificationEnvelope";
export type { ServerRequest } from "./ServerRequest";
export type { SessionSource } from "./SessionSource";
export type { Settings } from "./Settings";
export type { SleepItem } from "./SleepItem";
export type { SubAgentSource } from "./SubAgentSource";
export type { ThreadId } from "./ThreadId";
export type { ThreadMemoryMode } from "./ThreadMemoryMode";
@@ -5,6 +5,7 @@ import type { ImageGenerationItem } from "../ImageGenerationItem";
import type { LegacyAppPathString } from "../LegacyAppPathString";
import type { MessagePhase } from "../MessagePhase";
import type { ReasoningEffort } from "../ReasoningEffort";
import type { SleepItem } from "../SleepItem";
import type { WebSearchItem } from "../WebSearchItem";
import type { JsonValue } from "../serde_json/JsonValue";
import type { CollabAgentState } from "./CollabAgentState";
@@ -105,4 +106,4 @@ reasoningEffort: ReasoningEffort | null,
/**
* Last known status of the target agents, when available.
*/
agentsStates: { [key in string]?: CollabAgentState }, } | { "type": "subAgentActivity", id: string, kind: SubAgentActivityKind, agentThreadId: string, agentPath: string, } | { "type": "webSearch" } & WebSearchItem | { "type": "imageView", id: string, path: LegacyAppPathString, } | { "type": "sleep", id: string, durationMs: number, } | { "type": "imageGeneration" } & ImageGenerationItem | { "type": "enteredReviewMode", id: string, review: string, } | { "type": "exitedReviewMode", id: string, review: string, } | { "type": "contextCompaction", id: string, };
agentsStates: { [key in string]?: CollabAgentState }, } | { "type": "subAgentActivity", id: string, kind: SubAgentActivityKind, agentThreadId: string, agentPath: string, } | { "type": "webSearch" } & WebSearchItem | { "type": "imageView", id: string, path: LegacyAppPathString, } | { "type": "sleep" } & SleepItem | { "type": "imageGeneration" } & ImageGenerationItem | { "type": "enteredReviewMode", id: string, review: string, } | { "type": "exitedReviewMode", id: string, review: string, } | { "type": "contextCompaction", id: string, };
@@ -599,8 +599,7 @@ impl ThreadHistoryBuilder {
);
let should_upsert = match item {
codex_protocol::items::TurnItem::Plan(plan) => !plan.text.is_empty(),
codex_protocol::items::TurnItem::Sleep(_)
| codex_protocol::items::TurnItem::HookPrompt(_)
codex_protocol::items::TurnItem::HookPrompt(_)
| codex_protocol::items::TurnItem::CommandExecution(_)
| codex_protocol::items::TurnItem::DynamicToolCall(_)
| codex_protocol::items::TurnItem::CollabAgentToolCall(_)
@@ -1588,6 +1587,7 @@ mod tests {
use super::*;
use crate::protocol::v2::CommandExecutionSource;
use codex_extension_items::ExtensionItem as CoreExtensionItem;
use codex_extension_items::sleep::SleepItem as CoreSleepItem;
use codex_protocol::ThreadId;
use codex_protocol::dynamic_tools::DynamicToolCallOutputContentItem as CoreDynamicToolCallOutputContentItem;
use codex_protocol::items::CommandExecutionItem as CoreCommandExecutionItem;
@@ -1595,7 +1595,6 @@ mod tests {
use codex_protocol::items::EnteredReviewModeItem as CoreEnteredReviewModeItem;
use codex_protocol::items::ExitedReviewModeItem as CoreExitedReviewModeItem;
use codex_protocol::items::HookPromptFragment as CoreHookPromptFragment;
use codex_protocol::items::SleepItem as CoreSleepItem;
use codex_protocol::items::TurnItem as CoreTurnItem;
use codex_protocol::items::UserMessageItem as CoreUserMessageItem;
use codex_protocol::items::build_hook_prompt_message;
@@ -1959,10 +1958,10 @@ mod tests {
fn rebuilds_sleep_item_from_persisted_completion() {
let turn_id = "turn-1";
let thread_id = ThreadId::new();
let sleep_item = CoreTurnItem::Sleep(CoreSleepItem {
let sleep_item = CoreTurnItem::Extension(CoreExtensionItem::Sleep(CoreSleepItem {
id: "sleep-1".to_string(),
duration_ms: 1_000,
});
}));
let events = vec![
EventMsg::TurnStarted(TurnStartedEvent {
turn_id: turn_id.to_string(),
@@ -1997,10 +1996,10 @@ mod tests {
assert_eq!(turns.len(), 1);
assert_eq!(
turns[0].items,
vec![ThreadItem::Sleep {
vec![ThreadItem::Sleep(CoreSleepItem {
id: "sleep-1".to_string(),
duration_ms: 1_000,
}]
})]
);
}
@@ -14,6 +14,7 @@ use crate::protocol::item_builders::review_output_text;
use codex_experimental_api_macros::ExperimentalApi;
use codex_extension_items::ExtensionItem;
pub use codex_extension_items::image_generation::ImageGenerationItem;
pub use codex_extension_items::sleep::SleepItem;
pub use codex_extension_items::web_search::WebSearchAction;
pub use codex_extension_items::web_search::WebSearchItem;
use codex_protocol::approvals::GuardianAssessmentAction as CoreGuardianAssessmentAction;
@@ -368,13 +369,7 @@ pub enum ThreadItem {
id: String,
path: LegacyAppPathString,
},
#[serde(rename_all = "camelCase")]
#[ts(rename_all = "camelCase")]
Sleep {
id: String,
#[ts(type = "number")]
duration_ms: u64,
},
Sleep(SleepItem),
ImageGeneration(ImageGenerationItem),
#[serde(rename_all = "camelCase")]
#[ts(rename_all = "camelCase")]
@@ -430,11 +425,11 @@ impl ThreadItem {
| ThreadItem::CollabAgentToolCall { id, .. }
| ThreadItem::SubAgentActivity { id, .. }
| ThreadItem::ImageView { id, .. }
| ThreadItem::Sleep { id, .. }
| ThreadItem::EnteredReviewMode { id, .. }
| ThreadItem::ExitedReviewMode { id, .. }
| ThreadItem::ContextCompaction { id, .. } => id,
ThreadItem::WebSearch(item) => &item.id,
ThreadItem::Sleep(item) => &item.id,
ThreadItem::ImageGeneration(item) => &item.id,
}
}
@@ -908,12 +903,9 @@ impl From<CoreTurnItem> for ThreadItem {
id: image.id,
path: image.path.into(),
},
CoreTurnItem::Sleep(sleep) => ThreadItem::Sleep {
id: sleep.id,
duration_ms: sleep.duration_ms,
},
CoreTurnItem::Extension(extension) => match extension {
ExtensionItem::ImageGeneration(item) => ThreadItem::ImageGeneration(item),
ExtensionItem::Sleep(item) => ThreadItem::Sleep(item),
ExtensionItem::WebSearch(item) => ThreadItem::WebSearch(item),
},
CoreTurnItem::ImageGeneration(image) => {
+5 -4
View File
@@ -7,6 +7,7 @@ use codex_app_server_protocol::ItemStartedNotification;
use codex_app_server_protocol::JSONRPCResponse;
use codex_app_server_protocol::RequestId;
use codex_app_server_protocol::ServerRequest;
use codex_app_server_protocol::SleepItem;
use codex_app_server_protocol::ThreadItem;
use codex_app_server_protocol::ThreadStartParams;
use codex_app_server_protocol::ThreadStartResponse;
@@ -112,10 +113,10 @@ async fn external_sleep_polls_current_time_and_emits_items() -> Result<()> {
)
.await??;
let expected_item = ThreadItem::Sleep {
let expected_item = ThreadItem::Sleep(SleepItem {
id: CALL_ID.to_string(),
duration_ms: DURATION_MS,
};
});
assert!(completed.completed_at_ms >= started.started_at_ms);
assert_eq!(
started,
@@ -151,7 +152,7 @@ async fn wait_for_sleep_started(
.await??;
let started: ItemStartedNotification =
serde_json::from_value(notification.params.expect("item/started params"))?;
if matches!(&started.item, ThreadItem::Sleep { id, .. } if id == call_id) {
if matches!(&started.item, ThreadItem::Sleep(item) if item.id == call_id) {
return Ok(started);
}
}
@@ -169,7 +170,7 @@ async fn wait_for_sleep_completed(
.await??;
let completed: ItemCompletedNotification =
serde_json::from_value(notification.params.expect("item/completed params"))?;
if matches!(&completed.item, ThreadItem::Sleep { id, .. } if id == call_id) {
if matches!(&completed.item, ThreadItem::Sleep(item) if item.id == call_id) {
return Ok(completed);
}
}
+1 -1
View File
@@ -37,6 +37,7 @@ codex-core-plugins = { workspace = true }
codex-core-skills = { workspace = true }
codex-exec-server = { workspace = true }
codex-extension-api = { workspace = true }
codex-extension-items = { workspace = true }
codex-features = { workspace = true }
codex-feedback = { workspace = true }
codex-file-system = { workspace = true }
@@ -134,7 +135,6 @@ openssl-sys = { workspace = true, features = ["vendored"] }
codex-shell-escalation = { workspace = true }
[dev-dependencies]
codex-extension-items = { workspace = true }
assert_cmd = { workspace = true }
assert_matches = { workspace = true }
codex-image-generation-extension = { workspace = true }
+4 -3
View File
@@ -6,7 +6,8 @@ use crate::tools::context::boxed_tool_output;
use crate::tools::handlers::parse_arguments;
use crate::tools::registry::CoreToolRuntime;
use crate::tools::registry::ToolExecutor;
use codex_protocol::items::SleepItem;
use codex_extension_items::ExtensionItem;
use codex_extension_items::sleep::SleepItem;
use codex_protocol::items::TurnItem;
use codex_tools::JsonSchema;
use codex_tools::ResponsesApiNamespace;
@@ -89,10 +90,10 @@ impl ToolExecutor<ToolInvocation> for SleepHandler {
}
let started = Instant::now();
let item = TurnItem::Sleep(SleepItem {
let item = TurnItem::Extension(ExtensionItem::Sleep(SleepItem {
id: call_id,
duration_ms: args.duration_ms,
});
}));
session.emit_turn_item_started(turn.as_ref(), &item).await;
let turn_state = session
.input_queue
+13 -6
View File
@@ -3,9 +3,10 @@ use std::sync::Arc;
use codex_core::CodexThread;
use codex_core::config::CurrentTimeReminderConfig;
use codex_extension_items::ExtensionItem;
use codex_extension_items::sleep::SleepItem;
use codex_features::Feature;
use codex_protocol::AgentPath;
use codex_protocol::items::SleepItem;
use codex_protocol::items::TurnItem;
use codex_protocol::models::PermissionProfile;
use codex_protocol::protocol::AskForApproval;
@@ -244,14 +245,17 @@ async fn wait_for_sleep_item_started(codex: &CodexThread, call_id: &str, duratio
matches!(
event,
EventMsg::ItemStarted(started)
if matches!(&started.item, TurnItem::Sleep(item) if item.id == call_id)
if matches!(
&started.item,
TurnItem::Extension(ExtensionItem::Sleep(item)) if item.id == call_id
)
)
})
.await;
let EventMsg::ItemStarted(started) = event else {
unreachable!("wait predicate only accepts item/started events");
};
let TurnItem::Sleep(item) = started.item else {
let TurnItem::Extension(ExtensionItem::Sleep(item)) = started.item else {
unreachable!("wait predicate only accepts sleep items");
};
assert_eq!(
@@ -268,14 +272,17 @@ async fn wait_for_sleep_item_completed(codex: &CodexThread, call_id: &str, durat
matches!(
event,
EventMsg::ItemCompleted(completed)
if matches!(&completed.item, TurnItem::Sleep(item) if item.id == call_id)
if matches!(
&completed.item,
TurnItem::Extension(ExtensionItem::Sleep(item)) if item.id == call_id
)
)
})
.await;
let EventMsg::ItemCompleted(completed) = event else {
unreachable!("wait predicate only accepts item/completed events");
};
let TurnItem::Sleep(item) = completed.item else {
let TurnItem::Extension(ExtensionItem::Sleep(item)) = completed.item else {
unreachable!("wait predicate only accepts sleep items");
};
assert_eq!(
@@ -442,7 +449,7 @@ async fn any_new_input_interrupts_sleep() {
.filter_map(|line| serde_json::from_str::<RolloutLine>(line).ok())
.filter_map(|line| match line.item {
RolloutItem::EventMsg(EventMsg::ItemCompleted(event)) => match event.item {
TurnItem::Sleep(item) => Some(item),
TurnItem::Extension(ExtensionItem::Sleep(item)) => Some(item),
_ => None,
},
_ => None,
+5
View File
@@ -9,6 +9,7 @@ use serde::Serialize;
use ts_rs::TS;
pub mod image_generation;
pub mod sleep;
pub mod web_search;
/// Canonical extension-owned turn item carried through core lifecycle events.
@@ -35,6 +36,9 @@ pub enum ExtensionItem {
#[serde(rename = "image_gen.generation")]
#[ts(rename = "image_gen.generation")]
ImageGeneration(image_generation::ImageGenerationItem),
#[serde(rename = "clock.sleep")]
#[ts(rename = "clock.sleep")]
Sleep(sleep::SleepItem),
#[serde(rename = "web.search")]
#[ts(rename = "web.search")]
WebSearch(web_search::WebSearchItem),
@@ -46,6 +50,7 @@ impl ExtensionItem {
pub fn id(&self) -> &str {
match self {
Self::ImageGeneration(item) => &item.id,
Self::Sleep(item) => &item.id,
Self::WebSearch(item) => &item.id,
}
}
+14
View File
@@ -0,0 +1,14 @@
use schemars::JsonSchema;
use serde::Deserialize;
use serde::Serialize;
use ts_rs::TS;
/// Display item emitted by the interruptible `clock.sleep` tool.
#[derive(Debug, Clone, Deserialize, Serialize, TS, JsonSchema, PartialEq, Eq)]
#[serde(rename_all = "camelCase")]
#[ts(rename_all = "camelCase")]
pub struct SleepItem {
pub id: String,
#[ts(type = "number")]
pub duration_ms: u64,
}
+23
View File
@@ -3,6 +3,7 @@ use serde_json::json;
use super::ExtensionItem;
use super::image_generation::ImageGenerationItem;
use super::sleep::SleepItem;
use super::web_search::WebSearchAction;
use super::web_search::WebSearchItem;
@@ -84,6 +85,28 @@ fn web_search_item_preserves_stable_wire_shape() {
);
}
#[test]
fn sleep_item_preserves_stable_wire_shape() {
let item = ExtensionItem::Sleep(SleepItem {
id: "sleep-1".to_string(),
duration_ms: 1_000,
});
let value = serde_json::to_value(&item).expect("serialize extension item");
assert_eq!(
value,
json!({
"kind": "clock.sleep",
"id": "sleep-1",
"durationMs": 1_000,
})
);
assert_eq!(
serde_json::from_value::<ExtensionItem>(value).expect("deserialize extension item"),
item
);
}
#[test]
fn unknown_extension_kind_is_rejected() {
let value = json!({
+22 -10
View File
@@ -57,11 +57,10 @@ pub enum TurnItem {
/// schema is owned by the web-search extension.
WebSearch(WebSearchItem),
ImageView(ImageViewItem),
Sleep(SleepItem),
/// Item whose schema and lifecycle details are owned by an extension.
///
/// Standalone image generation and web search use this path. App-server
/// wraps the same typed items in their public variants.
/// Standalone image generation, sleep, and web search use this path.
/// App-server wraps the same typed items in their public variants.
Extension(ExtensionItem),
/// Hosted Responses API image-generation item handled directly by core.
///
@@ -320,12 +319,6 @@ pub struct ImageViewItem {
pub path: PathUri,
}
#[derive(Debug, Clone, Deserialize, Serialize, TS, JsonSchema, PartialEq, Eq)]
pub struct SleepItem {
pub id: String,
pub duration_ms: u64,
}
#[derive(Debug, Clone, Deserialize, Serialize, TS, JsonSchema, PartialEq)]
pub struct ImageGenerationItem {
pub id: String,
@@ -645,7 +638,6 @@ impl TurnItem {
TurnItem::SubAgentActivity(item) => item.id.clone(),
TurnItem::WebSearch(item) => item.id.clone(),
TurnItem::ImageView(item) => item.id.clone(),
TurnItem::Sleep(item) => item.id.clone(),
TurnItem::Extension(item) => item.id().to_string(),
TurnItem::ImageGeneration(item) => item.id.clone(),
TurnItem::EnteredReviewMode(item) => item.id.clone(),
@@ -660,7 +652,27 @@ impl TurnItem {
#[cfg(test)]
mod tests {
use super::*;
use codex_extension_items::sleep::SleepItem;
use pretty_assertions::assert_eq;
use serde_json::json;
#[test]
fn sleep_extension_item_preserves_type_and_kind() {
let item = TurnItem::Extension(ExtensionItem::Sleep(SleepItem {
id: "sleep-1".to_string(),
duration_ms: 1_000,
}));
assert_eq!(
serde_json::to_value(item).expect("serialize sleep extension item"),
json!({
"type": "Extension",
"kind": "clock.sleep",
"id": "sleep-1",
"durationMs": 1_000,
})
);
}
#[test]
fn hook_prompt_roundtrips_multiple_fragments() {
-1
View File
@@ -516,7 +516,6 @@ impl TurnItem {
path: item.path.clone(),
})]
}
TurnItem::Sleep(_) => Vec::new(),
TurnItem::Extension(_) => Vec::new(),
TurnItem::ImageGeneration(item) => vec![item.as_legacy_event()],
TurnItem::EnteredReviewMode(_) | TurnItem::ExitedReviewMode(_) => Vec::new(),
+1
View File
@@ -15,6 +15,7 @@ workspace = true
[dependencies]
anyhow = { workspace = true }
chrono = { workspace = true, features = ["serde"] }
codex-extension-items = { workspace = true }
codex-file-search = { workspace = true }
codex-git-utils = { workspace = true }
codex-otel = { workspace = true }
@@ -255,7 +255,6 @@ fn turn_item_type(item: &TurnItem) -> &'static str {
TurnItem::SubAgentActivity(_) => "sub_agent_activity",
TurnItem::WebSearch(_) => "web_search",
TurnItem::ImageView(_) => "image_view",
TurnItem::Sleep(_) => "sleep",
TurnItem::Extension(_) => "extension",
TurnItem::ImageGeneration(_) => "image_generation",
TurnItem::EnteredReviewMode(_) => "entered_review_mode",
+5 -1
View File
@@ -1,5 +1,6 @@
use crate::protocol::EventMsg;
use crate::protocol::RolloutItem;
use codex_extension_items::ExtensionItem;
use codex_protocol::items::TurnItem;
use codex_protocol::models::ResponseItem;
use codex_protocol::protocol::ThreadHistoryMode;
@@ -89,7 +90,10 @@ pub fn should_persist_event_msg(ev: &EventMsg, history_mode: ThreadHistoryMode)
// Paginated rollouts store TurnItems.
// Legacy rollouts keep only items with no raw ResponseItem or legacy equivalent.
matches!(history_mode, ThreadHistoryMode::Paginated)
|| matches!(event.item, TurnItem::Plan(_) | TurnItem::Sleep(_))
|| matches!(
event.item,
TurnItem::Plan(_) | TurnItem::Extension(ExtensionItem::Sleep(_))
)
}
EventMsg::TokenCount(_)
| EventMsg::ThreadGoalUpdated(_)
@@ -329,7 +329,7 @@ WHERE thread_id = ? AND turn_id = ?
| ThreadItem::SubAgentActivity { .. }
| ThreadItem::WebSearch(_)
| ThreadItem::ImageView { .. }
| ThreadItem::Sleep { .. }
| ThreadItem::Sleep(_)
| ThreadItem::ImageGeneration(_)
| ThreadItem::EnteredReviewMode { .. }
| ThreadItem::ExitedReviewMode { .. }
+3 -3
View File
@@ -189,9 +189,9 @@ fn activity_summary(item: &ThreadItem) -> Option<String> {
ThreadItem::EnteredReviewMode { .. } => return Some("Entered review mode".to_string()),
ThreadItem::ExitedReviewMode { .. } => return Some("Exited review mode".to_string()),
ThreadItem::ContextCompaction { .. } => return Some("Compacted context".to_string()),
ThreadItem::UserMessage { .. }
| ThreadItem::HookPrompt { .. }
| ThreadItem::Sleep { .. } => return None,
ThreadItem::UserMessage { .. } | ThreadItem::HookPrompt { .. } | ThreadItem::Sleep(_) => {
return None;
}
};
bounded_summary(summary)
}
+1 -1
View File
@@ -199,7 +199,7 @@ impl ChatWidget {
}),
item @ ThreadItem::SubAgentActivity { .. } => self.on_sub_agent_activity(item),
ThreadItem::DynamicToolCall { .. } => {}
ThreadItem::Sleep { .. } => {}
ThreadItem::Sleep(_) => {}
}
if matches!(replay_kind, Some(ReplayKind::ThreadSnapshot)) && turn_id.is_empty() {
+1 -1
View File
@@ -230,7 +230,7 @@ fn fallback_transcript_cell(item: &ThreadItem) -> Option<PlainHistoryCell> {
| ThreadItem::AgentMessage { .. }
| ThreadItem::Plan { .. }
| ThreadItem::Reasoning { .. }
| ThreadItem::Sleep { .. } => return None,
| ThreadItem::Sleep(_) => return None,
};
(!lines.is_empty()).then(|| PlainHistoryCell::new(lines))
}