Wake sleeping threads for queued agent mail (#34852)

## Why

An idle thread with an outstanding durable sleep must resume when agent work
arrives, even when that message would normally remain queued without triggering a
turn.

## What changed

- Treat any pending mailbox message as wake-up work while a durable sleep is
  attached to the thread.
- Keep requiring `trigger_turn` for idle threads that are not durably asleep.
- Cover waking a sleeping root thread from queue-only agent mail and persisting
  the message in thread history.

GitOrigin-RevId: e361ac1b104436d4d63aebfe5e2422691a1cc139
This commit is contained in:
Boyang Niu authored and copyberry committed 2026-07-23 01:04:01 +00:00
1 parent b72079a2cf
commit 44d76c6a6d
3 files changed
+80 -6

No files matched your search

+1 -1
View File
@@ -280,7 +280,7 @@ pub async fn inter_agent_communication(
.enqueue_mailbox_communication(communication)
.await;
crate::agent_communication::emit_agent_communication_receive(&sub_id);
if trigger_turn {
if trigger_turn || sess.has_outstanding_durable_sleep() {
sess.maybe_start_turn_for_pending_work_with_sub_id(sub_id)
.await;
}