diff --git a/.changeset/fix-anthropic-multi-turn-tool-calls.md b/.changeset/fix-anthropic-multi-turn-tool-calls.md deleted file mode 100644 index 34553ece..00000000 --- a/.changeset/fix-anthropic-multi-turn-tool-calls.md +++ /dev/null @@ -1,35 +0,0 @@ ---- -'@tanstack/ai': patch -'@tanstack/ai-client': patch -'@tanstack/ai-anthropic': patch -'@tanstack/ai-gemini': patch ---- - -fix(ai, ai-client, ai-anthropic, ai-gemini): fix multi-turn conversations failing after tool calls - -**Core (@tanstack/ai):** - -- Lazy assistant message creation: `StreamProcessor` now defers creating the assistant message until the first content-bearing chunk arrives (text, tool call, thinking, or error), eliminating empty `parts: []` messages from appearing during auto-continuation when the model returns no content -- Add `prepareAssistantMessage()` (lazy) alongside deprecated `startAssistantMessage()` (eager, backwards-compatible) -- Add `getCurrentAssistantMessageId()` to check if a message was created -- **Rewrite `uiMessageToModelMessages()` to preserve part ordering**: the function now walks parts sequentially instead of separating by type, producing correctly interleaved assistant/tool messages (text1 + toolCall1 → toolResult1 → text2 + toolCall2 → toolResult2) instead of concatenating all text and batching all tool calls. This fixes multi-round tool flows where the model would see garbled conversation history and re-call tools unnecessarily. -- Deduplicate tool result messages: when a client tool has both a `tool-result` part and a `tool-call` part with `output`, only one `role: 'tool'` message is emitted per tool call ID - -**Client (@tanstack/ai-client):** - -- Update `ChatClient.processStream()` to use lazy assistant message creation, preventing UI flicker from empty messages being created then removed - -**Anthropic:** - -- Fix consecutive user-role messages violating Anthropic's alternating role requirement by merging them in `formatMessages` -- Deduplicate `tool_result` blocks with the same `tool_use_id` -- Filter out empty assistant messages from conversation history -- Suppress duplicate `RUN_FINISHED` event from `message_stop` when `message_delta` already emitted one -- Fix `TEXT_MESSAGE_END` incorrectly emitting for `tool_use` content blocks -- Add Claude Opus 4.6 model support with adaptive thinking and effort parameter - -**Gemini:** - -- Fix consecutive user-role messages violating Gemini's alternating role requirement by merging them in `formatMessages` -- Deduplicate `functionResponse` parts with the same name (tool call ID) -- Filter out empty model messages from conversation history diff --git a/.changeset/tighten-adapter-contract.md b/.changeset/tighten-adapter-contract.md deleted file mode 100644 index 78a7af3f..00000000 --- a/.changeset/tighten-adapter-contract.md +++ /dev/null @@ -1,25 +0,0 @@ ---- -'@tanstack/ai': minor -'@tanstack/ai-anthropic': minor -'@tanstack/ai-gemini': minor ---- - -Tighten the AG-UI adapter contract and simplify the core stream processor. - -**Breaking type changes:** - -- `TextMessageContentEvent.delta` is now required (was optional) -- `StepFinishedEvent.delta` is now required (was optional) - -All first-party adapters already sent `delta` on every event, so this is a type-level enforcement of existing behavior. Community adapters that follow the reference implementations will not need code changes. - -**Core processor simplifications:** - -- `TEXT_MESSAGE_START` now resets text segment state, replacing heuristic overlap detection -- `TOOL_CALL_END` is now the authoritative signal for tool call input completion -- Removed delta/content fallback logic, whitespace-only message cleanup, and finish-reason conflict arbitration from the processor - -**Adapter fixes:** - -- Gemini: filter whitespace-only text parts, fix STEP_FINISHED content accumulation, emit fresh TEXT_MESSAGE_START after tool calls -- Anthropic: emit fresh TEXT_MESSAGE_START after tool_use blocks for proper text segmentation diff --git a/examples/ts-svelte-chat/CHANGELOG.md b/examples/ts-svelte-chat/CHANGELOG.md index 8a0ab92c..19dd8e31 100644 --- a/examples/ts-svelte-chat/CHANGELOG.md +++ b/examples/ts-svelte-chat/CHANGELOG.md @@ -1,5 +1,18 @@ # ts-svelte-chat +## 0.1.11 + +### Patch Changes + +- Updated dependencies [[`5d98472`](https://github.com/TanStack/ai/commit/5d984722e1f84725e3cfda834fbda3d0341ecedd), [`5d98472`](https://github.com/TanStack/ai/commit/5d984722e1f84725e3cfda834fbda3d0341ecedd)]: + - @tanstack/ai@0.5.0 + - @tanstack/ai-client@0.4.4 + - @tanstack/ai-anthropic@0.5.0 + - @tanstack/ai-gemini@0.5.0 + - @tanstack/ai-ollama@0.5.0 + - @tanstack/ai-openai@0.5.0 + - @tanstack/ai-svelte@0.5.0 + ## 0.1.10 ### Patch Changes diff --git a/examples/ts-svelte-chat/package.json b/examples/ts-svelte-chat/package.json index c98dcaa0..acab1ed5 100644 --- a/examples/ts-svelte-chat/package.json +++ b/examples/ts-svelte-chat/package.json @@ -1,7 +1,7 @@ { "name": "ts-svelte-chat", "private": true, - "version": "0.1.10", + "version": "0.1.11", "type": "module", "scripts": { "dev": "vite dev --port 3000", diff --git a/examples/ts-vue-chat/CHANGELOG.md b/examples/ts-vue-chat/CHANGELOG.md index 9d5142ad..94a6bed4 100644 --- a/examples/ts-vue-chat/CHANGELOG.md +++ b/examples/ts-vue-chat/CHANGELOG.md @@ -1,5 +1,19 @@ # ts-vue-chat +## 0.1.11 + +### Patch Changes + +- Updated dependencies [[`5d98472`](https://github.com/TanStack/ai/commit/5d984722e1f84725e3cfda834fbda3d0341ecedd), [`5d98472`](https://github.com/TanStack/ai/commit/5d984722e1f84725e3cfda834fbda3d0341ecedd)]: + - @tanstack/ai@0.5.0 + - @tanstack/ai-client@0.4.4 + - @tanstack/ai-anthropic@0.5.0 + - @tanstack/ai-gemini@0.5.0 + - @tanstack/ai-ollama@0.5.0 + - @tanstack/ai-openai@0.5.0 + - @tanstack/ai-vue@0.5.0 + - @tanstack/ai-vue-ui@0.1.9 + ## 0.1.10 ### Patch Changes diff --git a/examples/ts-vue-chat/package.json b/examples/ts-vue-chat/package.json index 39710b4d..e94fe96e 100644 --- a/examples/ts-vue-chat/package.json +++ b/examples/ts-vue-chat/package.json @@ -1,6 +1,6 @@ { "name": "ts-vue-chat", - "version": "0.1.10", + "version": "0.1.11", "private": true, "type": "module", "scripts": { diff --git a/examples/vanilla-chat/CHANGELOG.md b/examples/vanilla-chat/CHANGELOG.md index 999f574e..17433a34 100644 --- a/examples/vanilla-chat/CHANGELOG.md +++ b/examples/vanilla-chat/CHANGELOG.md @@ -1,5 +1,12 @@ # vanilla-chat +## 0.0.13 + +### Patch Changes + +- Updated dependencies [[`5d98472`](https://github.com/TanStack/ai/commit/5d984722e1f84725e3cfda834fbda3d0341ecedd)]: + - @tanstack/ai-client@0.4.4 + ## 0.0.12 ### Patch Changes diff --git a/examples/vanilla-chat/package.json b/examples/vanilla-chat/package.json index 32151544..d4ba014f 100644 --- a/examples/vanilla-chat/package.json +++ b/examples/vanilla-chat/package.json @@ -2,7 +2,7 @@ "name": "vanilla-chat", "private": true, "type": "module", - "version": "0.0.12", + "version": "0.0.13", "scripts": { "start": "vite --port 3001", "dev": "vite --port 3001", diff --git a/packages/typescript/ai-anthropic/CHANGELOG.md b/packages/typescript/ai-anthropic/CHANGELOG.md index fc6093a8..245ab88c 100644 --- a/packages/typescript/ai-anthropic/CHANGELOG.md +++ b/packages/typescript/ai-anthropic/CHANGELOG.md @@ -1,5 +1,56 @@ # @tanstack/ai-anthropic +## 0.5.0 + +### Minor Changes + +- Tighten the AG-UI adapter contract and simplify the core stream processor. ([#275](https://github.com/TanStack/ai/pull/275)) + + **Breaking type changes:** + - `TextMessageContentEvent.delta` is now required (was optional) + - `StepFinishedEvent.delta` is now required (was optional) + + All first-party adapters already sent `delta` on every event, so this is a type-level enforcement of existing behavior. Community adapters that follow the reference implementations will not need code changes. + + **Core processor simplifications:** + - `TEXT_MESSAGE_START` now resets text segment state, replacing heuristic overlap detection + - `TOOL_CALL_END` is now the authoritative signal for tool call input completion + - Removed delta/content fallback logic, whitespace-only message cleanup, and finish-reason conflict arbitration from the processor + + **Adapter fixes:** + - Gemini: filter whitespace-only text parts, fix STEP_FINISHED content accumulation, emit fresh TEXT_MESSAGE_START after tool calls + - Anthropic: emit fresh TEXT_MESSAGE_START after tool_use blocks for proper text segmentation + +### Patch Changes + +- fix(ai, ai-client, ai-anthropic, ai-gemini): fix multi-turn conversations failing after tool calls ([#275](https://github.com/TanStack/ai/pull/275)) + + **Core (@tanstack/ai):** + - Lazy assistant message creation: `StreamProcessor` now defers creating the assistant message until the first content-bearing chunk arrives (text, tool call, thinking, or error), eliminating empty `parts: []` messages from appearing during auto-continuation when the model returns no content + - Add `prepareAssistantMessage()` (lazy) alongside deprecated `startAssistantMessage()` (eager, backwards-compatible) + - Add `getCurrentAssistantMessageId()` to check if a message was created + - **Rewrite `uiMessageToModelMessages()` to preserve part ordering**: the function now walks parts sequentially instead of separating by type, producing correctly interleaved assistant/tool messages (text1 + toolCall1 → toolResult1 → text2 + toolCall2 → toolResult2) instead of concatenating all text and batching all tool calls. This fixes multi-round tool flows where the model would see garbled conversation history and re-call tools unnecessarily. + - Deduplicate tool result messages: when a client tool has both a `tool-result` part and a `tool-call` part with `output`, only one `role: 'tool'` message is emitted per tool call ID + + **Client (@tanstack/ai-client):** + - Update `ChatClient.processStream()` to use lazy assistant message creation, preventing UI flicker from empty messages being created then removed + + **Anthropic:** + - Fix consecutive user-role messages violating Anthropic's alternating role requirement by merging them in `formatMessages` + - Deduplicate `tool_result` blocks with the same `tool_use_id` + - Filter out empty assistant messages from conversation history + - Suppress duplicate `RUN_FINISHED` event from `message_stop` when `message_delta` already emitted one + - Fix `TEXT_MESSAGE_END` incorrectly emitting for `tool_use` content blocks + - Add Claude Opus 4.6 model support with adaptive thinking and effort parameter + + **Gemini:** + - Fix consecutive user-role messages violating Gemini's alternating role requirement by merging them in `formatMessages` + - Deduplicate `functionResponse` parts with the same name (tool call ID) + - Filter out empty model messages from conversation history + +- Updated dependencies [[`5d98472`](https://github.com/TanStack/ai/commit/5d984722e1f84725e3cfda834fbda3d0341ecedd), [`5d98472`](https://github.com/TanStack/ai/commit/5d984722e1f84725e3cfda834fbda3d0341ecedd)]: + - @tanstack/ai@0.5.0 + ## 0.4.2 ### Patch Changes diff --git a/packages/typescript/ai-anthropic/package.json b/packages/typescript/ai-anthropic/package.json index eecbe2a6..84b31808 100644 --- a/packages/typescript/ai-anthropic/package.json +++ b/packages/typescript/ai-anthropic/package.json @@ -1,6 +1,6 @@ { "name": "@tanstack/ai-anthropic", - "version": "0.4.2", + "version": "0.5.0", "description": "Anthropic Claude adapter for TanStack AI", "author": "", "license": "MIT", diff --git a/packages/typescript/ai-client/CHANGELOG.md b/packages/typescript/ai-client/CHANGELOG.md index 9f384597..3f5a9ad9 100644 --- a/packages/typescript/ai-client/CHANGELOG.md +++ b/packages/typescript/ai-client/CHANGELOG.md @@ -1,5 +1,37 @@ # @tanstack/ai-client +## 0.4.4 + +### Patch Changes + +- fix(ai, ai-client, ai-anthropic, ai-gemini): fix multi-turn conversations failing after tool calls ([#275](https://github.com/TanStack/ai/pull/275)) + + **Core (@tanstack/ai):** + - Lazy assistant message creation: `StreamProcessor` now defers creating the assistant message until the first content-bearing chunk arrives (text, tool call, thinking, or error), eliminating empty `parts: []` messages from appearing during auto-continuation when the model returns no content + - Add `prepareAssistantMessage()` (lazy) alongside deprecated `startAssistantMessage()` (eager, backwards-compatible) + - Add `getCurrentAssistantMessageId()` to check if a message was created + - **Rewrite `uiMessageToModelMessages()` to preserve part ordering**: the function now walks parts sequentially instead of separating by type, producing correctly interleaved assistant/tool messages (text1 + toolCall1 → toolResult1 → text2 + toolCall2 → toolResult2) instead of concatenating all text and batching all tool calls. This fixes multi-round tool flows where the model would see garbled conversation history and re-call tools unnecessarily. + - Deduplicate tool result messages: when a client tool has both a `tool-result` part and a `tool-call` part with `output`, only one `role: 'tool'` message is emitted per tool call ID + + **Client (@tanstack/ai-client):** + - Update `ChatClient.processStream()` to use lazy assistant message creation, preventing UI flicker from empty messages being created then removed + + **Anthropic:** + - Fix consecutive user-role messages violating Anthropic's alternating role requirement by merging them in `formatMessages` + - Deduplicate `tool_result` blocks with the same `tool_use_id` + - Filter out empty assistant messages from conversation history + - Suppress duplicate `RUN_FINISHED` event from `message_stop` when `message_delta` already emitted one + - Fix `TEXT_MESSAGE_END` incorrectly emitting for `tool_use` content blocks + - Add Claude Opus 4.6 model support with adaptive thinking and effort parameter + + **Gemini:** + - Fix consecutive user-role messages violating Gemini's alternating role requirement by merging them in `formatMessages` + - Deduplicate `functionResponse` parts with the same name (tool call ID) + - Filter out empty model messages from conversation history + +- Updated dependencies [[`5d98472`](https://github.com/TanStack/ai/commit/5d984722e1f84725e3cfda834fbda3d0341ecedd), [`5d98472`](https://github.com/TanStack/ai/commit/5d984722e1f84725e3cfda834fbda3d0341ecedd)]: + - @tanstack/ai@0.5.0 + ## 0.4.3 ### Patch Changes diff --git a/packages/typescript/ai-client/package.json b/packages/typescript/ai-client/package.json index 680e37f5..214facff 100644 --- a/packages/typescript/ai-client/package.json +++ b/packages/typescript/ai-client/package.json @@ -1,6 +1,6 @@ { "name": "@tanstack/ai-client", - "version": "0.4.3", + "version": "0.4.4", "description": "Framework-agnostic headless client for TanStack AI", "author": "", "license": "MIT", diff --git a/packages/typescript/ai-devtools/CHANGELOG.md b/packages/typescript/ai-devtools/CHANGELOG.md index e6378e35..7ed1fef3 100644 --- a/packages/typescript/ai-devtools/CHANGELOG.md +++ b/packages/typescript/ai-devtools/CHANGELOG.md @@ -1,5 +1,12 @@ # @tanstack/ai-devtools-core +## 0.3.3 + +### Patch Changes + +- Updated dependencies [[`5d98472`](https://github.com/TanStack/ai/commit/5d984722e1f84725e3cfda834fbda3d0341ecedd), [`5d98472`](https://github.com/TanStack/ai/commit/5d984722e1f84725e3cfda834fbda3d0341ecedd)]: + - @tanstack/ai@0.5.0 + ## 0.3.2 ### Patch Changes diff --git a/packages/typescript/ai-devtools/package.json b/packages/typescript/ai-devtools/package.json index dc38c3c3..04e8ff08 100644 --- a/packages/typescript/ai-devtools/package.json +++ b/packages/typescript/ai-devtools/package.json @@ -1,6 +1,6 @@ { "name": "@tanstack/ai-devtools-core", - "version": "0.3.2", + "version": "0.3.3", "description": "Core TanStack AI Devtools", "author": "", "license": "MIT", diff --git a/packages/typescript/ai-gemini/CHANGELOG.md b/packages/typescript/ai-gemini/CHANGELOG.md index 69f753a6..88f0a300 100644 --- a/packages/typescript/ai-gemini/CHANGELOG.md +++ b/packages/typescript/ai-gemini/CHANGELOG.md @@ -1,5 +1,56 @@ # @tanstack/ai-gemini +## 0.5.0 + +### Minor Changes + +- Tighten the AG-UI adapter contract and simplify the core stream processor. ([#275](https://github.com/TanStack/ai/pull/275)) + + **Breaking type changes:** + - `TextMessageContentEvent.delta` is now required (was optional) + - `StepFinishedEvent.delta` is now required (was optional) + + All first-party adapters already sent `delta` on every event, so this is a type-level enforcement of existing behavior. Community adapters that follow the reference implementations will not need code changes. + + **Core processor simplifications:** + - `TEXT_MESSAGE_START` now resets text segment state, replacing heuristic overlap detection + - `TOOL_CALL_END` is now the authoritative signal for tool call input completion + - Removed delta/content fallback logic, whitespace-only message cleanup, and finish-reason conflict arbitration from the processor + + **Adapter fixes:** + - Gemini: filter whitespace-only text parts, fix STEP_FINISHED content accumulation, emit fresh TEXT_MESSAGE_START after tool calls + - Anthropic: emit fresh TEXT_MESSAGE_START after tool_use blocks for proper text segmentation + +### Patch Changes + +- fix(ai, ai-client, ai-anthropic, ai-gemini): fix multi-turn conversations failing after tool calls ([#275](https://github.com/TanStack/ai/pull/275)) + + **Core (@tanstack/ai):** + - Lazy assistant message creation: `StreamProcessor` now defers creating the assistant message until the first content-bearing chunk arrives (text, tool call, thinking, or error), eliminating empty `parts: []` messages from appearing during auto-continuation when the model returns no content + - Add `prepareAssistantMessage()` (lazy) alongside deprecated `startAssistantMessage()` (eager, backwards-compatible) + - Add `getCurrentAssistantMessageId()` to check if a message was created + - **Rewrite `uiMessageToModelMessages()` to preserve part ordering**: the function now walks parts sequentially instead of separating by type, producing correctly interleaved assistant/tool messages (text1 + toolCall1 → toolResult1 → text2 + toolCall2 → toolResult2) instead of concatenating all text and batching all tool calls. This fixes multi-round tool flows where the model would see garbled conversation history and re-call tools unnecessarily. + - Deduplicate tool result messages: when a client tool has both a `tool-result` part and a `tool-call` part with `output`, only one `role: 'tool'` message is emitted per tool call ID + + **Client (@tanstack/ai-client):** + - Update `ChatClient.processStream()` to use lazy assistant message creation, preventing UI flicker from empty messages being created then removed + + **Anthropic:** + - Fix consecutive user-role messages violating Anthropic's alternating role requirement by merging them in `formatMessages` + - Deduplicate `tool_result` blocks with the same `tool_use_id` + - Filter out empty assistant messages from conversation history + - Suppress duplicate `RUN_FINISHED` event from `message_stop` when `message_delta` already emitted one + - Fix `TEXT_MESSAGE_END` incorrectly emitting for `tool_use` content blocks + - Add Claude Opus 4.6 model support with adaptive thinking and effort parameter + + **Gemini:** + - Fix consecutive user-role messages violating Gemini's alternating role requirement by merging them in `formatMessages` + - Deduplicate `functionResponse` parts with the same name (tool call ID) + - Filter out empty model messages from conversation history + +- Updated dependencies [[`5d98472`](https://github.com/TanStack/ai/commit/5d984722e1f84725e3cfda834fbda3d0341ecedd), [`5d98472`](https://github.com/TanStack/ai/commit/5d984722e1f84725e3cfda834fbda3d0341ecedd)]: + - @tanstack/ai@0.5.0 + ## 0.4.1 ### Patch Changes diff --git a/packages/typescript/ai-gemini/package.json b/packages/typescript/ai-gemini/package.json index 6d5fb2aa..adc20440 100644 --- a/packages/typescript/ai-gemini/package.json +++ b/packages/typescript/ai-gemini/package.json @@ -1,6 +1,6 @@ { "name": "@tanstack/ai-gemini", - "version": "0.4.1", + "version": "0.5.0", "description": "Google Gemini adapter for TanStack AI", "author": "", "license": "MIT", diff --git a/packages/typescript/ai-grok/CHANGELOG.md b/packages/typescript/ai-grok/CHANGELOG.md index 9c4dd05d..fdc55668 100644 --- a/packages/typescript/ai-grok/CHANGELOG.md +++ b/packages/typescript/ai-grok/CHANGELOG.md @@ -1,5 +1,12 @@ # @tanstack/ai-grok +## 0.5.0 + +### Patch Changes + +- Updated dependencies [[`5d98472`](https://github.com/TanStack/ai/commit/5d984722e1f84725e3cfda834fbda3d0341ecedd), [`5d98472`](https://github.com/TanStack/ai/commit/5d984722e1f84725e3cfda834fbda3d0341ecedd)]: + - @tanstack/ai@0.5.0 + ## 0.4.1 ### Patch Changes diff --git a/packages/typescript/ai-grok/package.json b/packages/typescript/ai-grok/package.json index 2dfc1270..06960f25 100644 --- a/packages/typescript/ai-grok/package.json +++ b/packages/typescript/ai-grok/package.json @@ -1,6 +1,6 @@ { "name": "@tanstack/ai-grok", - "version": "0.4.1", + "version": "0.5.0", "description": "Grok (xAI) adapter for TanStack AI", "author": "", "license": "MIT", diff --git a/packages/typescript/ai-ollama/CHANGELOG.md b/packages/typescript/ai-ollama/CHANGELOG.md index 0baf65de..516b50f3 100644 --- a/packages/typescript/ai-ollama/CHANGELOG.md +++ b/packages/typescript/ai-ollama/CHANGELOG.md @@ -1,5 +1,12 @@ # @tanstack/ai-ollama +## 0.5.0 + +### Patch Changes + +- Updated dependencies [[`5d98472`](https://github.com/TanStack/ai/commit/5d984722e1f84725e3cfda834fbda3d0341ecedd), [`5d98472`](https://github.com/TanStack/ai/commit/5d984722e1f84725e3cfda834fbda3d0341ecedd)]: + - @tanstack/ai@0.5.0 + ## 0.4.0 ### Patch Changes diff --git a/packages/typescript/ai-ollama/package.json b/packages/typescript/ai-ollama/package.json index 66a89e97..e1d96052 100644 --- a/packages/typescript/ai-ollama/package.json +++ b/packages/typescript/ai-ollama/package.json @@ -1,6 +1,6 @@ { "name": "@tanstack/ai-ollama", - "version": "0.4.0", + "version": "0.5.0", "description": "Ollama adapter for TanStack AI", "author": "", "license": "MIT", diff --git a/packages/typescript/ai-openai/CHANGELOG.md b/packages/typescript/ai-openai/CHANGELOG.md index 58bb832d..9fa7490e 100644 --- a/packages/typescript/ai-openai/CHANGELOG.md +++ b/packages/typescript/ai-openai/CHANGELOG.md @@ -1,5 +1,12 @@ # @tanstack/ai-openai +## 0.5.0 + +### Patch Changes + +- Updated dependencies [[`5d98472`](https://github.com/TanStack/ai/commit/5d984722e1f84725e3cfda834fbda3d0341ecedd), [`5d98472`](https://github.com/TanStack/ai/commit/5d984722e1f84725e3cfda834fbda3d0341ecedd)]: + - @tanstack/ai@0.5.0 + ## 0.4.0 ### Patch Changes diff --git a/packages/typescript/ai-openai/package.json b/packages/typescript/ai-openai/package.json index f6c6d374..ba40cee7 100644 --- a/packages/typescript/ai-openai/package.json +++ b/packages/typescript/ai-openai/package.json @@ -1,6 +1,6 @@ { "name": "@tanstack/ai-openai", - "version": "0.4.0", + "version": "0.5.0", "description": "OpenAI adapter for TanStack AI", "author": "", "license": "MIT", diff --git a/packages/typescript/ai-openrouter/CHANGELOG.md b/packages/typescript/ai-openrouter/CHANGELOG.md index acc6a33f..c7394155 100644 --- a/packages/typescript/ai-openrouter/CHANGELOG.md +++ b/packages/typescript/ai-openrouter/CHANGELOG.md @@ -1,5 +1,12 @@ # @tanstack/ai-openrouter +## 0.5.0 + +### Patch Changes + +- Updated dependencies [[`5d98472`](https://github.com/TanStack/ai/commit/5d984722e1f84725e3cfda834fbda3d0341ecedd), [`5d98472`](https://github.com/TanStack/ai/commit/5d984722e1f84725e3cfda834fbda3d0341ecedd)]: + - @tanstack/ai@0.5.0 + ## 0.4.2 ### Patch Changes diff --git a/packages/typescript/ai-openrouter/package.json b/packages/typescript/ai-openrouter/package.json index 7147daf2..6db6744a 100644 --- a/packages/typescript/ai-openrouter/package.json +++ b/packages/typescript/ai-openrouter/package.json @@ -1,6 +1,6 @@ { "name": "@tanstack/ai-openrouter", - "version": "0.4.2", + "version": "0.5.0", "description": "OpenRouter adapter for TanStack AI", "author": "", "license": "MIT", diff --git a/packages/typescript/ai-preact/CHANGELOG.md b/packages/typescript/ai-preact/CHANGELOG.md index 53e0b91f..ff3b3316 100644 --- a/packages/typescript/ai-preact/CHANGELOG.md +++ b/packages/typescript/ai-preact/CHANGELOG.md @@ -1,5 +1,13 @@ # @tanstack/ai-preact +## 0.5.3 + +### Patch Changes + +- Updated dependencies [[`5d98472`](https://github.com/TanStack/ai/commit/5d984722e1f84725e3cfda834fbda3d0341ecedd), [`5d98472`](https://github.com/TanStack/ai/commit/5d984722e1f84725e3cfda834fbda3d0341ecedd)]: + - @tanstack/ai@0.5.0 + - @tanstack/ai-client@0.4.4 + ## 0.5.2 ### Patch Changes diff --git a/packages/typescript/ai-preact/package.json b/packages/typescript/ai-preact/package.json index 62c8330f..9209dbe3 100644 --- a/packages/typescript/ai-preact/package.json +++ b/packages/typescript/ai-preact/package.json @@ -1,6 +1,6 @@ { "name": "@tanstack/ai-preact", - "version": "0.5.2", + "version": "0.5.3", "description": "Preact hooks for TanStack AI", "author": "", "license": "MIT", diff --git a/packages/typescript/ai-react-ui/CHANGELOG.md b/packages/typescript/ai-react-ui/CHANGELOG.md index 3b214471..a967661e 100644 --- a/packages/typescript/ai-react-ui/CHANGELOG.md +++ b/packages/typescript/ai-react-ui/CHANGELOG.md @@ -1,5 +1,13 @@ # @tanstack/ai-react-ui +## 0.5.1 + +### Patch Changes + +- Updated dependencies [[`5d98472`](https://github.com/TanStack/ai/commit/5d984722e1f84725e3cfda834fbda3d0341ecedd)]: + - @tanstack/ai-client@0.4.4 + - @tanstack/ai-react@0.5.1 + ## 0.5.0 ### Patch Changes diff --git a/packages/typescript/ai-react-ui/package.json b/packages/typescript/ai-react-ui/package.json index 26b6c5ea..d3c17e6e 100644 --- a/packages/typescript/ai-react-ui/package.json +++ b/packages/typescript/ai-react-ui/package.json @@ -1,6 +1,6 @@ { "name": "@tanstack/ai-react-ui", - "version": "0.5.0", + "version": "0.5.1", "description": "Headless React components for building AI chat interfaces", "module": "./dist/esm/index.js", "types": "./dist/esm/index.d.ts", diff --git a/packages/typescript/ai-react/CHANGELOG.md b/packages/typescript/ai-react/CHANGELOG.md index f1a56024..3e5aa7fa 100644 --- a/packages/typescript/ai-react/CHANGELOG.md +++ b/packages/typescript/ai-react/CHANGELOG.md @@ -1,5 +1,13 @@ # @tanstack/ai-react +## 0.5.3 + +### Patch Changes + +- Updated dependencies [[`5d98472`](https://github.com/TanStack/ai/commit/5d984722e1f84725e3cfda834fbda3d0341ecedd), [`5d98472`](https://github.com/TanStack/ai/commit/5d984722e1f84725e3cfda834fbda3d0341ecedd)]: + - @tanstack/ai@0.5.0 + - @tanstack/ai-client@0.4.4 + ## 0.5.2 ### Patch Changes diff --git a/packages/typescript/ai-react/package.json b/packages/typescript/ai-react/package.json index a9036014..4dedb169 100644 --- a/packages/typescript/ai-react/package.json +++ b/packages/typescript/ai-react/package.json @@ -1,6 +1,6 @@ { "name": "@tanstack/ai-react", - "version": "0.5.2", + "version": "0.5.3", "description": "React hooks for TanStack AI", "author": "", "license": "MIT", diff --git a/packages/typescript/ai-solid-ui/CHANGELOG.md b/packages/typescript/ai-solid-ui/CHANGELOG.md index 7bbbd8ff..1432490e 100644 --- a/packages/typescript/ai-solid-ui/CHANGELOG.md +++ b/packages/typescript/ai-solid-ui/CHANGELOG.md @@ -1,5 +1,13 @@ # @tanstack/ai-solid-ui +## 0.5.1 + +### Patch Changes + +- Updated dependencies [[`5d98472`](https://github.com/TanStack/ai/commit/5d984722e1f84725e3cfda834fbda3d0341ecedd)]: + - @tanstack/ai-client@0.4.4 + - @tanstack/ai-solid@0.5.1 + ## 0.5.0 ### Patch Changes diff --git a/packages/typescript/ai-solid-ui/package.json b/packages/typescript/ai-solid-ui/package.json index c815b937..00ee0849 100644 --- a/packages/typescript/ai-solid-ui/package.json +++ b/packages/typescript/ai-solid-ui/package.json @@ -1,6 +1,6 @@ { "name": "@tanstack/ai-solid-ui", - "version": "0.5.0", + "version": "0.5.1", "description": "Headless Solid components for building AI chat interfaces", "module": "./src/index.ts", "types": "./src/index.ts", diff --git a/packages/typescript/ai-solid/CHANGELOG.md b/packages/typescript/ai-solid/CHANGELOG.md index 92956adb..a9d57726 100644 --- a/packages/typescript/ai-solid/CHANGELOG.md +++ b/packages/typescript/ai-solid/CHANGELOG.md @@ -1,5 +1,13 @@ # @tanstack/ai-solid +## 0.5.3 + +### Patch Changes + +- Updated dependencies [[`5d98472`](https://github.com/TanStack/ai/commit/5d984722e1f84725e3cfda834fbda3d0341ecedd), [`5d98472`](https://github.com/TanStack/ai/commit/5d984722e1f84725e3cfda834fbda3d0341ecedd)]: + - @tanstack/ai@0.5.0 + - @tanstack/ai-client@0.4.4 + ## 0.5.2 ### Patch Changes diff --git a/packages/typescript/ai-solid/package.json b/packages/typescript/ai-solid/package.json index 8d84f46d..4cde9784 100644 --- a/packages/typescript/ai-solid/package.json +++ b/packages/typescript/ai-solid/package.json @@ -1,6 +1,6 @@ { "name": "@tanstack/ai-solid", - "version": "0.5.2", + "version": "0.5.3", "description": "Solid hooks for TanStack AI", "author": "", "license": "MIT", diff --git a/packages/typescript/ai-svelte/CHANGELOG.md b/packages/typescript/ai-svelte/CHANGELOG.md index 47e82746..7912fe49 100644 --- a/packages/typescript/ai-svelte/CHANGELOG.md +++ b/packages/typescript/ai-svelte/CHANGELOG.md @@ -1,5 +1,13 @@ # @tanstack/ai-svelte +## 0.5.3 + +### Patch Changes + +- Updated dependencies [[`5d98472`](https://github.com/TanStack/ai/commit/5d984722e1f84725e3cfda834fbda3d0341ecedd), [`5d98472`](https://github.com/TanStack/ai/commit/5d984722e1f84725e3cfda834fbda3d0341ecedd)]: + - @tanstack/ai@0.5.0 + - @tanstack/ai-client@0.4.4 + ## 0.5.2 ### Patch Changes diff --git a/packages/typescript/ai-svelte/package.json b/packages/typescript/ai-svelte/package.json index 7f376169..8f49e3e3 100644 --- a/packages/typescript/ai-svelte/package.json +++ b/packages/typescript/ai-svelte/package.json @@ -1,6 +1,6 @@ { "name": "@tanstack/ai-svelte", - "version": "0.5.2", + "version": "0.5.3", "description": "Svelte bindings for TanStack AI", "author": "", "license": "MIT", diff --git a/packages/typescript/ai-vue-ui/CHANGELOG.md b/packages/typescript/ai-vue-ui/CHANGELOG.md index 58a28334..7348ea9c 100644 --- a/packages/typescript/ai-vue-ui/CHANGELOG.md +++ b/packages/typescript/ai-vue-ui/CHANGELOG.md @@ -1,5 +1,12 @@ # @tanstack/ai-vue-ui +## 0.1.9 + +### Patch Changes + +- Updated dependencies []: + - @tanstack/ai-vue@0.5.3 + ## 0.1.8 ### Patch Changes diff --git a/packages/typescript/ai-vue-ui/package.json b/packages/typescript/ai-vue-ui/package.json index 57902f37..90dd2582 100644 --- a/packages/typescript/ai-vue-ui/package.json +++ b/packages/typescript/ai-vue-ui/package.json @@ -1,6 +1,6 @@ { "name": "@tanstack/ai-vue-ui", - "version": "0.1.8", + "version": "0.1.9", "description": "Headless Vue components for building AI chat interfaces", "module": "./src/index.ts", "types": "./src/index.ts", diff --git a/packages/typescript/ai-vue/CHANGELOG.md b/packages/typescript/ai-vue/CHANGELOG.md index 5bdddd1a..665c9cfd 100644 --- a/packages/typescript/ai-vue/CHANGELOG.md +++ b/packages/typescript/ai-vue/CHANGELOG.md @@ -1,5 +1,13 @@ # @tanstack/ai-vue +## 0.5.3 + +### Patch Changes + +- Updated dependencies [[`5d98472`](https://github.com/TanStack/ai/commit/5d984722e1f84725e3cfda834fbda3d0341ecedd), [`5d98472`](https://github.com/TanStack/ai/commit/5d984722e1f84725e3cfda834fbda3d0341ecedd)]: + - @tanstack/ai@0.5.0 + - @tanstack/ai-client@0.4.4 + ## 0.5.2 ### Patch Changes diff --git a/packages/typescript/ai-vue/package.json b/packages/typescript/ai-vue/package.json index 4f4615f8..6f71c5e6 100644 --- a/packages/typescript/ai-vue/package.json +++ b/packages/typescript/ai-vue/package.json @@ -1,6 +1,6 @@ { "name": "@tanstack/ai-vue", - "version": "0.5.2", + "version": "0.5.3", "description": "Vue hooks for TanStack AI", "author": "", "license": "MIT", diff --git a/packages/typescript/ai/CHANGELOG.md b/packages/typescript/ai/CHANGELOG.md index dfc5e613..4c15252c 100644 --- a/packages/typescript/ai/CHANGELOG.md +++ b/packages/typescript/ai/CHANGELOG.md @@ -1,5 +1,53 @@ # @tanstack/ai +## 0.5.0 + +### Minor Changes + +- Tighten the AG-UI adapter contract and simplify the core stream processor. ([#275](https://github.com/TanStack/ai/pull/275)) + + **Breaking type changes:** + - `TextMessageContentEvent.delta` is now required (was optional) + - `StepFinishedEvent.delta` is now required (was optional) + + All first-party adapters already sent `delta` on every event, so this is a type-level enforcement of existing behavior. Community adapters that follow the reference implementations will not need code changes. + + **Core processor simplifications:** + - `TEXT_MESSAGE_START` now resets text segment state, replacing heuristic overlap detection + - `TOOL_CALL_END` is now the authoritative signal for tool call input completion + - Removed delta/content fallback logic, whitespace-only message cleanup, and finish-reason conflict arbitration from the processor + + **Adapter fixes:** + - Gemini: filter whitespace-only text parts, fix STEP_FINISHED content accumulation, emit fresh TEXT_MESSAGE_START after tool calls + - Anthropic: emit fresh TEXT_MESSAGE_START after tool_use blocks for proper text segmentation + +### Patch Changes + +- fix(ai, ai-client, ai-anthropic, ai-gemini): fix multi-turn conversations failing after tool calls ([#275](https://github.com/TanStack/ai/pull/275)) + + **Core (@tanstack/ai):** + - Lazy assistant message creation: `StreamProcessor` now defers creating the assistant message until the first content-bearing chunk arrives (text, tool call, thinking, or error), eliminating empty `parts: []` messages from appearing during auto-continuation when the model returns no content + - Add `prepareAssistantMessage()` (lazy) alongside deprecated `startAssistantMessage()` (eager, backwards-compatible) + - Add `getCurrentAssistantMessageId()` to check if a message was created + - **Rewrite `uiMessageToModelMessages()` to preserve part ordering**: the function now walks parts sequentially instead of separating by type, producing correctly interleaved assistant/tool messages (text1 + toolCall1 → toolResult1 → text2 + toolCall2 → toolResult2) instead of concatenating all text and batching all tool calls. This fixes multi-round tool flows where the model would see garbled conversation history and re-call tools unnecessarily. + - Deduplicate tool result messages: when a client tool has both a `tool-result` part and a `tool-call` part with `output`, only one `role: 'tool'` message is emitted per tool call ID + + **Client (@tanstack/ai-client):** + - Update `ChatClient.processStream()` to use lazy assistant message creation, preventing UI flicker from empty messages being created then removed + + **Anthropic:** + - Fix consecutive user-role messages violating Anthropic's alternating role requirement by merging them in `formatMessages` + - Deduplicate `tool_result` blocks with the same `tool_use_id` + - Filter out empty assistant messages from conversation history + - Suppress duplicate `RUN_FINISHED` event from `message_stop` when `message_delta` already emitted one + - Fix `TEXT_MESSAGE_END` incorrectly emitting for `tool_use` content blocks + - Add Claude Opus 4.6 model support with adaptive thinking and effort parameter + + **Gemini:** + - Fix consecutive user-role messages violating Gemini's alternating role requirement by merging them in `formatMessages` + - Deduplicate `functionResponse` parts with the same name (tool call ID) + - Filter out empty model messages from conversation history + ## 0.4.2 ### Patch Changes diff --git a/packages/typescript/ai/package.json b/packages/typescript/ai/package.json index 4b76449d..3fe3ccb3 100644 --- a/packages/typescript/ai/package.json +++ b/packages/typescript/ai/package.json @@ -1,6 +1,6 @@ { "name": "@tanstack/ai", - "version": "0.4.2", + "version": "0.5.0", "description": "Core TanStack AI library - Open source AI SDK", "author": "Tanner Linsley", "license": "MIT", diff --git a/packages/typescript/preact-ai-devtools/CHANGELOG.md b/packages/typescript/preact-ai-devtools/CHANGELOG.md index 14f38624..43785a94 100644 --- a/packages/typescript/preact-ai-devtools/CHANGELOG.md +++ b/packages/typescript/preact-ai-devtools/CHANGELOG.md @@ -1,5 +1,12 @@ # @tanstack/preact-ai-devtools +## 0.1.7 + +### Patch Changes + +- Updated dependencies []: + - @tanstack/ai-devtools-core@0.3.3 + ## 0.1.6 ### Patch Changes diff --git a/packages/typescript/preact-ai-devtools/package.json b/packages/typescript/preact-ai-devtools/package.json index e98092eb..024a00ff 100644 --- a/packages/typescript/preact-ai-devtools/package.json +++ b/packages/typescript/preact-ai-devtools/package.json @@ -1,6 +1,6 @@ { "name": "@tanstack/preact-ai-devtools", - "version": "0.1.6", + "version": "0.1.7", "description": "Preact Devtools for TanStack AI.", "author": "tannerlinsley", "license": "MIT", diff --git a/packages/typescript/react-ai-devtools/CHANGELOG.md b/packages/typescript/react-ai-devtools/CHANGELOG.md index eb3ed942..92f8c940 100644 --- a/packages/typescript/react-ai-devtools/CHANGELOG.md +++ b/packages/typescript/react-ai-devtools/CHANGELOG.md @@ -1,5 +1,12 @@ # @tanstack/react-ai-devtools +## 0.2.7 + +### Patch Changes + +- Updated dependencies []: + - @tanstack/ai-devtools-core@0.3.3 + ## 0.2.6 ### Patch Changes diff --git a/packages/typescript/react-ai-devtools/package.json b/packages/typescript/react-ai-devtools/package.json index 1e53098c..87a731c4 100644 --- a/packages/typescript/react-ai-devtools/package.json +++ b/packages/typescript/react-ai-devtools/package.json @@ -1,6 +1,6 @@ { "name": "@tanstack/react-ai-devtools", - "version": "0.2.6", + "version": "0.2.7", "description": "React Devtools for TanStack AI.", "author": "tannerlinsley", "license": "MIT", diff --git a/packages/typescript/smoke-tests/adapters/CHANGELOG.md b/packages/typescript/smoke-tests/adapters/CHANGELOG.md index 8b696792..d5b385ae 100644 --- a/packages/typescript/smoke-tests/adapters/CHANGELOG.md +++ b/packages/typescript/smoke-tests/adapters/CHANGELOG.md @@ -1,5 +1,18 @@ # @tanstack/tests-adapters +## 0.1.12 + +### Patch Changes + +- Updated dependencies [[`5d98472`](https://github.com/TanStack/ai/commit/5d984722e1f84725e3cfda834fbda3d0341ecedd), [`5d98472`](https://github.com/TanStack/ai/commit/5d984722e1f84725e3cfda834fbda3d0341ecedd)]: + - @tanstack/ai@0.5.0 + - @tanstack/ai-anthropic@0.5.0 + - @tanstack/ai-gemini@0.5.0 + - @tanstack/ai-grok@0.5.0 + - @tanstack/ai-ollama@0.5.0 + - @tanstack/ai-openai@0.5.0 + - @tanstack/ai-openrouter@0.5.0 + ## 0.1.11 ### Patch Changes diff --git a/packages/typescript/smoke-tests/adapters/package.json b/packages/typescript/smoke-tests/adapters/package.json index 6db3c656..f51bd9d5 100644 --- a/packages/typescript/smoke-tests/adapters/package.json +++ b/packages/typescript/smoke-tests/adapters/package.json @@ -1,6 +1,6 @@ { "name": "@tanstack/tests-adapters", - "version": "0.1.11", + "version": "0.1.12", "private": true, "description": "Tests for TanStack AI adapters", "author": "", diff --git a/packages/typescript/smoke-tests/e2e/CHANGELOG.md b/packages/typescript/smoke-tests/e2e/CHANGELOG.md index 839861b9..61eb1953 100644 --- a/packages/typescript/smoke-tests/e2e/CHANGELOG.md +++ b/packages/typescript/smoke-tests/e2e/CHANGELOG.md @@ -1,5 +1,16 @@ # @tanstack/smoke-tests-e2e +## 0.0.16 + +### Patch Changes + +- Updated dependencies [[`5d98472`](https://github.com/TanStack/ai/commit/5d984722e1f84725e3cfda834fbda3d0341ecedd), [`5d98472`](https://github.com/TanStack/ai/commit/5d984722e1f84725e3cfda834fbda3d0341ecedd)]: + - @tanstack/ai@0.5.0 + - @tanstack/ai-client@0.4.4 + - @tanstack/ai-openai@0.5.0 + - @tanstack/ai-react@0.5.1 + - @tanstack/tests-adapters@0.1.12 + ## 0.0.15 ### Patch Changes diff --git a/packages/typescript/smoke-tests/e2e/package.json b/packages/typescript/smoke-tests/e2e/package.json index d39e4974..ef2602a3 100644 --- a/packages/typescript/smoke-tests/e2e/package.json +++ b/packages/typescript/smoke-tests/e2e/package.json @@ -1,6 +1,6 @@ { "name": "@tanstack/smoke-tests-e2e", - "version": "0.0.15", + "version": "0.0.16", "description": "E2E tests for TanStack AI chat", "private": true, "type": "module", diff --git a/packages/typescript/solid-ai-devtools/CHANGELOG.md b/packages/typescript/solid-ai-devtools/CHANGELOG.md index fe7ec5e3..6b08906a 100644 --- a/packages/typescript/solid-ai-devtools/CHANGELOG.md +++ b/packages/typescript/solid-ai-devtools/CHANGELOG.md @@ -1,5 +1,12 @@ # @tanstack/solid-ai-devtools +## 0.2.7 + +### Patch Changes + +- Updated dependencies []: + - @tanstack/ai-devtools-core@0.3.3 + ## 0.2.6 ### Patch Changes diff --git a/packages/typescript/solid-ai-devtools/package.json b/packages/typescript/solid-ai-devtools/package.json index 25bdb41a..3c1630d2 100644 --- a/packages/typescript/solid-ai-devtools/package.json +++ b/packages/typescript/solid-ai-devtools/package.json @@ -1,6 +1,6 @@ { "name": "@tanstack/solid-ai-devtools", - "version": "0.2.6", + "version": "0.2.7", "description": "Solid TanStack AI Devtools", "author": "", "license": "MIT",