fix: extract tool arguments from response.completed in streaming#336
Closed
dannote wants to merge 1 commit intoOpenRouterTeam:dev-v6from
Closed
fix: extract tool arguments from response.completed in streaming#336dannote wants to merge 1 commit intoOpenRouterTeam:dev-v6from
dannote wants to merge 1 commit intoOpenRouterTeam:dev-v6from
Conversation
OpenRouter Responses API doesn't stream tool arguments via delta events. Instead, the complete arguments are only available in the final response.completed event's output array. This fix: - Accumulates argument deltas in case they are provided - Tracks emitted tool calls to avoid duplicates - Extracts tool call arguments from response.completed event - Only emits tool-input events when actual arguments are available
commit: |
Contributor
|
Thank you for reporting this issue. This was filed against v6.0.0-alpha.* which was a pre-release version. We've since released v2.0.0 with stable AI SDK v6 support. The alpha versions will be deprecated. Please try upgrading to @openrouter/ai-sdk-provider@latest (v2.0.0+) and let us know if you still experience this issue. Release reference: https://github.com/OpenRouterTeam/ai-sdk-provider/releases |
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.
Description
OpenRouter Responses API doesn't stream tool arguments via
response.function_call_arguments.deltaevents. Theargumentsfield inresponse.function_call_arguments.doneis empty, and the complete arguments are only available in the finalresponse.completedevent's output array.This causes tool calls to fail with validation errors like:
Changes
response.completedevent's output arraytool-input-*events when actual arguments are availableChecklist
pnpm stylecheckandpnpm typecheckpnpm testand all tests passChangeset
pnpm changesetto create a changeset file