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
This commit is contained in:
RJ
2026-11-16 22:07:07 +00:00
committed by copyberry
parent 3a51865c8c
commit c0d47262f3
3 changed files with 17 additions and 3 deletions
@@ -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
@@ -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),
))
}