Skip to content

Commit a5e0d49

Browse files
committed
test(dispatch): pin attachment failure note ordering
1 parent 7d33b8e commit a5e0d49

1 file changed

Lines changed: 31 additions & 0 deletions

File tree

src/dispatch.rs

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -796,6 +796,37 @@ mod tests {
796796
assert!(matches!(&blocks[3], ContentBlock::Image { .. }));
797797
}
798798

799+
#[test]
800+
fn pack_arrival_event_keeps_text_extras_order_before_prompt() {
801+
let extra = vec![
802+
ContentBlock::Text {
803+
text: "[Voice message transcript]: hello".into(),
804+
},
805+
ContentBlock::Text {
806+
text: "[Attachment validation failed]: the user attempted to attach `photo.png`"
807+
.into(),
808+
},
809+
ContentBlock::Image {
810+
media_type: "image/png".into(),
811+
data: "abc".into(),
812+
},
813+
];
814+
let blocks = AdapterRouter::pack_arrival_event("{}", "typed prompt", extra);
815+
816+
assert_eq!(blocks.len(), 5);
817+
assert!(
818+
matches!(&blocks[0], ContentBlock::Text { text } if text.contains("<sender_context>"))
819+
);
820+
assert!(
821+
matches!(&blocks[1], ContentBlock::Text { text } if text.contains("Voice message transcript"))
822+
);
823+
assert!(
824+
matches!(&blocks[2], ContentBlock::Text { text } if text.contains("Attachment validation failed"))
825+
);
826+
assert!(matches!(&blocks[3], ContentBlock::Text { text } if text == "typed prompt"));
827+
assert!(matches!(&blocks[4], ContentBlock::Image { .. }));
828+
}
829+
799830
#[test]
800831
fn pack_arrival_event_batch_n2() {
801832
// Two arrival events concatenated → 2 (header + prompt) pairs = 4 blocks.

0 commit comments

Comments
 (0)