Skip to content

steer_rejected_on_empty_prompt is flaky due to response-order race #4939

Description

@stevelr

Describe the bug
In desktop-v0.5.5, buzz-agent tests can intermittently fail with:

empty steer prompt was not rejected

The implementation in crates/buzz-agent/src/lib.rs::steer_session correctly rejects an empty prompt with INVALID_PARAMS.

The race is in crates/buzz-agent/tests/fake_llm.rs::steer_rejected_on_empty_prompt. Its receive loop stops when the concurrent session/prompt response arrives, even if the steer rejection response has not yet been read:

} else if v["id"] == json!(p_id) {
    break;
}

Suggested change: wait specifically for the steer response, as other tests do:

let v = h.recv_until(|v| v["id"] == json!(s_id)).await;
assert_eq!(v["error"]["code"], -32602);

This tests the intended behavior without depending on response ordering between the prompt and steer requests.

Expected behavior

It's a race condition, so it fails intermittently (3/10 times with --release -p fake_llm).
Expect tests to pass 100% of attempts.

Version and platform
0.5.5 on x86_64-linux

Additional info

I tried running the specific failing test

for i in {1..10}; do
    cargo test --release -p buzz-agent --test fake_llm steer_rejected_on_empty_prompt -- --exact || break
done

and it passed 10/10 times. so the. race condition depends on other parallel factors.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions