Hey everyone! I'm building a tool execution system where custom tool handlers are stored as code strings in the database and need to be executed at runtime inside a Convex internalAction. When I try to use new AsyncFunction("args", "context", "fetch", handlerCode) I get EvalError: Code generation from strings disallowed for this context. I originally had this running on a Cloudflare Worker but hit the exact same restriction there. Is there any way to enable dynamic code evaluation in Convex actions, or is this a hard V8 sandbox limitation?
If not, what's the recommended pattern for this use case? The tool handlers are defined by users in their workspace, synced to Convex as serialized code strings, and executed when an AI agent calls them. I'm considering either pre-registering handlers as named functions with a dispatch table, or using something like quickjs-emscripten as an embedded interpreter. Would love to hear if anyone has solved a similar problem or if there's a Convex-native approach I'm missing. Thanks!