Skip to content

Tweak streaming tool data representation a bit more - #108

Merged
msullivan merged 4 commits into
mainfrom
ai-sdk-ui
May 12, 2026
Merged

Tweak streaming tool data representation a bit more#108
msullivan merged 4 commits into
mainfrom
ai-sdk-ui

Conversation

@msullivan

@msullivan msullivan commented May 12, 2026

Copy link
Copy Markdown
Contributor

For streaming tools, make the result be the final aggregation
snapshot. This allows the result of a subagent to be the full
MessageBundle, which has the advantage that the preliminary
type when streaming over the ai-sdk ui matches the final type.

We add a hidden _model_input to messages representing the actual
value to be sent to the model. This gets set on ToolResultPart when
on tool completion and by Agent.run when processing messages that
are missing them.
We do it this way because Agent.run has access to the tools.

@msullivan
msullivan requested review from 1st1 and anbuzin May 12, 2026 06:52
@vercel

vercel Bot commented May 12, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
py-ai Ready Ready Preview, Comment May 12, 2026 8:50pm

Request Review

@anbuzin

anbuzin commented May 12, 2026

Copy link
Copy Markdown
Collaborator

Could you clarify result vs model_result a bit more please? Which carries what data?

@msullivan

Copy link
Copy Markdown
Contributor Author

result is the "real" return value from the tool, model_result is a transformed version for feeding to the model. (So, extracting the text from subagent messages for example)

msullivan added 4 commits May 12, 2026 13:49
For streaming tools, make the `result` be the final aggregation
snapshot, and then have a separate `model_result`. This allows the
`result` of a subagent to be the full `MessageBundle`, which has the
advantage that the `preliminary` type when streaming over the ai-sdk
ui matches the final type.

UIMessage <-> MessageBundle coversions are done on the ai-sdk ui side,
and we now pass tools in to enable that.
@msullivan
msullivan merged commit cbe831f into main May 12, 2026
6 checks passed
@msullivan
msullivan deleted the ai-sdk-ui branch May 12, 2026 20:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants