ai-chatbot icon indicating copy to clipboard operation
ai-chatbot copied to clipboard

When calling a tool on the client side, tool-call and tool-results messages are not saving to the database

Open tobiasbueschel opened this issue 2 months ago • 2 comments

Hi Vercel Team,

Great work with this AI Chatbot Starter Template, it's fantastic 👏

When setting up client-side tool calling, I've noticed that the results of these tool calls are currently not correctly stored in the database. I've followed this guide to set it up: https://sdk.vercel.ai/docs/ai-sdk-ui/chatbot-with-tool-calling#chatbot-with-tools

I've forked this repo and added an example commit to demonstrate this + to reproduce it easily:

https://github.com/tobiasbueschel/ai-chatbot/commit/a673798b513b86b3c3f2559bced5ea557d950c57

https://github.com/tobiasbueschel/ai-chatbot/blob/a673798b513b86b3c3f2559bced5ea557d950c57/components/chat.tsx#L43-L69

This is what I see in the DB when running the client-side tool: image

  • notice that my initial user message has been stored twice
  • tool-call and tool-result is missing entirely

And here is what is stored in the DB when running a server-side tool image

On that note, as other people might also find examples for client-side tools helpful, shall we add such an example to the tools that are already registered in this starter template?

Thanks 🙏

tobiasbueschel avatar Nov 25 '24 05:11 tobiasbueschel