Browse Source

Pass clean conversation history to API for Anthropic

Matt Rubens 1 year ago
parent
commit
26f7ba07c2
2 changed files with 8 additions and 1 deletions
  1. 5 0
      .changeset/stupid-pears-help.md
  2. 3 1
      src/core/Cline.ts

+ 5 - 0
.changeset/stupid-pears-help.md

@@ -0,0 +1,5 @@
+---
+"roo-cline": patch
+---
+
+Hotfix

+ 3 - 1
src/core/Cline.ts

@@ -807,7 +807,9 @@ export class Cline {
 			}
 		}
 
-		const stream = this.api.createMessage(systemPrompt, this.apiConversationHistory)
+		// Convert to Anthropic.MessageParam by spreading only the API-required properties
+		const cleanConversationHistory = this.apiConversationHistory.map(({ role, content }) => ({ role, content }))
+		const stream = this.api.createMessage(systemPrompt, cleanConversationHistory)
 		const iterator = stream[Symbol.asyncIterator]()
 
 		try {