Skip to content

Commit 338c2c8

Browse files
authored
bug: fix flaky test (#4878)
Fix flaky test by warming up the tools
1 parent 4b0f5eb commit 338c2c8

File tree

1 file changed

+28
-1
lines changed

1 file changed

+28
-1
lines changed

codex-rs/core/tests/suite/tool_parallelism.rs

Lines changed: 28 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,16 @@ async fn read_file_tools_run_in_parallel() -> anyhow::Result<()> {
8383
let server = start_mock_server().await;
8484
let test = build_codex_with_test_tool(&server).await?;
8585

86+
let warmup_args = json!({
87+
"sleep_after_ms": 10,
88+
"barrier": {
89+
"id": "parallel-test-sync-warmup",
90+
"participants": 2,
91+
"timeout_ms": 1_000,
92+
}
93+
})
94+
.to_string();
95+
8696
let parallel_args = json!({
8797
"sleep_after_ms": 300,
8898
"barrier": {
@@ -93,6 +103,17 @@ async fn read_file_tools_run_in_parallel() -> anyhow::Result<()> {
93103
})
94104
.to_string();
95105

106+
let warmup_first = sse(vec![
107+
json!({"type": "response.created", "response": {"id": "resp-warm-1"}}),
108+
ev_function_call("warm-call-1", "test_sync_tool", &warmup_args),
109+
ev_function_call("warm-call-2", "test_sync_tool", &warmup_args),
110+
ev_completed("resp-warm-1"),
111+
]);
112+
let warmup_second = sse(vec![
113+
ev_assistant_message("warm-msg-1", "warmup complete"),
114+
ev_completed("resp-warm-2"),
115+
]);
116+
96117
let first_response = sse(vec![
97118
json!({"type": "response.created", "response": {"id": "resp-1"}}),
98119
ev_function_call("call-1", "test_sync_tool", &parallel_args),
@@ -103,7 +124,13 @@ async fn read_file_tools_run_in_parallel() -> anyhow::Result<()> {
103124
ev_assistant_message("msg-1", "done"),
104125
ev_completed("resp-2"),
105126
]);
106-
mount_sse_sequence(&server, vec![first_response, second_response]).await;
127+
mount_sse_sequence(
128+
&server,
129+
vec![warmup_first, warmup_second, first_response, second_response],
130+
)
131+
.await;
132+
133+
run_turn(&test, "warm up parallel tool").await?;
107134

108135
let duration = run_turn_and_measure(&test, "exercise sync tool").await?;
109136
assert_parallel_duration(duration);

0 commit comments

Comments
 (0)