@@ -614,8 +614,14 @@ mod tests {
614
614
#[ tokio:: test]
615
615
async fn test_conversation_state_history_handling_truncation ( ) {
616
616
let tool_manager = ToolManager :: default ( ) ;
617
- let mut conversation_state =
618
- ConversationState :: new ( Context :: new_fake ( ) , tool_manager. load_tools ( ) . await . unwrap ( ) , None ) . await ;
617
+ let buf = Vec :: < u8 > :: new ( ) ;
618
+ let mut output = std:: io:: BufWriter :: new ( buf) ;
619
+ let mut conversation_state = ConversationState :: new (
620
+ Context :: new_fake ( ) ,
621
+ tool_manager. load_tools ( & mut output) . await . unwrap ( ) ,
622
+ None ,
623
+ )
624
+ . await ;
619
625
620
626
// First, build a large conversation history. We need to ensure that the order is always
621
627
// User -> Assistant -> User -> Assistant ...and so on.
@@ -636,8 +642,14 @@ mod tests {
636
642
async fn test_conversation_state_history_handling_with_tool_results ( ) {
637
643
// Build a long conversation history of tool use results.
638
644
let tool_manager = ToolManager :: default ( ) ;
639
- let mut conversation_state =
640
- ConversationState :: new ( Context :: new_fake ( ) , tool_manager. load_tools ( ) . await . unwrap ( ) , None ) . await ;
645
+ let buf = Vec :: < u8 > :: new ( ) ;
646
+ let mut output = std:: io:: BufWriter :: new ( buf) ;
647
+ let mut conversation_state = ConversationState :: new (
648
+ Context :: new_fake ( ) ,
649
+ tool_manager. load_tools ( & mut output) . await . unwrap ( ) ,
650
+ None ,
651
+ )
652
+ . await ;
641
653
conversation_state. append_new_user_message ( "start" . to_string ( ) ) . await ;
642
654
for i in 0 ..=( MAX_CONVERSATION_STATE_HISTORY_LEN + 100 ) {
643
655
let s = conversation_state. as_sendable_conversation_state ( ) . await ;
@@ -659,8 +671,12 @@ mod tests {
659
671
}
660
672
661
673
// Build a long conversation history of user messages mixed in with tool results.
662
- let mut conversation_state =
663
- ConversationState :: new ( Context :: new_fake ( ) , tool_manager. load_tools ( ) . await . unwrap ( ) , None ) . await ;
674
+ let mut conversation_state = ConversationState :: new (
675
+ Context :: new_fake ( ) ,
676
+ tool_manager. load_tools ( & mut output) . await . unwrap ( ) ,
677
+ None ,
678
+ )
679
+ . await ;
664
680
conversation_state. append_new_user_message ( "start" . to_string ( ) ) . await ;
665
681
for i in 0 ..=( MAX_CONVERSATION_STATE_HISTORY_LEN + 100 ) {
666
682
let s = conversation_state. as_sendable_conversation_state ( ) . await ;
@@ -697,7 +713,10 @@ mod tests {
697
713
ctx. fs ( ) . write ( AMAZONQ_FILENAME , "test context" ) . await . unwrap ( ) ;
698
714
699
715
let tool_manager = ToolManager :: default ( ) ;
700
- let mut conversation_state = ConversationState :: new ( ctx, tool_manager. load_tools ( ) . await . unwrap ( ) , None ) . await ;
716
+ let buf = Vec :: < u8 > :: new ( ) ;
717
+ let mut output = std:: io:: BufWriter :: new ( buf) ;
718
+ let mut conversation_state =
719
+ ConversationState :: new ( ctx, tool_manager. load_tools ( & mut output) . await . unwrap ( ) , None ) . await ;
701
720
702
721
// First, build a large conversation history. We need to ensure that the order is always
703
722
// User -> Assistant -> User -> Assistant ...and so on.
0 commit comments