From d99e0812d09ff9e2140e442ffb6cb705137ee7c9 Mon Sep 17 00:00:00 2001 From: damocles Date: Sat, 16 May 2026 13:48:04 +0200 Subject: [PATCH] fix: move sleep to only occur when recv returns empty, avoid message delivery delay --- hive-ag3nt/src/bin/hive-ag3nt.rs | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/hive-ag3nt/src/bin/hive-ag3nt.rs b/hive-ag3nt/src/bin/hive-ag3nt.rs index 23f3c9b..2a8d8d8 100644 --- a/hive-ag3nt/src/bin/hive-ag3nt.rs +++ b/hive-ag3nt/src/bin/hive-ag3nt.rs @@ -166,7 +166,13 @@ async fn serve( turn::emit_turn_end(&bus, &outcome); bus.set_state(TurnState::Idle); } - Ok(AgentResponse::Empty) => {} + Ok(AgentResponse::Empty) => { + // Idle: brief sleep before next poll to avoid busy-looping + // on consecutive Empty responses. The recv() call already + // waits up to 180s for messages, so this is just for + // responsiveness if recv() times out. + tokio::time::sleep(interval).await; + } Ok(AgentResponse::Ok | AgentResponse::Status { .. } | AgentResponse::Recent { .. } @@ -180,7 +186,6 @@ async fn serve( tracing::warn!(error = ?e, "recv failed; retrying"); } } - tokio::time::sleep(interval).await; } }