Skip to content

Conversation

@daniel-lxs
Copy link
Member

Summary

Fixed duplicate tool rendering in the OpenAI Responses API providers (openai-native.ts and openai-codex.ts).

Problem

Tools were being rendered twice because both providers were emitting tool calls through two separate code paths:

  1. Streaming path: tool_call_partial events during response.tool_call_arguments.delta → processed by NativeToolCallParserfinalizeRawChunks() at stream end emits tool_call_endfinalizeStreamingToolCall() creates the final ToolUse
  2. Done event path: response.output_item.done with function_call/tool_call item → emitted a complete tool_call event → processed separately by Task.ts

Both paths resulted in the same tool being rendered, causing duplication.

Solution

Removed the tool_call emission from the response.output_item.done handler in both providers. The streaming path already handles tool call completion correctly through NativeToolCallParser.

Testing

  • All 79 related tests pass (65 openai-native + 7 openai-codex + 7 NativeToolCallParser)

Affected Providers

  • openai-native.ts - ✅ Fixed
  • openai-codex.ts - ✅ Fixed
  • openai.ts (Chat Completions API) - Not affected (uses different event pattern)

The openai-native and openai-codex providers were emitting tool calls twice:
1. tool_call_partial events during streaming (handled by NativeToolCallParser)
2. Complete tool_call from response.output_item.done events

This caused tools to be rendered twice in the UI.

Fix: Remove the tool_call emission from response.output_item.done since the
streaming path already handles tool call completion via NativeToolCallParser's
finalizeRawChunks() and finalizeStreamingToolCall() methods.
@roomote
Copy link
Contributor

roomote bot commented Jan 27, 2026

Rooviewer Clock   See task on Roo Cloud

Review complete. No issues found.

The fix correctly removes the duplicate tool_call emission from the response.output_item.done handler in both OpenAI Responses API providers. The streaming path through NativeToolCallParser is the proper mechanism for handling tool calls, and this change eliminates the redundant second code path that was causing tools to be rendered twice.

Mention @roomote in a comment to request specific changes to this pull request or fix all unresolved issues.

Copy link
Collaborator

@hannesrudolph hannesrudolph left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM. The removed code was defensive 'backward compatibility' for a non-streaming tool path that doesn't actually exist - createMessage() always streams, and completePrompt() doesn't use tools. The streaming path via NativeToolCallParser properly handles tool completion.

@dosubot dosubot bot added the lgtm This PR has been approved by a maintainer label Jan 27, 2026
@hannesrudolph hannesrudolph marked this pull request as ready for review January 27, 2026 17:19
@dosubot dosubot bot added size:M This PR changes 30-99 lines, ignoring generated files. bug Something isn't working labels Jan 27, 2026
@roomote
Copy link
Contributor

roomote bot commented Jan 27, 2026

Rooviewer Clock   See task on Roo Cloud

Review complete. No issues found.

The fix correctly removes duplicate tool_call emission from response.output_item.done handlers in both OpenAI Responses API providers. The streaming path through tool_call_partial events and NativeToolCallParser already handles tool call completion properly, making the removed code redundant.

Mention @roomote in a comment to request specific changes to this pull request or fix all unresolved issues.

@mrubens mrubens merged commit 17d3456 into main Jan 27, 2026
28 checks passed
@mrubens mrubens deleted the fix/duplicate-tool-rendering-responses-api branch January 27, 2026 18:33
@github-project-automation github-project-automation bot moved this from New to Done in Roo Code Roadmap Jan 27, 2026
@github-project-automation github-project-automation bot moved this from Triage to Done in Roo Code Roadmap Jan 27, 2026
@mrubens mrubens mentioned this pull request Jan 27, 2026
@roomote roomote bot mentioned this pull request Jan 27, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working lgtm This PR has been approved by a maintainer size:M This PR changes 30-99 lines, ignoring generated files.

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

4 participants