Tool Calling Errors
I am getting tool calling errors that respond with "Invalid JSON response" but when I reconcile the request made by the tool to whatever API provider the tool uses, I see a successfully executed request. I am wondering if there is some sort of timeout associated with tools.
To recreate this, create a tool that calls a long running image generation tool like nano-banana-pro. On a large set of requests you should see the occasional timeout, but when you go to reconcile the generation is successful.
11 Replies
📝 Created GitHub issue: https://github.com/mastra-ai/mastra/issues/10518
🔍 If you're experiencing an error, please provide a minimal reproducible example whenever possible to help us resolve it quickly.
🙏 Thank you for helping us improve Mastra!
Hey @tommy ! What do you mean by reconcile?
How are you executing the agent? through mastra server?
Hey @Abhi Aiyer , By ‘reconcile,’ I mean matching the tool’s request ID with the corresponding entry in the platform’s logs. So the tool calls a third party API, I look at the request ID made by the tool, and see that in the platform the request was successful. The agent is hosted on mastra, and is part of a larger workflow.
I'm wondering if the server request timed out! Theres a default server timeout of 3 minutes
You can configure this on the
server in Mastra classIts possible, but I've seen it fail on requests that were shorter than 3 minutes.
The generation on the google side is happening independent of the http connection tracking it, so makes sense why it was still successful. Invalid JSON Response leads me to believe its some HTTP issue, let me see if we can add more error logging there
I think the default server timeout might be 30 seconds?
Hmm in the code i see its 3 * 60 * 1000 ms, but in the docs i see 30s T_T
Oh yea I was going based on the docs not the code.
ill address that docs thing, curious if theres a good way to repro
Not a great way to recreate unfortunately because the image gen workflows vary based on input. If you pass a few images and a relatively complex prompt to an image gen tool like nano-banana-pro you may be able to recreate it. The error has reduced, but I am unsure why. I haven't changed anything about our configuration.
I'll follow up again in this thread if I see the error happening consistently. Sorry about that.