From c0d47262f33fdb866e2012baad52cf6584e37c03 Mon Sep 17 00:00:00 2001 From: RJ Date: Mon, 16 Nov 2026 21:30:14 +0000 Subject: [PATCH] Acknowledge agent messages and clarify how to wake idle recipients (#61894) ## What changed Return `Message accepted.` from the v2 `send_message` tool. For non-root recipients, also advise using `followup_task` when an idle agent should act immediately. Messages to the root agent receive only the acknowledgment. ## Testing Assert the acknowledgment when a child messages the root agent, and update the idle-eviction follow-up snapshot to include the guidance for non-root recipients. GitOrigin-RevId: bb0cf6039d9b693052a1747daa2e75fa25c13522 --- .../core/src/tools/handlers/multi_agents_tests.rs | 6 +++++- .../tools/handlers/multi_agents_v2/message_tool.rs | 12 +++++++++++- ...rios__agent_eviction__idle_eviction_followup.snap | 2 +- 3 files changed, 17 insertions(+), 3 deletions(-) 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 189f021201..eaad60b9fe 100644 --- a/codex-rs/core/src/tools/handlers/multi_agents_tests.rs +++ b/codex-rs/core/src/tools/handlers/multi_agents_tests.rs @@ -1361,7 +1361,7 @@ async fn multi_agent_v2_send_message_accepts_root_target_from_child() { agent_role: None, }); - SendMessageHandlerV2 + let output = SendMessageHandlerV2 .handle(invocation( Arc::new(session), Arc::new(turn), @@ -1373,6 +1373,10 @@ async fn multi_agent_v2_send_message_accepts_root_target_from_child() { )) .await .expect("send_message should accept the root agent path"); + assert_eq!( + expect_text_output(output), + ("Message accepted.".to_string(), Some(true)) + ); assert!(manager.captured_ops().iter().any(|(id, op)| { *id == root.thread_id 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 8392960121..2f4636804c 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 @@ -83,6 +83,13 @@ pub(super) async fn handle_message_string_tool( let receiver_agent_path = receipt.metadata.agent_path.ok_or_else(|| { FunctionCallError::RespondToModel("target agent is missing an agent_path".to_string()) })?; + let output = match mode { + MessageDeliveryMode::QueueOnly if receiver_agent_path.is_root() => "Message accepted.", + MessageDeliveryMode::QueueOnly => { + "Message accepted. If the recipient is idle and should act now, use followup_task to ask it to act on the message." + } + MessageDeliveryMode::TriggerTurn => "", + }; emit_sub_agent_activity( &session, &turn, @@ -97,5 +104,8 @@ pub(super) async fn handle_message_string_tool( ) .await; - Ok(FunctionToolOutput::from_text(String::new(), Some(true))) + Ok(FunctionToolOutput::from_text( + output.to_string(), + Some(true), + )) } diff --git a/codex-rs/core/tests/suite/snapshots/all__suite__scenarios__agent_eviction__idle_eviction_followup.snap b/codex-rs/core/tests/suite/snapshots/all__suite__scenarios__agent_eviction__idle_eviction_followup.snap index 95675c3489..e005207244 100644 --- a/codex-rs/core/tests/suite/snapshots/all__suite__scenarios__agent_eviction__idle_eviction_followup.snap +++ b/codex-rs/core/tests/suite/snapshots/all__suite__scenarios__agent_eviction__idle_eviction_followup.snap @@ -55,7 +55,7 @@ Scenario: A parent with no configured environment delegates an API migration, qu Run send_message for the API migration. -- request 4 (turn) -- 10:function_call/collaboration.send_message:{"message":"Use the new API for the migration.","target":"worker"} -11:function_call_output: +11:function_call_output:Message accepted. If the recipient is idle and should act now, use followup_task to ask it to act on the message. 12:agent_message -- request 5 (turn) -- 13:message/user: