Preserve trigger intent in typed agent messages

This commit is contained in:
Nikil Pancha
2026-06-16 15:36:02 -07:00
parent 5f8b2e5447
commit aac6018fa8
3 changed files with 26 additions and 0 deletions
@@ -55,6 +55,28 @@ fn inter_agent_assistant_message(text: &str) -> ResponseItem {
}
}
#[test]
fn typed_inter_agent_message_preserves_trigger_turn() {
for trigger_turn in [false, true] {
let communication = InterAgentCommunication::new(
AgentPath::root(),
AgentPath::root().join("worker").expect("worker path"),
Vec::new(),
"hello".to_string(),
trigger_turn,
);
let ResponseItem::AgentMessage {
trigger_turn: serialized_trigger_turn,
..
} = communication.to_model_input_item()
else {
panic!("expected typed agent message");
};
assert_eq!(serialized_trigger_turn, Some(trigger_turn));
}
}
#[tokio::test]
async fn record_initial_history_reconstructs_typed_inter_agent_message() {
let (session, _turn_context) = make_session_and_context().await;
+3
View File
@@ -922,6 +922,9 @@ pub enum ResponseItem {
content: Vec<AgentMessageInputContent>,
#[serde(default, skip_serializing_if = "Option::is_none")]
#[ts(optional)]
trigger_turn: Option<bool>,
#[serde(default, skip_serializing_if = "Option::is_none")]
#[ts(optional)]
metadata: Option<ResponseItemMetadata>,
},
Reasoning {
+1
View File
@@ -750,6 +750,7 @@ impl InterAgentCommunication {
author: self.author.to_string(),
recipient: self.recipient.to_string(),
content: vec![content],
trigger_turn: Some(self.trigger_turn),
metadata: self.metadata.clone(),
}
}