Wait for subprocess replies in completed-tool replay regression

Co-Authored-By: Paperclip <noreply@paperclip.ing>
This commit is contained in:
DottaandPaperclip committed 2026-09-28 14:41:48 -05:00
1 parent 26dde3cfe9
commit 45e4eff874
1 file changed
+26 -13
@@ -850,16 +850,21 @@ fn codex_rejects_replay_of_a_completed_tool_call_id_in_the_same_turn() {
.start_turn("Inspect the fake task once.", &config.cwd)
.expect("start provider turn");
let first_call = (0..32)
.find_map(|_| match provider.poll().expect("poll first tool call") {
Some(CodexProviderEvent::ToolCall {
call_id,
operation_id,
..
}) => Some((call_id, operation_id)),
_ => None,
})
.expect("observe the first semantic tool call");
let first_call_deadline = std::time::Instant::now() + std::time::Duration::from_secs(5);
let first_call =
std::iter::from_fn(|| (std::time::Instant::now() < first_call_deadline).then_some(()))
.find_map(|_| match provider.poll().expect("poll first tool call") {
Some(CodexProviderEvent::ToolCall {
call_id,
operation_id,
..
}) => Some((call_id, operation_id)),
_ => {
std::thread::sleep(std::time::Duration::from_millis(1));
None
}
})
.expect("observe the first semantic tool call");
provider
.deliver_tool_result(&ToolResult {
call_id: first_call.0,
@@ -869,9 +874,17 @@ fn codex_rejects_replay_of_a_completed_tool_call_id_in_the_same_turn() {
})
.expect("deliver the first semantic result");
let replay_error = (0..32)
.find_map(|_| provider.poll().err())
.expect("same-turn replay of the completed call id is rejected");
let replay_deadline = std::time::Instant::now() + std::time::Duration::from_secs(5);
let replay_error =
std::iter::from_fn(|| (std::time::Instant::now() < replay_deadline).then_some(()))
.find_map(|_| {
let error = provider.poll().err();
if error.is_none() {
std::thread::sleep(std::time::Duration::from_millis(1));
}
error
})
.expect("same-turn replay of the completed call id is rejected");
assert!(
replay_error
.to_string()