Reduce session submission channel memory with boxed payloads (#61389)

## Why

The bounded submission channel reserves all slots at session startup, including space for a full `Submission` in each slot.

## What changed

Send `Box<Submission>` through the channel so each slot reserves only pointer-sized payload storage, allocating full submissions as needed. Update submission producers, delegate forwarding, and test helpers to pass boxed submissions, and unbox them in the submission loop.

GitOrigin-RevId: d8d9c613683076d74fcb3e2f2cb6244c5857bca2
This commit is contained in:
Charlie Marsh
2026-11-13 22:18:34 +00:00
committed by copyberry
parent 0276c8143d
commit 1c76c0bc08
8 changed files with 28 additions and 22 deletions
+3 -3
View File
@@ -305,7 +305,7 @@ pub(crate) async fn run_codex_thread_one_shot(
let _ = tx_bridge.send(event).await;
if should_shutdown {
let _ = ops_tx
.send(Submission {
.send(Box::new(Submission {
id: "shutdown".to_string(),
op: Op::Shutdown {},
turn_extension_init: None,
@@ -314,7 +314,7 @@ pub(crate) async fn run_codex_thread_one_shot(
root_turn_id: None,
residency_guard: None,
message_delivery: None,
})
}))
.await;
child_cancel.cancel();
break;
@@ -415,7 +415,7 @@ async fn forward_event_or_shutdown(
/// Forward ops from a caller to a sub-agent, respecting cancellation.
async fn forward_ops(
io: Arc<SessionIo>,
rx_ops: Receiver<Submission>,
rx_ops: Receiver<Box<Submission>>,
cancel_token_ops: CancellationToken,
) {
loop {