Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions src/core/assistant-message/presentAssistantMessage.ts
Original file line number Diff line number Diff line change
Expand Up @@ -277,6 +277,9 @@ export async function presentAssistantMessage(cline: Task) {
break
}

// Track if we've already pushed a tool result for this tool call (native protocol only)
let hasToolResult = false

const pushToolResult = (content: ToolResponse) => {
// Check if we're using native tool protocol
const toolProtocol = vscode.workspace
Expand All @@ -288,6 +291,14 @@ export async function presentAssistantMessage(cline: Task) {
const toolCallId = (block as any).id

if (isNative && toolCallId) {
// For native protocol, only allow ONE tool_result per tool call
if (hasToolResult) {
console.warn(
`[presentAssistantMessage] Skipping duplicate tool_result for tool_use_id: ${toolCallId}`,
)
return
}

// For native protocol, add as tool_result block
let resultContent: string
if (typeof content === "string") {
Expand All @@ -312,6 +323,8 @@ export async function presentAssistantMessage(cline: Task) {
tool_use_id: toolCallId,
content: resultContent,
} as Anthropic.ToolResultBlockParam)

hasToolResult = true
} else {
// For XML protocol, add as text blocks (legacy behavior)
cline.userMessageContent.push({ type: "text", text: `${toolDescription()} Result:` })
Expand Down