From 3d2a7ffec7cf927677620973a42741d25b070650 Mon Sep 17 00:00:00 2001 From: damocles Date: Sat, 16 May 2026 13:50:11 +0200 Subject: [PATCH] fix: auto-wake after turn if pending messages exist, don't block on recv --- hive-ag3nt/src/bin/hive-ag3nt.rs | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/hive-ag3nt/src/bin/hive-ag3nt.rs b/hive-ag3nt/src/bin/hive-ag3nt.rs index 2a8d8d8..65dd0a1 100644 --- a/hive-ag3nt/src/bin/hive-ag3nt.rs +++ b/hive-ag3nt/src/bin/hive-ag3nt.rs @@ -165,6 +165,15 @@ async fn serve( let outcome = turn::drive_turn(&prompt, files, &bus).await; turn::emit_turn_end(&bus, &outcome); bus.set_state(TurnState::Idle); + + // After turn completes, check if there are pending messages waiting. + // If so, immediately process them instead of blocking on recv(). + // This ensures messages queued during the turn are processed ASAP. + let pending = inbox_unread(socket).await; + if pending > 0 { + tracing::info!(%pending, "pending messages after turn; fetching next"); + continue; // Loop back to recv() immediately instead of sleeping + } } Ok(AgentResponse::Empty) => { // Idle: brief sleep before next poll to avoid busy-looping