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 34553ecec..000000000 --- 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 78a7af3f5..000000000 --- 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 8a0ab92cd..19dd8e314 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 c98dcaa05..acab1ed5a 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 9d5142adb..94a6bed41 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 39710b4d3..e94fe96e1 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 999f574ec..17433a348 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 321515447..d4ba014f1 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 fc6093a81..245ab88c5 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 eecbe2a68..84b318080 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 9f384597e..3f5a9ad90 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 680e37f57..214facffa 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 e6378e35a..7ed1fef3f 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 dc38c3c3e..04e8ff088 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 69f753a6b..88f0a3001 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 6d5fb2aa7..adc204409 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 9c4dd05d1..fdc55668e 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 2dfc12706..06960f258 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 0baf65dee..516b50f34 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 66a89e97e..e1d960523 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 58bb832d1..9fa7490e8 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 f6c6d3744..ba40cee7a 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 acc6a33f9..c73941555 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 7147daf2e..6db6744ad 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 53e0b91ff..ff3b3316a 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 62c8330f9..9209dbe3b 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 3b2144710..a967661e4 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 26b6c5ea8..d3c17e6e8 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 f1a560246..3e5aa7fa3 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 a9036014e..4dedb1699 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 7bbbd8ffc..1432490e8 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 c815b9377..00ee08498 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 92956adb1..a9d577264 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 8d84f46d2..4cde97843 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 47e827466..7912fe497 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 7f3761694..8f49e3e35 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 58a283340..7348ea9cd 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 57902f376..90dd25823 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 5bdddd1aa..665c9cfdc 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 4f4615f8b..6f71c5e65 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 dfc5e613e..4c15252c3 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 4b76449d8..3fe3ccb31 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 14f38624c..43785a94a 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 e98092eb2..024a00ffa 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 eb3ed9421..92f8c9403 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 1e53098c8..87a731c45 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 8b696792d..d5b385aef 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 6db3c6566..f51bd9d56 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 839861b93..61eb19537 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 d39e49747..ef2602a35 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 fe7ec5e34..6b08906a8 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 25bdb41a6..3c1630d22 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",