Skip to content
Source
Sign inSign up
TanStack/ai

fix(ai-openrouter): ignore Responses argument deltas after TOOL_CALL_END #2304

Opencanblmz1(GitHub profile, opens in a new tab)wants to merge 1 commit intomain fromrefs/pull/2304/headopened View on GitHub

Showing 6 changed files with 98 additions and 0 deletions (loading 2).

x
0 of 6 viewed, 6 left
5 additions and 0 deletions.changeset/openrouter-responses-late-args-delta.mdAdded
View file
@@ -0,0 +1,5 @@
+---
+'@tanstack/ai-openrouter': patch
+---
+​
+Ignore and log Responses argument deltas that arrive after a tool call's `TOOL_CALL_END`.
16 additions and 0 deletionspackages/ai-openrouter/src/adapters/responses-text.tsModified
View file
@@ -1424,6 +1424,22 @@
continue
+ // A delta after this call's END (from args.done or the
+ // output_item.done backstop) would reach consumers as ARGS after
+ // END, and they would append it to arguments that END already
+ // reported as complete. Drop it so the finalized arguments stand.
+ if (metadata.ended) {
+ options.logger.errors(
+ `${this.name}.processStreamChunks late function_call_arguments.delta after TOOL_CALL_END`,
+ {
+ source: `${this.name}.processStreamChunks`,
+ toolCallId: metadata.callId,
+ itemId,
+ rawDelta: chunk.delta,
+ },
+ )
+ continue
+ }
yield {
type: EventType.TOOL_CALL_ARGS,