Add lifecycle hooks for inter-agent messages (#55657)

## What changed

Add `MessageLifecycleContributor` hooks to capture extension state when local agent control publishes a message and notify contributors when the recipient commits it to history, before sampling.

Carry shared delivery state through submissions, input queues, and mailbox eviction with `PendingAgentMessage`. Notify consumption at most once per delivery, release captured state when consumed or abandoned, and drop pending mail outside queue locks. Preserve the serialized message format without republishing restored history.

## Testing

Extend the mailbox eviction test to verify that publication state survives eviction and retained messages are consumed before the first resumed model sample.

GitOrigin-RevId: 9a1f6832bd48ec646a3fd179485c095e8dcc72cc
This commit is contained in:
Ruslan Nigmatullin
2026-10-20 19:39:43 +00:00
committed by copyberry
parent 87f3c3284e
commit 66d0de9983
25 changed files with 304 additions and 76 deletions
+2 -1
View File
@@ -404,7 +404,7 @@ impl CodexThread {
self.io
.submit_with_trace(
op, trace, /*parent_turn_id*/ None, /*root_turn_id*/ None,
/*residency_guard*/ None,
/*residency_guard*/ None, /*message_delivery*/ None,
)
.await
}
@@ -550,6 +550,7 @@ impl CodexThread {
parent_turn_id: None,
root_turn_id: None,
residency_guard: None,
message_delivery: None,
})
.await
.map_err(|_| CodexErr::Fatal("thread session has stopped".to_string()))?;