This commit is contained in:
Ahmed Ibrahim
2025-09-05 14:39:06 -07:00
parent 660327aa9c
commit a045ef05f2
2 changed files with 27 additions and 2 deletions

View File

@@ -4,6 +4,7 @@ use codex_core::ModelProviderInfo;
use codex_core::NewConversation;
use codex_core::WireApi;
use codex_core::built_in_model_providers;
use codex_core::protocol::AgentMessageEvent;
use codex_core::protocol::EventMsg;
use codex_core::protocol::InputItem;
use codex_core::protocol::Op;
@@ -159,6 +160,15 @@ async fn resume_includes_initial_messages_and_sends_prior_items() {
}],
};
writeln!(f, "{}", serde_json::to_string(&prior_item).unwrap()).unwrap();
let prior_item_event = EventMsg::AgentMessage(AgentMessageEvent {
message: "resumed assistant message".to_string(),
});
let prior_event_line = serde_json::json!({
"record_type": "event",
"id": "resume-1",
"msg": prior_item_event,
});
writeln!(f, "{prior_event_line}").unwrap();
drop(f);
// Mock server that will receive the resumed request

View File

@@ -100,6 +100,19 @@ async fn fork_conversation_twice_drops_to_first_message() {
}
out
}
async fn read_response_entries_with_retry(
path: &std::path::Path,
min_len: usize,
) -> Vec<ResponseItem> {
for _ in 0..50u32 {
let entries = read_response_entries(path).await;
if entries.len() >= min_len {
return entries;
}
tokio::time::sleep(tokio::time::Duration::from_millis(10)).await;
}
read_response_entries(path).await
}
let entries_after_three: Vec<ResponseItem> = read_response_entries(&base_path).await;
// History layout for this test:
// [0] user instructions,
@@ -147,7 +160,8 @@ async fn fork_conversation_twice_drops_to_first_message() {
}) => (*conversation_id, path.clone()),
_ => panic!("expected ConversationHistory event after first fork"),
};
let entries_after_first_fork: Vec<ResponseItem> = read_response_entries(&fork1_path).await;
let entries_after_first_fork: Vec<ResponseItem> =
read_response_entries_with_retry(&fork1_path, expected_after_first.len()).await;
assert_eq!(entries_after_first_fork, expected_after_first);
// Fork again with n=1 → drops the (new) last user message, leaving only the first.
@@ -171,6 +185,7 @@ async fn fork_conversation_twice_drops_to_first_message() {
}) => (*conversation_id, path.clone()),
_ => panic!("expected ConversationHistory event after second fork"),
};
let entries_after_second_fork: Vec<ResponseItem> = read_response_entries(&fork2_path).await;
let entries_after_second_fork: Vec<ResponseItem> =
read_response_entries_with_retry(&fork2_path, expected_after_second.len()).await;
assert_eq!(entries_after_second_fork, expected_after_second);
}