@@ -136,32 +136,39 @@ export class Cline extends EventEmitter<ClineEvents> {
136136 readonly rootTask : Cline | undefined = undefined
137137 readonly parentTask : Cline | undefined = undefined
138138 readonly taskNumber : number
139+
139140 isPaused : boolean = false
140141 pausedModeSlug : string = defaultModeSlug
141142 private pauseInterval : NodeJS . Timeout | undefined
142143
143144 readonly apiConfiguration : ApiConfiguration
144145 api : ApiHandler
146+ private promptCacheKey : string
147+
148+ rooIgnoreController ?: RooIgnoreController
145149 private fileContextTracker : FileContextTracker
146150 private urlContentFetcher : UrlContentFetcher
147151 browserSession : BrowserSession
148152 didEditFile : boolean = false
149153 customInstructions ?: string
154+
150155 diffStrategy ?: DiffStrategy
151156 diffEnabled : boolean = false
152157 fuzzyMatchThreshold : number
153158
154159 apiConversationHistory : ( Anthropic . MessageParam & { ts ?: number } ) [ ] = [ ]
155160 clineMessages : ClineMessage [ ] = [ ]
156- rooIgnoreController ?: RooIgnoreController
161+
157162 private askResponse ?: ClineAskResponse
158163 private askResponseText ?: string
159164 private askResponseImages ?: string [ ]
160165 private lastMessageTs ?: number
166+
161167 // Not private since it needs to be accessible by tools.
162168 consecutiveMistakeCount : number = 0
163169 consecutiveMistakeLimit : number
164170 consecutiveMistakeCountForApplyDiff : Map < string , number > = new Map ( )
171+
165172 // Not private since it needs to be accessible by tools.
166173 providerRef : WeakRef < ClineProvider >
167174 private abort : boolean = false
@@ -203,7 +210,6 @@ export class Cline extends EventEmitter<ClineEvents> {
203210 task,
204211 images,
205212 historyItem,
206- experiments,
207213 startTask = true ,
208214 rootTask,
209215 parentTask,
@@ -222,11 +228,15 @@ export class Cline extends EventEmitter<ClineEvents> {
222228
223229 this . rooIgnoreController = new RooIgnoreController ( this . cwd )
224230 this . fileContextTracker = new FileContextTracker ( provider , this . taskId )
231+
225232 this . rooIgnoreController . initialize ( ) . catch ( ( error ) => {
226233 console . error ( "Failed to initialize RooIgnoreController:" , error )
227234 } )
235+
228236 this . apiConfiguration = apiConfiguration
229237 this . api = buildApiHandler ( apiConfiguration )
238+ this . promptCacheKey = crypto . randomUUID ( )
239+
230240 this . urlContentFetcher = new UrlContentFetcher ( provider . context )
231241 this . browserSession = new BrowserSession ( provider . context )
232242 this . customInstructions = customInstructions
@@ -353,6 +363,8 @@ export class Cline extends EventEmitter<ClineEvents> {
353363 }
354364
355365 public async overwriteClineMessages ( newMessages : ClineMessage [ ] ) {
366+ // Reset the the prompt cache key since we've altered the conversation history.
367+ this . promptCacheKey = crypto . randomUUID ( )
356368 this . clineMessages = newMessages
357369 await this . saveClineMessages ( )
358370 }
@@ -652,6 +664,7 @@ export class Cline extends EventEmitter<ClineEvents> {
652664 modifiedClineMessages ,
653665 ( m ) => ! ( m . ask === "resume_task" || m . ask === "resume_completed_task" ) ,
654666 )
667+
655668 if ( lastRelevantMessageIndex !== - 1 ) {
656669 modifiedClineMessages . splice ( lastRelevantMessageIndex + 1 )
657670 }
@@ -661,6 +674,7 @@ export class Cline extends EventEmitter<ClineEvents> {
661674 modifiedClineMessages ,
662675 ( m ) => m . type === "say" && m . say === "api_req_started" ,
663676 )
677+
664678 if ( lastApiReqStartedIndex !== - 1 ) {
665679 const lastApiReqStarted = modifiedClineMessages [ lastApiReqStartedIndex ]
666680 const { cost, cancelReason } : ClineApiReqInfo = JSON . parse ( lastApiReqStarted . text || "{}" )
@@ -1092,7 +1106,7 @@ export class Cline extends EventEmitter<ClineEvents> {
10921106 return { role, content }
10931107 } )
10941108
1095- const stream = this . api . createMessage ( systemPrompt , cleanConversationHistory , this . taskId )
1109+ const stream = this . api . createMessage ( systemPrompt , cleanConversationHistory , this . promptCacheKey )
10961110 const iterator = stream [ Symbol . asyncIterator ] ( )
10971111
10981112 try {
0 commit comments