Closed woozar closed 2 months ago
onFinish
only provides you with the tool calls & tool results from the last roundtrip. I would need to add roundtrips
to onFinish
/ the result object similar to what generateText
does.
Is using generateText
an option?
We do need the stream, so it is not an option.
Also it is very irritating, that the toolCalls result which is described as "The tool calls that have been executed" does not contain all those calls. It took me quite a while to figure out "why the provided tool was never used", because it was used but not part of that list.
I am not sure if we need all the roundtrips (would not be the worst idea, probably) but for me personally, it would be sufficient to just get the toolCalls from all roundtrips and return the merged list
I'm experiencing a similar problem. I need a callback to save the tool results into client states using useChat and into the database using streamText, but both methods only provide the final assistant message.
Same here.
Do we need to do something with onChunk and potentially parse each message out? Imagine this is a pretty common use case especially if you're saving the messages to a DB.
You can now access intermediate results using the steps
property in onFinish
Description
I used the tool example with the calculator from the official website https://sdk.vercel.ai/docs/ai-sdk-core/agents and slightly adapted it to look like the provided code. Then I ran a prompt that used the tool to calculate some areas of some random parts.
After executing the code i get the following output on the console:
Obviously the calculator was called for each part, but the toolCalls and toolResults in the onFinish are still empty.
Code example
I had to slightly adapt the code to put everything in one place and also replace the system prompt, which I am not allowed to publish (I am confident, that the system prompt is not the cause of this issue). Please forgive, if I did some syntax errors (or similar) during this process.
Additional context
Used packages: