Stabilize thread resume and memory dual-write tests (#47817)

Wait for an assistant item to start before resuming a running paginated
thread, ensuring the user message has reached live history. Emit the initial
response events before the gate and keep completion gated during resume.

Increase the memory dual-write test's consolidation timeout from 10 to 60
seconds to allow Git workspace and agent process startup under contention
on Windows CI runners.

GitOrigin-RevId: 4d74d04955c88a9c208a809f639fe14fdb2ebf37
This commit is contained in:
jif
2026-09-24 11:10:14 +00:00
committed by copyberry
parent 869b5527cd
commit 16b20547f6
2 changed files with 22 additions and 10 deletions
@@ -5147,14 +5147,22 @@ async fn thread_resume_rejoins_running_paginated_thread_with_initial_page() -> R
responses::ev_completed("resp-1"),
]),
}],
vec![StreamingSseChunk {
gate: Some(running_turn_gate),
body: responses::sse(vec![
responses::ev_response_created("resp-2"),
responses::ev_assistant_message("msg-2", "Done"),
responses::ev_completed("resp-2"),
]),
}],
vec![
StreamingSseChunk {
gate: None,
body: responses::sse(vec![
responses::ev_response_created("resp-2"),
responses::ev_message_item_added("msg-2", ""),
]),
},
StreamingSseChunk {
gate: Some(running_turn_gate),
body: responses::sse(vec![
responses::ev_assistant_message("msg-2", "Done"),
responses::ev_completed("resp-2"),
]),
},
],
])
.await;
let codex_home = TempDir::new()?;
@@ -5218,12 +5226,14 @@ async fn thread_resume_rejoins_running_paginated_thread_with_initial_page() -> R
primary.read_stream_until_notification_message("turn/started"),
)
.await??;
// An assistant item starts after the user message has reached live history.
// The gated remainder of the response keeps the turn running during resume.
timeout(DEFAULT_READ_TIMEOUT, async {
loop {
let started: ItemStartedNotification =
primary.read_notification("item/started").await?;
if started.turn_id == running_turn.id
&& matches!(started.item, ThreadItem::UserMessage { .. })
&& matches!(started.item, ThreadItem::AgentMessage { .. })
{
return Ok::<(), anyhow::Error>(());
}
@@ -61,7 +61,9 @@ async fn dual_write_extracts_and_consolidates_into_independent_stores() -> anyho
(MemoryVersion::V2, &v2_root, "", "v2 rollout"),
] {
let store = db.memories_for_version(version).await?;
let deadline = Instant::now() + Duration::from_secs(10);
// Both pipelines initialize Git workspaces and run consolidation agents.
// Allow for process startup under contention on Windows CI runners.
let deadline = Instant::now() + Duration::from_secs(60);
while store.max_consolidated_thread_count().await? == 0 {
anyhow::ensure!(
Instant::now() < deadline,