File tree Expand file tree Collapse file tree 1 file changed +10
-0
lines changed
tools/server/public_simplechat Expand file tree Collapse file tree 1 file changed +10
-0
lines changed Original file line number Diff line number Diff line change @@ -407,11 +407,21 @@ class SimpleChat {
407407
408408 /**
409409 * Add an entry into xchat.
410+ * If the last message in chat history is a ToolTemp message, discard it
411+ * as the runtime logic is asking for adding new message instead of promoting the tooltemp message.
412+ *
410413 * NOTE: A new copy is created and added into xchat.
411414 * Also update iLastSys system prompt index tracker
412415 * @param {ChatMessageEx } chatMsg
413416 */
414417 add ( chatMsg ) {
418+ if ( this . xchat . length > 0 ) {
419+ let lastIndex = this . xchat . length - 1 ;
420+ if ( this . xchat [ lastIndex ] . ns . role == Roles . ToolTemp ) {
421+ console . debug ( "DBUG:SimpleChat:Add:Discarding prev ToolTemp message..." )
422+ this . xchat . pop ( )
423+ }
424+ }
415425 this . xchat . push ( ChatMessageEx . newFrom ( chatMsg ) ) ;
416426 if ( chatMsg . ns . role == Roles . System ) {
417427 this . iLastSys = this . xchat . length - 1 ;
You can’t perform that action at this time.
0 commit comments