Skip to content

fix: extract tool arguments from response.completed in streaming#336

Closed
dannote wants to merge 1 commit intoOpenRouterTeam:dev-v6from
dannote:fix-tools-v6
Closed

fix: extract tool arguments from response.completed in streaming#336
dannote wants to merge 1 commit intoOpenRouterTeam:dev-v6from
dannote:fix-tools-v6

Conversation

@dannote
Copy link

@dannote dannote commented Jan 20, 2026

Description

OpenRouter Responses API doesn't stream tool arguments via response.function_call_arguments.delta events. The arguments field in response.function_call_arguments.done is empty, and the complete arguments are only available in the final response.completed event's output array.

This causes tool calls to fail with validation errors like:

Invalid input for tool weather: Type validation failed: Value: {}.
Error message: [{"expected":"string","code":"invalid_type","path":["location"],"message":"Required"}]

Changes

  • Accumulate argument deltas during streaming (in case a provider does send them)
  • Track emitted tool calls to avoid duplicates
  • Extract tool call arguments from response.completed event's output array
  • Only emit tool-input-* events when actual arguments are available

Checklist

  • I have run pnpm stylecheck and pnpm typecheck
  • I have run pnpm test and all tests pass
  • I have added tests for my changes (if applicable)
  • I have updated documentation (if applicable)

Changeset

  • I have run pnpm changeset to create a changeset file

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
@robert-j-y robert-j-y self-requested a review January 23, 2026 19:14
@pkg-pr-new
Copy link

pkg-pr-new bot commented Jan 23, 2026

Open in StackBlitz

npm i https://pkg.pr.new/OpenRouterTeam/ai-sdk-provider/@openrouter/ai-sdk-provider@336

commit: fb49892

@robert-j-y
Copy link
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

@robert-j-y robert-j-y closed this Jan 23, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants