Skip to content

fix: emit missing tool-input-end in multi-chunk tool call streaming#414

Open
metaslim wants to merge 1 commit intoOpenRouterTeam:mainfrom
metaslim:fix/missing-tool-input-end
Open

fix: emit missing tool-input-end in multi-chunk tool call streaming#414
metaslim wants to merge 1 commit intoOpenRouterTeam:mainfrom
metaslim:fix/missing-tool-input-end

Conversation

@metaslim
Copy link

Summary

Adds the missing tool-input-end event in the multi-chunk tool call merge path in doStream().

Problem

The single-chunk tool call path correctly emits the full sequence:

tool-input-start → tool-input-delta → tool-input-end → tool-call

But the multi-chunk merge path was missing tool-input-end:

tool-input-delta → tool-call (no tool-input-end)

This inconsistency may cause downstream stream consumers (like the AI SDK's stream processor) to wait for the missing tool-input-end event before processing the tool-call, contributing to perceived streaming delays in multi-step tool calling scenarios.

Change

Added controller.enqueue({ type: 'tool-input-end', id: toolCall.id }) before the tool-call emission in the multi-chunk path, matching the single-chunk path's behavior.

Related

Fixes #413

The single-chunk tool call path correctly emits the full sequence:
  tool-input-start → tool-input-delta → tool-input-end → tool-call

But the multi-chunk merge path was missing tool-input-end:
  tool-input-delta → tool-call (no tool-input-end)

This inconsistency may cause downstream stream consumers to wait for
the missing tool-input-end event, contributing to perceived streaming
delays in multi-step tool calling scenarios.

Fixes OpenRouterTeam#413
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.

Tool call events are buffered until stream ends (flush) causing perceived streaming delay

1 participant