M
Mastra2w ago
tommy

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
Mastra Triager
📝 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!
Abhi Aiyer
Abhi Aiyer2w ago
Hey @tommy ! What do you mean by reconcile? How are you executing the agent? through mastra server?
tommy
tommyOP2w ago
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.
Abhi Aiyer
Abhi Aiyer2w ago
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 class
tommy
tommyOP2w ago
Its possible, but I've seen it fail on requests that were shorter than 3 minutes.
Abhi Aiyer
Abhi Aiyer2w ago
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
tommy
tommyOP2w ago
I think the default server timeout might be 30 seconds?
Abhi Aiyer
Abhi Aiyer2w ago
Hmm in the code i see its 3 * 60 * 1000 ms, but in the docs i see 30s T_T
tommy
tommyOP2w ago
Oh yea I was going based on the docs not the code.
Abhi Aiyer
Abhi Aiyer2w ago
ill address that docs thing, curious if theres a good way to repro
tommy
tommyOP2w ago
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.

Did you find this page helpful?