dynamic agents - throwing in `instructions`

I use dynamic agents and throw inside instructions function if runtimeContext is not valid. Because of it, I can't initialize mastra dev, on some reasons on initializing it tries to call agent.generate() (with empty runtimeContext obviously) and fails.. Is that an issue to post or I'm doing something wrong?
3 Replies
Mastra Triager
Mastra Triager4mo ago
GitHub
[DISCORD:1394297453288755241] dynamic agents - throwing in `instruc...
This issue was created from Discord post: https://discord.com/channels/1309558646228779139/1394297453288755241 I use dynamic agents and throw inside instructions function if runtimeContext is not v...
Abhi Aiyer
Abhi Aiyer4mo ago
Hi @dashan108 we require the dynamic function to return the value. You will need to catch and return empty string in a dev environment vs production Throwing in those dynamic functions are not advised.
dashan108
dashan108OP4mo ago
ok, understood!

Did you find this page helpful?