Download codex-rs/core/src/agent_communication.rs from SaylorTwift/codex: direct link, hf CLI and curl.
- Browser
- Download file 2.09 kB
-
https://huggingface.co/SaylorTwift/codex/resolve/main/codex-rs/core/src/agent_communication.rs
- Command line
-
hf download hf://SaylorTwift/codex/codex-rs/core/src/agent_communication.rs
-
curl -L -o agent_communication.rs https://huggingface.co/SaylorTwift/codex/resolve/main/codex-rs/core/src/agent_communication.rs
2.09 kB
| use codex_protocol::ThreadId; | |
| use codex_protocol::protocol::InterAgentCommunication; | |
| const AGENT_COMMUNICATION_TARGET: &str = "codex_otel.agent_communication"; | |
| pub(crate) enum AgentCommunicationKind { | |
| Spawn, | |
| Message, | |
| Followup, | |
| Result, | |
| } | |
| impl AgentCommunicationKind { | |
| fn as_str(self) -> &'static str { | |
| match self { | |
| Self::Spawn => "spawn", | |
| Self::Message => "message", | |
| Self::Followup => "followup", | |
| Self::Result => "result", | |
| } | |
| } | |
| } | |
| pub(crate) struct AgentCommunicationContext { | |
| kind: AgentCommunicationKind, | |
| sender_thread_id: ThreadId, | |
| } | |
| impl AgentCommunicationContext { | |
| pub(crate) fn new(kind: AgentCommunicationKind, sender_thread_id: ThreadId) -> Self { | |
| Self { | |
| kind, | |
| sender_thread_id, | |
| } | |
| } | |
| } | |
| pub(crate) fn logging_enabled() -> bool { | |
| tracing::enabled!(target: AGENT_COMMUNICATION_TARGET, tracing::Level::INFO) | |
| } | |
| pub(crate) fn emit_agent_communication_send( | |
| communication_id: &str, | |
| context: &AgentCommunicationContext, | |
| communication: &InterAgentCommunication, | |
| receiver_thread_id: ThreadId, | |
| ) { | |
| tracing::info!( | |
| target: AGENT_COMMUNICATION_TARGET, | |
| { | |
| event.name = "codex.agent_communication", | |
| communication_id, | |
| kind = context.kind.as_str(), | |
| state = "send", | |
| sender_thread_id = %context.sender_thread_id, | |
| receiver_thread_id = %receiver_thread_id, | |
| content = communication | |
| .encrypted_content | |
| .as_deref() | |
| .unwrap_or("[plaintext]"), | |
| }, | |
| "agent communication" | |
| ); | |
| } | |
| pub(crate) fn emit_agent_communication_receive(communication_id: &str) { | |
| tracing::info!( | |
| target: AGENT_COMMUNICATION_TARGET, | |
| { | |
| event.name = "codex.agent_communication", | |
| communication_id, | |
| state = "receive", | |
| }, | |
| "agent communication" | |
| ); | |
| } | |