You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
// NOTE: it's okay that we overwriteConversationHistory in resume task since we're only ever removing the last user message and not anything in the middle which would affect this range
// Make sure the last message being removed is a user message, so that the next message after the initial task message is an assistant message. This preservers the user-assistant-user-assistant structure.
25
+
// NOTE: anthropic format messages are always user-assistant-user-assistant, while openai format messages can have multiple user messages in a row (we use anthropic format throughout cline)
26
+
if(messages[rangeEndIndex].role!=="user"){
27
+
rangeEndIndex-=1
28
+
}
29
+
30
+
// this is an inclusive range that will be removed from the conversation history
31
+
return[rangeStartIndex,rangeEndIndex]
32
+
}
33
+
34
+
getTruncatedMessages(
35
+
messages: Anthropic.Messages.MessageParam[],
36
+
deletedRange: [number,number]|undefined,
37
+
): Anthropic.Messages.MessageParam[]{
38
+
if(!deletedRange){
39
+
returnmessages
40
+
}
41
+
42
+
const[start,end]=deletedRange
43
+
// the range is inclusive - both start and end indices and everything in between will be removed from the final result.
44
+
// NOTE: if you try to console log these, don't forget that logging a reference to an array may not provide the same result as logging a slice() snapshot of that array at that exact moment. The following DOES in fact include the latest assistant message.
0 commit comments