diff --git a/codex-rs/app-server-protocol/schema/json/ClientRequest.json b/codex-rs/app-server-protocol/schema/json/ClientRequest.json index 5ebb861de0..b8731ffd82 100644 --- a/codex-rs/app-server-protocol/schema/json/ClientRequest.json +++ b/codex-rs/app-server-protocol/schema/json/ClientRequest.json @@ -2353,6 +2353,12 @@ "recipient": { "type": "string" }, + "source_call_id": { + "type": [ + "string", + "null" + ] + }, "type": { "enum": [ "agent_message" @@ -2908,12 +2914,6 @@ }, "ResponseItemMetadata": { "properties": { - "source_call_id": { - "type": [ - "string", - "null" - ] - }, "turn_id": { "type": [ "string", diff --git a/codex-rs/app-server-protocol/schema/json/codex_app_server_protocol.schemas.json b/codex-rs/app-server-protocol/schema/json/codex_app_server_protocol.schemas.json index c75ae416fa..39b374dc94 100644 --- a/codex-rs/app-server-protocol/schema/json/codex_app_server_protocol.schemas.json +++ b/codex-rs/app-server-protocol/schema/json/codex_app_server_protocol.schemas.json @@ -14855,6 +14855,12 @@ "recipient": { "type": "string" }, + "source_call_id": { + "type": [ + "string", + "null" + ] + }, "type": { "enum": [ "agent_message" @@ -15410,12 +15416,6 @@ }, "ResponseItemMetadata": { "properties": { - "source_call_id": { - "type": [ - "string", - "null" - ] - }, "turn_id": { "type": [ "string", diff --git a/codex-rs/app-server-protocol/schema/json/codex_app_server_protocol.v2.schemas.json b/codex-rs/app-server-protocol/schema/json/codex_app_server_protocol.v2.schemas.json index a4a0267dc5..143c7fb11b 100644 --- a/codex-rs/app-server-protocol/schema/json/codex_app_server_protocol.v2.schemas.json +++ b/codex-rs/app-server-protocol/schema/json/codex_app_server_protocol.v2.schemas.json @@ -11300,6 +11300,12 @@ "recipient": { "type": "string" }, + "source_call_id": { + "type": [ + "string", + "null" + ] + }, "type": { "enum": [ "agent_message" @@ -11855,12 +11861,6 @@ }, "ResponseItemMetadata": { "properties": { - "source_call_id": { - "type": [ - "string", - "null" - ] - }, "turn_id": { "type": [ "string", diff --git a/codex-rs/app-server-protocol/schema/json/v2/RawResponseItemCompletedNotification.json b/codex-rs/app-server-protocol/schema/json/v2/RawResponseItemCompletedNotification.json index f77a68dc1d..1608ff61e2 100644 --- a/codex-rs/app-server-protocol/schema/json/v2/RawResponseItemCompletedNotification.json +++ b/codex-rs/app-server-protocol/schema/json/v2/RawResponseItemCompletedNotification.json @@ -440,6 +440,12 @@ "recipient": { "type": "string" }, + "source_call_id": { + "type": [ + "string", + "null" + ] + }, "type": { "enum": [ "agent_message" @@ -995,12 +1001,6 @@ }, "ResponseItemMetadata": { "properties": { - "source_call_id": { - "type": [ - "string", - "null" - ] - }, "turn_id": { "type": [ "string", diff --git a/codex-rs/app-server-protocol/schema/json/v2/ThreadResumeParams.json b/codex-rs/app-server-protocol/schema/json/v2/ThreadResumeParams.json index e09dd2c6fc..497a776fc2 100644 --- a/codex-rs/app-server-protocol/schema/json/v2/ThreadResumeParams.json +++ b/codex-rs/app-server-protocol/schema/json/v2/ThreadResumeParams.json @@ -511,6 +511,12 @@ "recipient": { "type": "string" }, + "source_call_id": { + "type": [ + "string", + "null" + ] + }, "type": { "enum": [ "agent_message" @@ -1066,12 +1072,6 @@ }, "ResponseItemMetadata": { "properties": { - "source_call_id": { - "type": [ - "string", - "null" - ] - }, "turn_id": { "type": [ "string", diff --git a/codex-rs/app-server-protocol/schema/typescript/ResponseItem.ts b/codex-rs/app-server-protocol/schema/typescript/ResponseItem.ts index f0cd1c8ee6..e38758af57 100644 --- a/codex-rs/app-server-protocol/schema/typescript/ResponseItem.ts +++ b/codex-rs/app-server-protocol/schema/typescript/ResponseItem.ts @@ -12,7 +12,7 @@ import type { ReasoningItemReasoningSummary } from "./ReasoningItemReasoningSumm import type { ResponseItemMetadata } from "./ResponseItemMetadata"; import type { WebSearchAction } from "./WebSearchAction"; -export type ResponseItem = { "type": "message", role: string, content: Array, phase?: MessagePhase, metadata?: ResponseItemMetadata, } | { "type": "agent_message", author: string, recipient: string, content: Array, metadata?: ResponseItemMetadata, } | { "type": "reasoning", summary: Array, content?: Array, encrypted_content: string | null, metadata?: ResponseItemMetadata, } | { "type": "local_shell_call", +export type ResponseItem = { "type": "message", role: string, content: Array, phase?: MessagePhase, metadata?: ResponseItemMetadata, } | { "type": "agent_message", author: string, recipient: string, source_call_id?: string, content: Array, metadata?: ResponseItemMetadata, } | { "type": "reasoning", summary: Array, content?: Array, encrypted_content: string | null, metadata?: ResponseItemMetadata, } | { "type": "local_shell_call", /** * Set when using the Responses API. */ diff --git a/codex-rs/app-server-protocol/schema/typescript/ResponseItemMetadata.ts b/codex-rs/app-server-protocol/schema/typescript/ResponseItemMetadata.ts index 365c561fd1..f7b69a6dfe 100644 --- a/codex-rs/app-server-protocol/schema/typescript/ResponseItemMetadata.ts +++ b/codex-rs/app-server-protocol/schema/typescript/ResponseItemMetadata.ts @@ -2,4 +2,4 @@ // This file was generated by [ts-rs](https://github.com/Aleph-Alpha/ts-rs). Do not edit this file manually. -export type ResponseItemMetadata = { turn_id?: string, source_call_id?: string, }; +export type ResponseItemMetadata = { turn_id?: string, }; diff --git a/codex-rs/core/src/tools/handlers/multi_agents_tests.rs b/codex-rs/core/src/tools/handlers/multi_agents_tests.rs index 557164f4de..6a0cc14304 100644 --- a/codex-rs/core/src/tools/handlers/multi_agents_tests.rs +++ b/codex-rs/core/src/tools/handlers/multi_agents_tests.rs @@ -1195,11 +1195,7 @@ async fn multi_agent_v2_spawn_returns_path_and_send_message_accepts_relative_pat && communication.other_recipients.is_empty() && communication.content.is_empty() && communication.encrypted_content.as_deref() == Some("encrypted-spawn-message") - && communication - .metadata - .as_ref() - .and_then(|metadata| metadata.source_call_id.as_deref()) - == Some("call-1") + && communication.source_call_id.as_deref() == Some("call-1") && communication.trigger_turn ) })); @@ -1227,11 +1223,7 @@ async fn multi_agent_v2_spawn_returns_path_and_send_message_accepts_relative_pat && communication.other_recipients.is_empty() && communication.content.is_empty() && communication.encrypted_content.as_deref() == Some("encrypted-send-message") - && communication - .metadata - .as_ref() - .and_then(|metadata| metadata.source_call_id.as_deref()) - == Some("call-1") + && communication.source_call_id.as_deref() == Some("call-1") && !communication.trigger_turn ) })); @@ -2045,11 +2037,7 @@ async fn multi_agent_v2_followup_task_completion_notifies_parent_on_every_turn() if communication.author == AgentPath::root() && communication.recipient == worker_path && communication.encrypted_content.as_deref() == Some("continue") - && communication - .metadata - .as_ref() - .and_then(|metadata| metadata.source_call_id.as_deref()) - == Some("call-1") + && communication.source_call_id.as_deref() == Some("call-1") && communication.trigger_turn ) })); diff --git a/codex-rs/core/src/tools/handlers/multi_agents_v2/message_tool.rs b/codex-rs/core/src/tools/handlers/multi_agents_v2/message_tool.rs index 81eebed4a3..c62367f785 100644 --- a/codex-rs/core/src/tools/handlers/multi_agents_v2/message_tool.rs +++ b/codex-rs/core/src/tools/handlers/multi_agents_v2/message_tool.rs @@ -6,7 +6,6 @@ use super::*; use crate::tools::context::FunctionToolOutput; use crate::turn_timing::now_unix_timestamp_ms; -use codex_protocol::models::ResponseItemMetadata; use codex_protocol::protocol::InterAgentCommunication; #[derive(Clone, Copy, PartialEq, Eq)] @@ -102,10 +101,7 @@ pub(crate) async fn handle_message_string_tool( .unwrap_or_else(AgentPath::root); let mut communication = communication_from_tool_message(author, receiver_agent_path.clone(), message); - communication - .metadata - .get_or_insert_with(ResponseItemMetadata::default) - .source_call_id = Some(call_id.clone()); + communication.source_call_id = Some(call_id.clone()); let result = session .services .agent_control diff --git a/codex-rs/core/src/tools/handlers/multi_agents_v2/spawn.rs b/codex-rs/core/src/tools/handlers/multi_agents_v2/spawn.rs index 51813c5c19..8b2b8f9c70 100644 --- a/codex-rs/core/src/tools/handlers/multi_agents_v2/spawn.rs +++ b/codex-rs/core/src/tools/handlers/multi_agents_v2/spawn.rs @@ -8,7 +8,6 @@ use crate::tools::handlers::multi_agents_spec::SpawnAgentToolOptions; use crate::tools::handlers::multi_agents_spec::create_spawn_agent_tool_v2; use crate::turn_timing::now_unix_timestamp_ms; use codex_protocol::AgentPath; -use codex_protocol::models::ResponseItemMetadata; use codex_protocol::protocol::Op; use codex_tools::ToolSpec; @@ -120,10 +119,7 @@ async fn handle_spawn_agent( .unwrap_or_else(AgentPath::root); let mut communication = communication_from_tool_message(author, new_agent_path.clone(), message); - communication - .metadata - .get_or_insert_with(ResponseItemMetadata::default) - .source_call_id = Some(call_id.clone()); + communication.source_call_id = Some(call_id.clone()); Op::InterAgentCommunication { communication } } initial_operation => initial_operation, diff --git a/codex-rs/core/tests/suite/subagent_notifications.rs b/codex-rs/core/tests/suite/subagent_notifications.rs index 2501aa0dde..7641bf8ffa 100644 --- a/codex-rs/core/tests/suite/subagent_notifications.rs +++ b/codex-rs/core/tests/suite/subagent_notifications.rs @@ -1088,9 +1088,7 @@ async fn encrypted_multi_agent_v2_spawn_sends_agent_message_to_child() -> Result "type": "agent_message", "author": "/root", "recipient": "/root/worker", - "metadata": { - "source_call_id": SPAWN_CALL_ID, - }, + "source_call_id": SPAWN_CALL_ID, "content": [ { "type": "input_text", diff --git a/codex-rs/protocol/src/models.rs b/codex-rs/protocol/src/models.rs index 3c0753cb43..ff4a457418 100644 --- a/codex-rs/protocol/src/models.rs +++ b/codex-rs/protocol/src/models.rs @@ -909,9 +909,6 @@ pub struct ResponseItemMetadata { #[serde(default, skip_serializing_if = "Option::is_none")] #[ts(optional)] pub turn_id: Option, - #[serde(default, skip_serializing_if = "Option::is_none")] - #[ts(optional)] - pub source_call_id: Option, } #[derive(Debug, Clone, Serialize, Deserialize, PartialEq, JsonSchema, TS)] @@ -941,6 +938,9 @@ pub enum ResponseItem { id: Option, author: String, recipient: String, + #[serde(default, skip_serializing_if = "Option::is_none")] + #[ts(optional)] + source_call_id: Option, content: Vec, #[serde(default, skip_serializing_if = "Option::is_none")] #[ts(optional)] diff --git a/codex-rs/protocol/src/protocol.rs b/codex-rs/protocol/src/protocol.rs index d51a30addf..5b78dd9f80 100644 --- a/codex-rs/protocol/src/protocol.rs +++ b/codex-rs/protocol/src/protocol.rs @@ -693,6 +693,9 @@ pub struct InterAgentCommunication { pub encrypted_content: Option, #[serde(default, skip_serializing_if = "Option::is_none")] #[ts(optional)] + pub source_call_id: Option, + #[serde(default, skip_serializing_if = "Option::is_none")] + #[ts(optional)] pub metadata: Option, pub trigger_turn: bool, } @@ -711,6 +714,7 @@ impl InterAgentCommunication { other_recipients, content, encrypted_content: None, + source_call_id: None, metadata: None, trigger_turn, } @@ -729,6 +733,7 @@ impl InterAgentCommunication { other_recipients, content: String::new(), encrypted_content: Some(encrypted_content), + source_call_id: None, metadata: None, trigger_turn, } @@ -772,6 +777,7 @@ impl InterAgentCommunication { id: None, author: self.author.to_string(), recipient: self.recipient.to_string(), + source_call_id: self.source_call_id.clone(), content, metadata: self.metadata.clone(), } @@ -4263,6 +4269,7 @@ mod tests { other_recipients: vec![AgentPath::root().join("worker").expect("recipient path")], content: "review the diff".to_string(), encrypted_content: None, + source_call_id: None, metadata: None, trigger_turn: true, }; @@ -4295,6 +4302,7 @@ mod tests { id: None, author: "/root/worker".to_string(), recipient: "/root".to_string(), + source_call_id: None, content: vec![ AgentMessageInputContent::InputText { text: "Message Type: MESSAGE\nTask name: /root\nSender: /root/worker\nPayload:\n"