Duplicate responses coming from Mastra

I sometimes notice my streamVNext agent outputting two text outputs on the same run. I have verified this by confirming that two text-start chunk types get sent in the stream with the same runId but different message IDs. For context, I'm on the latest mastra version. Is there any flag I can set on streamVNext so this doesn't happen? Or is it completely up to the model provider and Mastra has no control here? Please let me know, as I'm currently manually filtering out the rest of the stream after I detect the first text-start.
11 Replies
Ferreo
Ferreo3w ago
Maybe try a different model/provider to see if it is mastra or not. I've had some models duplicate text output and also tool use. Forcing just a single step seems to work too but then you can't do anything mutli-step obviously
Mastra Triager
GitHub
[DISCORD:1423829170848268298] Duplicate responses coming from Mastr...
This issue was created from Discord post: https://discord.com/channels/1309558646228779139/1423829170848268298 I sometimes notice my streamVNext agent outputting two text outputs on the same run. I...
seb7wake
seb7wakeOP3w ago
Hm ya my guess is that it's just the openai api outputting 2 text responses annoyingly Single step is a good idea, but then I suppose tool calls wouldn't work in that case
Ferreo
Ferreo3w ago
If you limit steps to 1 it'll output some chat, do the tool call but then no action on that call - so depending on your use case it might be useful or might not be. You could also try modifying the system prompt to make it not do it?
seb7wake
seb7wakeOP3w ago
Good to know, thanks!
Unknown User
Unknown User3w ago
Message Not Public
Sign In & Join Server To View
Ferreo
Ferreo3w ago
Do you with other models?
Unknown User
Unknown User3w ago
Message Not Public
Sign In & Join Server To View
seb7wake
seb7wakeOP3w ago
Ya my fix was to actually watch the chunks that come out and ignore the second text response if we detect it bit of a workaround but gets the job done
Unknown User
Unknown User3w ago
Message Not Public
Sign In & Join Server To View
seb7wake
seb7wakeOP3w ago
awesome, thanks for sharing! I'm using 4.1 so makes sense

Did you find this page helpful?