Backfill completion items only for the active exec turn (#34226)

## Why

Multi-agent exec sessions can receive child `turn/completed` notifications on
the same event stream as the primary turn. Backfilling those unrelated
completions issues unnecessary `thread/read` requests.

## What changed

Run completion-item backfill only after a notification has been matched to the
primary exec thread and turn.

## Testing

Add an integration test that delivers a child completion before the primary
completion and verifies that only the primary completion triggers backfill.

GitOrigin-RevId: 46a41236ee6a39e4b341570ff4826a71fa02bb32
This commit is contained in:
Charlie Marsh
2026-07-19 20:36:18 +00:00
committed by copyberry
parent c86b1be3cd
commit 7844386e3d
3 changed files with 172 additions and 8 deletions
+8 -8
View File
@@ -1014,19 +1014,19 @@ async fn run_exec_session(args: ExecRunArgs) -> anyhow::Result<()> {
error_seen = true;
}
maybe_backfill_turn_completed_items(
config.ephemeral,
&client,
&mut request_ids,
&mut notification,
)
.await;
if should_process_notification(
&notification,
&primary_thread_id_for_requests,
&task_id,
) {
maybe_backfill_turn_completed_items(
config.ephemeral,
&client,
&mut request_ids,
&mut notification,
)
.await;
match event_processor.process_server_notification(notification) {
CodexStatus::Running => {}
CodexStatus::InitiateShutdown => {