Skip to content

Commit 881fd20

Browse files
Eric Wheelerdaniel-lxs
authored andcommitted
fix: attach pendingFileMetadata to API conversation stream
This fixes an issue where file metadata from read_file operations was not being properly attached to the API conversation history stream. The pendingFileMetadata was being set correctly in the Task object but never incorporated into the conversation stream, causing subsequent reads of the same file to not recognize previously read ranges. The fix modifies addToApiConversationHistory to check for and include any pending file metadata and tool metadata in the message before adding it to the conversation stream, ensuring proper tracking of file reads across multiple operations. Signed-off-by: Eric Wheeler <[email protected]>
1 parent a6456bc commit 881fd20

File tree

1 file changed

+18
-1
lines changed

1 file changed

+18
-1
lines changed

src/core/task/Task.ts

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -338,7 +338,24 @@ export class Task extends EventEmitter<ClineEvents> {
338338
}
339339

340340
private async addToApiConversationHistory(message: Anthropic.MessageParam) {
341-
const messageWithTs = { ...message, ts: Date.now() }
341+
const messageWithTs: ApiMessage = {
342+
...message,
343+
ts: Date.now(),
344+
}
345+
346+
// Attach pending file metadata and tool metadata if they exist
347+
if (this.pendingFileMetadata && this.pendingFileMetadata.length > 0) {
348+
messageWithTs.files = this.pendingFileMetadata
349+
// Clear pending metadata after attaching it
350+
this.pendingFileMetadata = undefined
351+
}
352+
353+
if (this.pendingToolMetadata) {
354+
messageWithTs.tool = this.pendingToolMetadata
355+
// Clear pending tool metadata after attaching it
356+
this.pendingToolMetadata = undefined
357+
}
358+
342359
this.apiConversationHistory.push(messageWithTs)
343360
await this.saveApiConversationHistory()
344361
}

0 commit comments

Comments
 (0)