File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff 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.
You can’t perform that action at this time.
0 commit comments