Wake idle root threads on persisted agent messages (#63312)

## Why

Plaintext agent messages injected through `thread/inject_items` could
be saved to root-thread history without waking the thread, even when
agent-message wakes were enabled.

## What changed

After persisting a batch of plaintext agent messages with unspecified
retention, let the native multi-agent v2 root thread's mailbox scheduler
apply its usual wake and turn-admission rules. Use the recorded history
sequence to skip a wake if another turn already read the messages and
to deliver the mail directly from history without re-enqueueing it.

## Testing

Cover app-server injection with wakes enabled and disabled, wake a
reloaded sleeping root with its previous turn context, and verify that
a paused turn-admission gate defers the wake and the eventual model
request contains the message once.

GitOrigin-RevId: 5fde8062a179fd7a7919d240373592f2dbb4a389
This commit is contained in:
jif
2026-11-23 11:16:31 +00:00
committed by copyberry
parent a1604a8c05
commit ca891cecdc
9 changed files with 237 additions and 101 deletions
-4
View File
@@ -589,10 +589,6 @@ impl Session {
self: &Arc<Self>,
sub_id: String,
) {
if !self.input_queue.has_pending_mailbox_items().await {
return;
}
let Some(reservation) = self.reserve_pending_work_turn().await else {
return;
};