fix: auto-wake after turn if pending messages exist, don't block on recv
This commit is contained in:
parent
d99e0812d0
commit
3d2a7ffec7
1 changed files with 9 additions and 0 deletions
|
|
@ -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
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue