@@ -14,7 +14,7 @@ import { OpenRouterHandler } from "../api/providers/openrouter"
1414import { ApiStream } from "../api/transform/stream"
1515import CheckpointTracker from "../integrations/checkpoints/CheckpointTracker"
1616import { DIFF_VIEW_URI_SCHEME , DiffViewProvider } from "../integrations/editor/DiffViewProvider"
17- import { findToolName , formatContentBlockToMarkdown } from "../integrations/misc/export-markdown"
17+ import { formatContentBlockToMarkdown } from "../integrations/misc/export-markdown"
1818import { extractTextFromFile } from "../integrations/misc/extract-text"
1919import { showSystemNotification } from "../integrations/notifications"
2020import { TerminalManager } from "../integrations/terminal/TerminalManager"
@@ -860,42 +860,7 @@ export class Cline {
860860
861861 // need to make sure that the api conversation history can be resumed by the api, even if it goes out of sync with cline messages
862862
863- let existingApiConversationHistory : Anthropic . Messages . MessageParam [ ] = await this . getSavedApiConversationHistory ( )
864-
865- // v2.0 xml tags refactor caveat: since we don't use tools anymore, we need to replace all tool use blocks with a text block since the API disallows conversations with tool uses and no tool schema
866- const conversationWithoutToolBlocks = existingApiConversationHistory . map ( ( message ) => {
867- if ( Array . isArray ( message . content ) ) {
868- const newContent = message . content . map ( ( block ) => {
869- if ( block . type === "tool_use" ) {
870- // it's important we convert to the new tool schema format so the model doesn't get confused about how to invoke tools
871- const inputAsXml = Object . entries ( block . input as Record < string , string > )
872- . map ( ( [ key , value ] ) => `<${ key } >\n${ value } \n</${ key } >` )
873- . join ( "\n" )
874- return {
875- type : "text" ,
876- text : `<${ block . name } >\n${ inputAsXml } \n</${ block . name } >` ,
877- } as Anthropic . Messages . TextBlockParam
878- } else if ( block . type === "tool_result" ) {
879- // Convert block.content to text block array, removing images
880- const contentAsTextBlocks = Array . isArray ( block . content )
881- ? block . content . filter ( ( item ) => item . type === "text" )
882- : [ { type : "text" , text : block . content } ]
883- const textContent = contentAsTextBlocks . map ( ( item ) => item . text ) . join ( "\n\n" )
884- const toolName = findToolName ( block . tool_use_id , existingApiConversationHistory )
885- return {
886- type : "text" ,
887- text : `[${ toolName } Result]\n\n${ textContent } ` ,
888- } as Anthropic . Messages . TextBlockParam
889- }
890- return block
891- } )
892- return { ...message , content : newContent }
893- }
894- return message
895- } )
896- existingApiConversationHistory = conversationWithoutToolBlocks
897-
898- // FIXME: remove tool use blocks altogether
863+ const existingApiConversationHistory : Anthropic . Messages . MessageParam [ ] = await this . getSavedApiConversationHistory ( )
899864
900865 // if the last message is an assistant message, we need to check if there's tool use since every tool use has to have a tool response
901866 // if there's no tool use and only a text block, then we can just add a user message
0 commit comments