mirror of
https://github.com/RooVetGit/Roo-Code.git
synced 2026-09-06 08:18:39 +00:00
fix: prevent duplicate tool_result blocks in native tool protocol (#9248)
This commit is contained in:
parent
375351616d
commit
bc99f41a51
1 changed files with 13 additions and 0 deletions
|
|
@ -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 isNative = isNativeProtocol(getToolProtocolFromSettings())
|
||||
|
|
@ -285,6 +288,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") {
|
||||
|
|
@ -309,6 +320,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:` })
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue