Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion codex-rs/core/src/session/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1134,7 +1134,7 @@ impl Session {
pub(crate) async fn route_realtime_text_input(self: &Arc<Self>, text: String) {
handlers::user_input_or_turn_inner(
self,
self.next_internal_sub_id(),
Uuid::now_v7().to_string(),
Op::UserInput {
items: vec![UserInput::Text {
text,
Expand Down
9 changes: 9 additions & 0 deletions codex-rs/core/tests/suite/realtime_conversation.rs
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ use std::sync::Mutex;
use std::time::Duration;
use tokio::sync::oneshot;
use tokio::time::timeout;
use uuid::Uuid;
use wiremock::Match;
use wiremock::Mock;
use wiremock::Request as WiremockRequest;
Expand Down Expand Up @@ -3019,6 +3020,14 @@ async fn inbound_handoff_request_starts_turn() -> Result<()> {
})
.await;

let turn_id = loop {
let event = test.codex.next_event().await?;
if let EventMsg::TurnStarted(turn_started) = event.msg {
break turn_started.turn_id;
Comment on lines +3023 to +3026

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Capture TurnStarted before it can be discarded

When the routed realtime turn wins the scheduling race, route_realtime_text_input can spawn the task and emit TurnStarted before the fanout sends the HandoffRequested realtime notification; the preceding wait_for_event_match then consumes and drops that TurnStarted, so this loop waits for a second one that never arrives and the test hangs. Capture the turn id in a single event-draining loop (or start waiting for TurnStarted before waiting for the handoff notification) so either event order passes.

Useful? React with 👍 / 👎.

}
};
Uuid::parse_str(&turn_id).context("realtime-routed turn ID should be a UUID")?;

wait_for_event(&test.codex, |event| {
matches!(event, EventMsg::TurnComplete(_))
})
Expand Down
Loading