@@ -375,7 +375,10 @@ export class ChatDatabase {
375
375
376
376
formatChatHistoryMessage ( message : Message ) : Message {
377
377
if ( message . type === ( 'prompt' as ChatItemType ) ) {
378
- const hasToolResults = message . userInputMessageContext ?. toolResults
378
+ let hasToolResults = false
379
+ if ( message . userInputMessageContext ?. toolResults ) {
380
+ hasToolResults = message . userInputMessageContext ?. toolResults . length > 0
381
+ }
379
382
return {
380
383
...message ,
381
384
userInputMessageContext : {
@@ -589,6 +592,13 @@ export class ChatDatabase {
589
592
590
593
// Make sure the last stored message is from the assistant (type === 'answer'), else drop
591
594
if ( messages . length > 0 && messages [ messages . length - 1 ] . type === ( 'prompt' as ChatItemType ) ) {
595
+ // When user aborts some in-progress tooluse event, we should still send the previous toolResult back
596
+ if ( messages [ messages . length - 1 ] . userInputMessageContext ?. toolResults ) {
597
+ if ( newUserMessage . userInputMessage ?. userInputMessageContext ) {
598
+ newUserMessage . userInputMessage . userInputMessageContext . toolResults =
599
+ messages [ messages . length - 1 ] . userInputMessageContext ?. toolResults
600
+ }
601
+ }
592
602
messages . pop ( )
593
603
this . #features. logging . debug ( 'Dropped trailing user message' )
594
604
}
@@ -686,10 +696,10 @@ export class ChatDatabase {
686
696
687
697
getModelId ( ) : string | undefined {
688
698
const settings = this . getSettings ( )
689
- return settings ?. modelId
699
+ return settings ?. modelId === '' ? undefined : settings ?. modelId
690
700
}
691
701
692
702
setModelId ( modelId : string | undefined ) : void {
693
- this . updateSettings ( { modelId } )
703
+ this . updateSettings ( { modelId : modelId === '' ? undefined : modelId } )
694
704
}
695
705
}
0 commit comments