Skip to content

Commit b2aef35

Browse files
committed
test(agent): wait for both responses in the steer run-id mismatch test
steer_rejected_on_run_id_mismatch stopped reading when the prompt turn finished. The fake LLM can finish the turn before the agent handles the steer, so the rejected steer's response can arrive after the turn's response. The test then reported "run-id mismatch was not rejected" even though the agent rejected it. The test now reads until it has both responses, and it still requires the steer to fail with invalid_params. On a saturated 16-core host the unchanged test failed 15 of 400 runs; with this change it failed 0 of 400. Signed-off-by: Tee8z <[email protected]>
1 parent e3f8f9a commit b2aef35

1 file changed

Lines changed: 8 additions & 0 deletions

File tree

‎crates/buzz-agent/tests/fake_llm.rs‎

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -983,7 +983,10 @@ async fn steer_rejected_on_run_id_mismatch() {
983983
)
984984
.await;
985985

986+
// The fake turn can finish before the steer is handled, so the two
987+
// responses arrive in either order; wait for both.
986988
let mut saw_reject = false;
989+
let mut turn_done = false;
987990
for _ in 0..40 {
988991
let v = h.recv().await;
989992
if v["id"] == json!(s_id) {
@@ -994,10 +997,15 @@ async fn steer_rejected_on_run_id_mismatch() {
994997
saw_reject = true;
995998
} else if v["id"] == json!(p_id) {
996999
// Turn finishes normally regardless of the rejected steer.
1000+
assert_eq!(v["result"]["stopReason"], "end_turn");
1001+
turn_done = true;
1002+
}
1003+
if saw_reject && turn_done {
9971004
break;
9981005
}
9991006
}
10001007
assert!(saw_reject, "run-id mismatch was not rejected");
1008+
assert!(turn_done, "turn did not finish after the rejected steer");
10011009
h.shutdown().await;
10021010
}
10031011

0 commit comments

Comments
 (0)