-
Notifications
You must be signed in to change notification settings - Fork 2.8k
fix: remove duplicate tool_call emission from Responses API providers #11008
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
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.
Review complete. No issues found. The fix correctly removes the duplicate Mention @roomote in a comment to request specific changes to this pull request or fix all unresolved issues. |
hannesrudolph
left a comment
There was a problem hiding this 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.
Review complete. No issues found. The fix correctly removes duplicate Mention @roomote in a comment to request specific changes to this pull request or fix all unresolved issues. |
Summary
Fixed duplicate tool rendering in the OpenAI Responses API providers (
openai-native.tsandopenai-codex.ts).Problem
Tools were being rendered twice because both providers were emitting tool calls through two separate code paths:
tool_call_partialevents duringresponse.tool_call_arguments.delta→ processed byNativeToolCallParser→finalizeRawChunks()at stream end emitstool_call_end→finalizeStreamingToolCall()creates the final ToolUseresponse.output_item.donewith function_call/tool_call item → emitted a completetool_callevent → processed separately by Task.tsBoth paths resulted in the same tool being rendered, causing duplication.
Solution
Removed the
tool_callemission from theresponse.output_item.donehandler in both providers. The streaming path already handles tool call completion correctly throughNativeToolCallParser.Testing
Affected Providers
openai-native.ts- ✅ Fixedopenai-codex.ts- ✅ Fixedopenai.ts(Chat Completions API) - Not affected (uses different event pattern)