Skip to content
Source
Sign inSign up
TanStack/ai

fix(ai-mistral): ignore argument deltas after TOOL_CALL_END #2303

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

Showing 6 changed files with 19 additions and 0 deletions (loading 3).

x
0 of 6 viewed, 6 left
5 additions and 0 deletions.changeset/mistral-late-tool-arguments.mdAdded
View file
@@ -0,0 +1,5 @@
+---
+'@tanstack/ai-mistral': patch
+---
+​
+Ignore and log Mistral tool argument deltas that arrive after `TOOL_CALL_END`.
2 additions and 0 deletionsdocs/adapters/mistral.mdModified
View file
@@ -110,6 +110,8 @@
​
You now have a streaming Mistral chat. [Tools](../tools/tools) work the same as with every adapter. Mistral has no provider tools of its own, so define your tools with `toolDefinition()`.
​
+The adapter ignores argument deltas for a tool call after it emits `TOOL_CALL_END`.
+​
When a tool call hits the token limit, `metadata.tanstack.finishReason` is `length`.
Complete JSON arguments include a normalized `input` on `TOOL_CALL_END`.
Incomplete arguments keep the raw `args` and have no `input`.
12 additions and 0 deletionspackages/ai-mistral/src/adapters/text.tsModified
View file
@@ -746,6 +746,18 @@
​
const rawArgs = toolCallDelta.function?.arguments
+ if (rawArgs !== undefined && toolCall.ended) {
+ options.logger.errors(
+ `${this.name}.processMistralStreamChunks late arguments delta after TOOL_CALL_END`,
+ {
+ source: `${this.name}.processMistralStreamChunks`,