maybe migrate to top-level source_call_id

This commit is contained in:
Owen Lin
2026-06-18 12:09:07 -07:00
parent 47ab51470b
commit 1262c3d245
13 changed files with 49 additions and 63 deletions
+6 -6
View File
@@ -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",
@@ -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",
@@ -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",
@@ -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",
@@ -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",
@@ -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<ContentItem>, phase?: MessagePhase, metadata?: ResponseItemMetadata, } | { "type": "agent_message", author: string, recipient: string, content: Array<AgentMessageInputContent>, metadata?: ResponseItemMetadata, } | { "type": "reasoning", summary: Array<ReasoningItemReasoningSummary>, content?: Array<ReasoningItemContent>, encrypted_content: string | null, metadata?: ResponseItemMetadata, } | { "type": "local_shell_call",
export type ResponseItem = { "type": "message", role: string, content: Array<ContentItem>, phase?: MessagePhase, metadata?: ResponseItemMetadata, } | { "type": "agent_message", author: string, recipient: string, source_call_id?: string, content: Array<AgentMessageInputContent>, metadata?: ResponseItemMetadata, } | { "type": "reasoning", summary: Array<ReasoningItemReasoningSummary>, content?: Array<ReasoningItemContent>, encrypted_content: string | null, metadata?: ResponseItemMetadata, } | { "type": "local_shell_call",
/**
* Set when using the Responses API.
*/
@@ -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, };
@@ -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
)
}));
@@ -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
@@ -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,
@@ -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",
+3 -3
View File
@@ -909,9 +909,6 @@ pub struct ResponseItemMetadata {
#[serde(default, skip_serializing_if = "Option::is_none")]
#[ts(optional)]
pub turn_id: Option<String>,
#[serde(default, skip_serializing_if = "Option::is_none")]
#[ts(optional)]
pub source_call_id: Option<String>,
}
#[derive(Debug, Clone, Serialize, Deserialize, PartialEq, JsonSchema, TS)]
@@ -941,6 +938,9 @@ pub enum ResponseItem {
id: Option<String>,
author: String,
recipient: String,
#[serde(default, skip_serializing_if = "Option::is_none")]
#[ts(optional)]
source_call_id: Option<String>,
content: Vec<AgentMessageInputContent>,
#[serde(default, skip_serializing_if = "Option::is_none")]
#[ts(optional)]
+8
View File
@@ -693,6 +693,9 @@ pub struct InterAgentCommunication {
pub encrypted_content: Option<String>,
#[serde(default, skip_serializing_if = "Option::is_none")]
#[ts(optional)]
pub source_call_id: Option<String>,
#[serde(default, skip_serializing_if = "Option::is_none")]
#[ts(optional)]
pub metadata: Option<ResponseItemMetadata>,
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"