File tree Expand file tree Collapse file tree 1 file changed +31
-1
lines changed Expand file tree Collapse file tree 1 file changed +31
-1
lines changed Original file line number Diff line number Diff line change @@ -1015,7 +1015,37 @@ impl ChatContext {
10151015 execute ! ( self . output, cursor:: Hide , style:: Print ( "\n " ) ) ?;
10161016 self . spinner = Some ( Spinner :: new ( Spinners :: Dots , "Creating summary..." . to_string ( ) ) ) ;
10171017 }
1018- let response = self . client . send_message ( summary_state) . await ?;
1018+ let response = self . client . send_message ( summary_state) . await ;
1019+
1020+ // TODO(brandonskiser): This is a temporary hotfix for failing compaction. We should instead
1021+ // retry except with less context included.
1022+ let response = match response {
1023+ Ok ( res) => res,
1024+ Err ( e) => match e {
1025+ fig_api_client:: Error :: ContextWindowOverflow => {
1026+ self . conversation_state . clear ( true ) ;
1027+ if self . interactive {
1028+ self . spinner . take ( ) ;
1029+ execute ! (
1030+ self . output,
1031+ terminal:: Clear ( terminal:: ClearType :: CurrentLine ) ,
1032+ cursor:: MoveToColumn ( 0 ) ,
1033+ style:: SetForegroundColor ( Color :: Yellow ) ,
1034+ style:: Print (
1035+ "The context window usage has overflowed. Clearing the conversation history.\n \n "
1036+ ) ,
1037+ style:: SetAttribute ( Attribute :: Reset )
1038+ ) ?;
1039+ }
1040+ return Ok ( ChatState :: PromptUser {
1041+ tool_uses,
1042+ pending_tool_index,
1043+ skip_printing_tools : true ,
1044+ } ) ;
1045+ } ,
1046+ e => return Err ( e. into ( ) ) ,
1047+ } ,
1048+ } ;
10191049
10201050 let summary = {
10211051 let mut parser = ResponseParser :: new ( response) ;
You can’t perform that action at this time.
0 commit comments