@@ -343,7 +343,7 @@ export class LlamaChatSession {
343343 /** @internal */ private readonly _chatLock = { } ;
344344 /** @internal */ private _chatHistory : ChatHistoryItem [ ] ;
345345 /** @internal */ private _lastEvaluation ?: LlamaChatResponse [ "lastEvaluation" ] ;
346- /** @internal */ private _canUseLastEvaluationForCompletion : boolean = true ;
346+ /** @internal */ private _canUseContextWindowForCompletion : boolean = true ;
347347 /** @internal */ private _chat : LlamaChat | null ;
348348 /** @internal */ public _chatHistoryStateRef = { } ;
349349 /** @internal */ public readonly _preloadAndCompleteAbortControllers = new Set < AbortController > ( ) ;
@@ -520,7 +520,7 @@ export class LlamaChatSession {
520520
521521 const supportsParallelFunctionCalling = this . _chat . chatWrapper . settings . functions . parallelism != null ;
522522 const [ abortController , disposeAbortController ] = wrapAbortSignal ( signal ) ;
523- let lastEvaluation = this . _canUseLastEvaluationForCompletion
523+ let lastEvaluation = this . _canUseContextWindowForCompletion
524524 ? this . _lastEvaluation
525525 : undefined ;
526526 let newChatHistory = appendUserMessageToChatHistory ( this . _chatHistory , prompt ) ;
@@ -726,7 +726,7 @@ export class LlamaChatSession {
726726 }
727727
728728 this . _lastEvaluation = lastEvaluation ;
729- this . _canUseLastEvaluationForCompletion = true ;
729+ this . _canUseContextWindowForCompletion = true ;
730730 this . _chatHistory = newChatHistory ;
731731 this . _chatHistoryStateRef = { } ;
732732
@@ -883,7 +883,7 @@ export class LlamaChatSession {
883883 contextWindow : asWithLastUserMessageRemoved ( lastEvaluation . contextWindow ) ,
884884 contextShiftMetadata : lastEvaluation . contextShiftMetadata
885885 } ;
886- this . _canUseLastEvaluationForCompletion = this . _chatHistory . at ( - 1 ) ?. type === "user" ;
886+ this . _canUseContextWindowForCompletion = this . _chatHistory . at ( - 1 ) ?. type === "user" ;
887887
888888 if ( ! stopOnAbortSignal && metadata . stopReason === "abort" && abortController . signal ?. aborted )
889889 throw abortController . signal . reason ;
@@ -923,6 +923,7 @@ export class LlamaChatSession {
923923 this . _chatHistory = structuredClone ( chatHistory ) ;
924924 this . _chatHistoryStateRef = { } ;
925925 this . _lastEvaluation = undefined ;
926+ this . _canUseContextWindowForCompletion = false ;
926927 }
927928
928929 /** Clear the chat history and reset it to the initial state. */
0 commit comments