mirror of
https://github.com/openai/codex.git
synced 2026-10-22 17:58:46 +00:00
## Why Contextual fragments and extension-owned world-state sections currently return strings, limiting them to text content. ## What changed - Return `ContentItem` from fragment bodies and rendering, preserving classification and attribution. Apply text markers only to `InputText`; pass other content through unchanged. - Allow extension prompt and world-state contributions to carry typed content, and preserve media in context-window hints. - Hash non-text world-state fragments by their serialized content and role while retaining the existing text hashing behavior. - Add shared content-to-tool-output conversion that preserves image references, image detail, and audio. ## Testing Add coverage for typed world-state hashing and preservation of image content and attribution. Expand code-mode output tests to cover input text, output text, file-backed and inline images, and audio. GitOrigin-RevId: 2ed00d466a3f169b151202f3eef71e667ea64be1
46 lines
1.6 KiB
Rust
46 lines
1.6 KiB
Rust
//! Converts agent messages into attributed input while preserving their wake mode.
|
|
|
|
use crate::agent::types::AgentMessage;
|
|
use crate::agent::types::MessageDeliveryMode;
|
|
use crate::context::ContextualUserFragment;
|
|
use crate::context::InterAgentMessage;
|
|
use crate::context::InterAgentMessageType;
|
|
use codex_protocol::AgentPath;
|
|
use codex_protocol::protocol::InterAgentCommunication;
|
|
|
|
impl AgentMessage {
|
|
pub(crate) fn into_communication(
|
|
self,
|
|
author: AgentPath,
|
|
recipient: AgentPath,
|
|
mode: MessageDeliveryMode,
|
|
) -> InterAgentCommunication {
|
|
let trigger_turn = mode == MessageDeliveryMode::TriggerTurn;
|
|
match self {
|
|
Self::Encrypted(message) => InterAgentCommunication::new_encrypted(
|
|
author,
|
|
recipient,
|
|
Vec::new(),
|
|
message,
|
|
trigger_turn,
|
|
),
|
|
Self::Plaintext(message) => {
|
|
let message_type = match mode {
|
|
MessageDeliveryMode::QueueOnly => InterAgentMessageType::Message,
|
|
MessageDeliveryMode::TriggerTurn => InterAgentMessageType::NewTask,
|
|
};
|
|
let content = InterAgentMessage::new(
|
|
message_type,
|
|
recipient.clone(),
|
|
author.clone(),
|
|
message,
|
|
)
|
|
.render()
|
|
.into_text()
|
|
.unwrap_or_default();
|
|
InterAgentCommunication::new(author, recipient, Vec::new(), content, trigger_turn)
|
|
}
|
|
}
|
|
}
|
|
}
|