fix(sdk): yield manual tool calls from getNewMessagesStream()#6
Merged
mattapperson merged 3 commits intomainfrom Apr 4, 2026
Merged
fix(sdk): yield manual tool calls from getNewMessagesStream()#6mattapperson merged 3 commits intomainfrom
mattapperson merged 3 commits intomainfrom
Conversation
When callModel is used with a mix of auto-execute and manual (no execute function) tools, getNewMessagesStream() would silently drop function_call items for manual tools. The data was present in finalResponse but never yielded because the finalResponse block only yielded messages. Now yields function_call items from finalResponse before the message, matching the behavior of getItemsStream() which already handles this correctly via the broadcaster pattern.
Covers edge cases in getNewMessagesStream and getItemsStream: - Duplicate suppression when manual tools appear in both rounds and finalResponse - Multiple manual tools in a single response - Unknown/hallucinated tool names not in the tools list - Auto-execute tools not leaking through yieldManualToolCalls - Null and empty finalResponse handling - Non-function_call items in finalResponse ignored - Empty arguments string - in_progress status function_call items - No tools configured with function_calls in response - Ordering: manual tool calls yielded before final message
Track yielded callIds across execution rounds and finalResponse to prevent the same manual tool function_call from being yielded twice when it appears in both a round's response.output and in finalResponse.
mattokafor
approved these changes
Apr 3, 2026
robert-j-y
approved these changes
Apr 3, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
getNewMessagesStream()silently droppingfunction_callitems for manual tools (noexecutefunction) when mixed with auto-execute toolsfinalResponsebut never yielded because thefinalResponseblock only yielded messagesfunction_callitems fromfinalResponsebefore the message, matching the existing behavior ofgetItemsStream()Re-creation of https://github.com/OpenRouterTeam/openrouter-web/pull/16470 on this repo after the SDK was broken out of the monorepo.
Changes
isManualToolCall()andyieldManualToolCalls()helper methods toModelResultgetNewMessagesStream()now yields manual toolfunction_callitems fromfinalResponsegetItemsStreamwith manual toolsTest plan
npm run buildpassesnpx vitest run tests/unit/)npx vitest run tests/e2e/call-model.test.ts)callModelwith mixed auto-execute + manual tools, consume viagetNewMessagesStream(), confirm manual toolfunction_callitems are yielded