useChat client side tool repeat calls

Hello,

I’ve been using useChat and streamText to build a chat bot.

Everything works fine, only one issue which is annoying.

I have 1 client-side tool which gets executed to receive user confirmation.

Once user confirms, it records the call but then the tool gets executed again.

Any idea? I’m using addToolResult to record the result.

are you able to share a code snippet of how you’ve structure this?

I fixed this issue. It was an issue within my code. Thank you Josh.

1 Like

@suchakmaulik179 I’m experiencing the same problem, what was the issue for you?

I was passing messages back to the useChat which did not include toolInvocation and all toolcalls, I started to include it and it started working. No more repeat API calls.