File tree Expand file tree Collapse file tree 1 file changed +13
-0
lines changed
src/core/assistant-message Expand file tree Collapse file tree 1 file changed +13
-0
lines changed Original file line number Diff line number Diff line change @@ -277,6 +277,9 @@ export async function presentAssistantMessage(cline: Task) {
277277 break
278278 }
279279
280+ // Track if we've already pushed a tool result for this tool call (native protocol only)
281+ let hasToolResult = false
282+
280283 const pushToolResult = ( content : ToolResponse ) => {
281284 // Check if we're using native tool protocol
282285 const toolProtocol = vscode . workspace
@@ -288,6 +291,14 @@ export async function presentAssistantMessage(cline: Task) {
288291 const toolCallId = ( block as any ) . id
289292
290293 if ( isNative && toolCallId ) {
294+ // For native protocol, only allow ONE tool_result per tool call
295+ if ( hasToolResult ) {
296+ console . warn (
297+ `[presentAssistantMessage] Skipping duplicate tool_result for tool_use_id: ${ toolCallId } ` ,
298+ )
299+ return
300+ }
301+
291302 // For native protocol, add as tool_result block
292303 let resultContent : string
293304 if ( typeof content === "string" ) {
@@ -312,6 +323,8 @@ export async function presentAssistantMessage(cline: Task) {
312323 tool_use_id : toolCallId ,
313324 content : resultContent ,
314325 } as Anthropic . ToolResultBlockParam )
326+
327+ hasToolResult = true
315328 } else {
316329 // For XML protocol, add as text blocks (legacy behavior)
317330 cline . userMessageContent . push ( { type : "text" , text : `${ toolDescription ( ) } Result:` } )
You can’t perform that action at this time.
0 commit comments