@@ -80,6 +80,7 @@ import {
8080import { processUserContentMentions } from "../mentions/processUserContentMentions"
8181import { ApiMessage } from "../task-persistence/apiMessages"
8282import { getMessagesSinceLastSummary , summarizeConversationIfNeeded } from "../condense"
83+ import { maybeRemoveImageBlocks } from "../../api/transform/image-cleaning"
8384
8485export type ClineEvents = {
8586 message : [ { action : "created" | "updated" ; message : ClineMessage } ]
@@ -1484,32 +1485,9 @@ export class Task extends EventEmitter<ClineEvents> {
14841485 }
14851486
14861487 const messagesSinceLastSummary = getMessagesSinceLastSummary ( this . apiConversationHistory )
1487-
1488- // Clean conversation history by:
1489- // 1. Converting to Anthropic.MessageParam by spreading only the API-required properties.
1490- // 2. Converting image blocks to text descriptions if model doesn't support images.
1491- const cleanConversationHistory = messagesSinceLastSummary . map ( ( { role, content } ) => {
1492- // Handle array content (could contain image blocks).
1493- if ( Array . isArray ( content ) ) {
1494- if ( ! this . api . getModel ( ) . info . supportsImages ) {
1495- // Convert image blocks to text descriptions.
1496- content = content . map ( ( block ) => {
1497- if ( block . type === "image" ) {
1498- // Convert image blocks to text descriptions.
1499- // Note: We can't access the actual image content/url due to API limitations,
1500- // but we can indicate that an image was present in the conversation.
1501- return {
1502- type : "text" ,
1503- text : "[Referenced image in conversation]" ,
1504- }
1505- }
1506- return block
1507- } )
1508- }
1509- }
1510-
1511- return { role, content }
1512- } )
1488+ const cleanConversationHistory = maybeRemoveImageBlocks ( messagesSinceLastSummary , this . api ) . map (
1489+ ( { role, content } ) => ( { role, content } ) ,
1490+ )
15131491
15141492 const stream = this . api . createMessage ( systemPrompt , cleanConversationHistory )
15151493 const iterator = stream [ Symbol . asyncIterator ] ( )
0 commit comments