From c117207a6f1f948ac7fcdd5e784d75fc4e9d13e1 Mon Sep 17 00:00:00 2001 From: jif Date: Tue, 22 Sep 2026 10:31:56 +0000 Subject: [PATCH] Drop descendant channel posts from retained remote compaction v2 history (#47249) ## Why Remote compaction v2 excluded descendant progress messages from retained history but kept `CHANNEL_POST` messages from those same agents. ## What changed Treat descendant `CHANNEL_POST` messages like `MESSAGE` progress updates when selecting history to retain after remote compaction v2. ## Testing Extend the remote compaction test to verify that a child channel post is included in the compaction input and omitted from the follow-up request. GitOrigin-RevId: 204bf44b8cddf1e6dc1e48234f51d4ac2aaf2e9f --- codex-rs/core/src/compact_remote_v2.rs | 1 + codex-rs/core/tests/suite/compact_remote.rs | 25 +++++++++++++++++++++ 2 files changed, 26 insertions(+) diff --git a/codex-rs/core/src/compact_remote_v2.rs b/codex-rs/core/src/compact_remote_v2.rs index a6436d15f7..722b24cf8e 100644 --- a/codex-rs/core/src/compact_remote_v2.rs +++ b/codex-rs/core/src/compact_remote_v2.rs @@ -572,6 +572,7 @@ fn is_retained_for_remote_compaction_v2( content.first(), Some(AgentMessageInputContent::InputText { text }) if text.starts_with("Message Type: MESSAGE\n") + || text.starts_with("Message Type: CHANNEL_POST\n") ); let is_completion = matches!( content.first(), diff --git a/codex-rs/core/tests/suite/compact_remote.rs b/codex-rs/core/tests/suite/compact_remote.rs index f7dc16e13d..f8a82bd394 100644 --- a/codex-rs/core/tests/suite/compact_remote.rs +++ b/codex-rs/core/tests/suite/compact_remote.rs @@ -912,6 +912,19 @@ async fn remote_compact_v2_reuses_compaction_trigger_for_followups() -> Result<( start_options: Default::default(), }) .await?; + let channel_progress = "Message Type: CHANNEL_POST\nSender: /root/child\nChannel: progress\nMessage ID: aaaabbbbcccc\nThread ID: aaaabbbbcccc\nPayload:\nchild channel progress"; + codex + .submit(Op::InterAgentCommunication { + communication: InterAgentCommunication::new( + AgentPath::root().join("child").expect("valid child path"), + AgentPath::root(), + Vec::new(), + channel_progress.to_string(), + /*trigger_turn*/ false, + ), + start_options: Default::default(), + }) + .await?; codex .submit(Op::InterAgentCommunication { communication: InterAgentCommunication::new( @@ -1012,6 +1025,12 @@ async fn remote_compact_v2_reuses_compaction_trigger_for_followups() -> Result<( .any(|item| item.to_string().contains("child progress")), "expected v2 compaction input to include the child progress update" ); + assert!( + compact_request + .inputs_of_type("agent_message") + .iter() + .any(|item| item["content"][0]["text"].as_str() == Some(channel_progress)) + ); assert!( compact_request .inputs_of_type("agent_message") @@ -1106,6 +1125,12 @@ async fn remote_compact_v2_reuses_compaction_trigger_for_followups() -> Result<( .all(|item| !item.to_string().contains("child progress")), "expected v2 follow-up request to omit the child progress update" ); + assert!( + follow_up_request + .inputs_of_type("agent_message") + .iter() + .all(|item| item["content"][0]["text"].as_str() != Some(channel_progress)) + ); assert!( follow_up_request .inputs_of_type("agent_message")