How to send enough data to AI, but extra data for UI when using tool

When I call a tool the execute function runs. The returned data is fed to AI as well used for UI. For example if I have a web search tool it will send search results.

Now for UI rendering let’s say to make it beautiful I need favicon and some other metadata, which has nothing to do with AI’s context.

But the problem is if I strip data in execute function’s return, the AI and UI both doesn’t get it. I am new to programming and AI SDK. Please help.

How can I make that the tool return enough data for AI context and extra data for a beautiful rich transparent UI while the data persist across sessions.

1 Like

@tweak-shank-factor-6 In AI SDK 6, toModelOutput can help you do this. Here are the docs:

2 Likes

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.