diff --git a/codex-rs/agent-message-board-host/src/lib.rs b/codex-rs/agent-message-board-host/src/lib.rs index bffc8dee78..fc60220721 100644 --- a/codex-rs/agent-message-board-host/src/lib.rs +++ b/codex-rs/agent-message-board-host/src/lib.rs @@ -230,24 +230,11 @@ impl MessageBoardHost for LocalBoardHost { Err(error) => return Err(error), }; let recipient_path = self.registered_path(&recipient).await?; - let suffix = if post.truncated { - "\n[Use read_post for the rest.]" - } else { - "" - }; - let content = format!( - "Message Type: CHANNEL_POST\nSender: {}\nChannel: {}\nMessage ID: {}\nThread ID: {}\nPayload:\n{}{suffix}", - post.metadata.author, - post.metadata.channel_name, - post.metadata.message_id, - post.metadata.thread_id, - post.text_preview, - ); let communication = InterAgentCommunication::new( post.metadata.author.clone(), recipient_path, Vec::new(), - content, + post.notification_text(), /*trigger_turn*/ false, ); // Remote metadata is untrusted. Skip an oversized notice without closing diff --git a/codex-rs/message-board/src/types.rs b/codex-rs/message-board/src/types.rs index 02e8ab0b1a..7bc28a55b1 100644 --- a/codex-rs/message-board/src/types.rs +++ b/codex-rs/message-board/src/types.rs @@ -1,4 +1,4 @@ -//! Message-board records shared by backends and tool adapters. +//! Message-board records and notification text shared by backends and tool adapters. use crate::BoardPermissions; use crate::ChannelPermissions; @@ -29,6 +29,25 @@ pub struct PostPreview { pub truncated: bool, } +impl PostPreview { + /// Formats a channel notification from this preview, including its truncation marker. + pub fn notification_text(&self) -> String { + let suffix = if self.truncated { + "\n[Use read_post for the rest.]" + } else { + "" + }; + format!( + "Message Type: CHANNEL_POST\nSender: {}\nChannel: {}\nMessage ID: {}\nThread ID: {}\nPayload:\n{}{suffix}", + self.metadata.author, + self.metadata.channel_name, + self.metadata.message_id, + self.metadata.thread_id, + self.text_preview, + ) + } +} + #[derive(Clone, Debug, PartialEq, Eq, Serialize, Deserialize)] pub struct PostContent { #[serde(flatten)]