Prefix handoff messages with role (#13505)

Format handoff context by prefixing each message with its role (for
example "user:" and "assistant:") before forwarding to the agent.
This commit is contained in:
Ahmed Ibrahim
2026-03-04 15:37:31 -08:00
committed by GitHub
parent 4907096d13
commit 294079b0b1
2 changed files with 21 additions and 11 deletions
+2 -2
View File
@@ -376,7 +376,7 @@ fn realtime_text_from_handoff_request(handoff: &RealtimeHandoffRequested) -> Opt
let messages = handoff
.messages
.iter()
.map(|message| message.text.as_str())
.map(|message| format!("{}: {}", message.role, message.text))
.collect::<Vec<_>>()
.join("\n");
(!messages.is_empty()).then_some(messages).or_else(|| {
@@ -605,7 +605,7 @@ mod tests {
};
assert_eq!(
realtime_text_from_handoff_request(&handoff),
Some("hello\nhi there".to_string())
Some("user: hello\nassistant: hi there".to_string())
);
}