fix(service-ai): yield tool-result events in streamChatWithTools SSE stream#1087
Merged
fix(service-ai): yield tool-result events in streamChatWithTools SSE stream#1087
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
…stream Previously, streamChatWithTools only yielded tool-call events but not tool-result events. Tool results were pushed to the conversation but never emitted via SSE, making it impossible for the frontend to track tool output in real-time. Now each tool execution result is yielded as a tool-result TextStreamPart before being appended to the conversation, which the encoder maps to tool-output-available SSE chunks. Agent-Logs-Url: https://github.com/objectstack-ai/framework/sessions/6af7123e-c579-4a8f-84f6-a58107c88797 Co-authored-by: hotlong <50353452+hotlong@users.noreply.github.com>
Copilot
AI
changed the title
[WIP] Fix SSE stream to yield tool-result events for AI Chat
fix(service-ai): yield tool-result events in streamChatWithTools SSE stream
Apr 8, 2026
Contributor
There was a problem hiding this comment.
Pull request overview
Fixes AIService.streamChatWithTools() so it emits tool-result stream parts (in addition to tool-call) during SSE-style streaming, enabling clients to receive tool outputs as they become available.
Changes:
- Yield
tool-resultevents for each executed tool before appending the tool message back into the conversation loop. - Extend streaming tests to assert
tool-resultpresence and validate that tool output content round-trips correctly.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| packages/services/service-ai/src/ai-service.ts | Emits tool-result stream parts during the tool-resolution loop so tool outputs are visible to SSE clients. |
| packages/services/service-ai/src/tests/auth-and-toolcalling.test.ts | Adds assertions for tool-result events and introduces a dedicated test verifying tool output and event ordering. |
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
streamChatWithToolsemittedtool-call(tool-input-available) events but never yielded the correspondingtool-result— results were only pushed to the conversation array. The encoder already mappedtool-result→tool-output-available; it just was never invoked.Changes
ai-service.ts: Yield eachToolExecutionResultas atool-resultstream part before appending it to the conversationauth-and-toolcalling.test.ts: Added assertions fortool-resultpresence/ordering in the existing streaming test; added a dedicated test validating tool output content round-trips correctly