Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions codex-rs/app-server-protocol/schema/json/ClientRequest.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions codex-rs/core/src/compact_tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -238,6 +238,7 @@ fn build_compacted_history_preserves_user_message_metadata() {
message: "first user message".to_string(),
metadata: Some(ResponseItemMetadata {
turn_id: Some("turn-1".to_string()),
..Default::default()
}),
}],
"summary text",
Expand Down
1 change: 1 addition & 0 deletions codex-rs/core/src/context_manager/history_tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1049,6 +1049,7 @@ fn record_items_truncates_function_call_output_content() {
},
metadata: Some(ResponseItemMetadata {
turn_id: Some("turn-1".to_string()),
..Default::default()
}),
};

Expand Down
1 change: 1 addition & 0 deletions codex-rs/core/src/session/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1606,6 +1606,7 @@ async fn reconstruct_history_uses_replacement_history_verbatim() {
phase: None,
metadata: Some(ResponseItemMetadata {
turn_id: Some("compact-turn".to_string()),
..Default::default()
}),
};
let replacement_history = vec![
Expand Down
27 changes: 27 additions & 0 deletions codex-rs/core/src/tools/handlers/multi_agents_tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1195,6 +1195,11 @@ 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.trigger_turn
)
}));
Expand Down Expand Up @@ -1222,6 +1227,11 @@ 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.trigger_turn
)
}));
Expand Down Expand Up @@ -2027,6 +2037,23 @@ async fn multi_agent_v2_followup_task_completion_notifies_parent_on_every_turn()
.await
.expect("followup_task should succeed");

assert!(manager.captured_ops().iter().any(|(id, op)| {
*id == agent_id
&& matches!(
op,
Op::InterAgentCommunication { communication }
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.trigger_turn
)
}));

let second_turn = thread.codex.session.new_default_turn().await;
thread
.codex
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
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)]
Expand Down Expand Up @@ -99,8 +100,12 @@ pub(crate) async fn handle_message_string_tool(
.session_source
.get_agent_path()
.unwrap_or_else(AgentPath::root);
let communication =
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());
Comment thread
jif-oai marked this conversation as resolved.
let result = session
.services
.agent_control
Expand Down
7 changes: 6 additions & 1 deletion codex-rs/core/src/tools/handlers/multi_agents_v2/spawn.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ 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;

Expand Down Expand Up @@ -117,8 +118,12 @@ async fn handle_spawn_agent(
.session_source
.get_agent_path()
.unwrap_or_else(AgentPath::root);
let communication =
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());
Comment thread
jif-oai marked this conversation as resolved.
Op::InterAgentCommunication { communication }
}
initial_operation => initial_operation,
Expand Down
3 changes: 3 additions & 0 deletions codex-rs/core/tests/suite/subagent_notifications.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1088,6 +1088,9 @@ 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,
},
"content": [
{
"type": "input_text",
Expand Down
4 changes: 4 additions & 0 deletions codex-rs/protocol/src/models.rs
Original file line number Diff line number Diff line change
Expand Up @@ -909,6 +909,9 @@ 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>,
Comment thread
jif-oai marked this conversation as resolved.
}

#[derive(Debug, Clone, Serialize, Deserialize, PartialEq, JsonSchema, TS)]
Expand Down Expand Up @@ -2072,6 +2075,7 @@ mod tests {
fn response_item_metadata(turn_id: &str) -> ResponseItemMetadata {
ResponseItemMetadata {
turn_id: Some(turn_id.to_string()),
..Default::default()
}
}

Expand Down
Loading