-
Notifications
You must be signed in to change notification settings - Fork 60
Open
Labels
enhancementNew feature or requestNew feature or request
Description
I keep on getting the same error and I have no clue why:
Q - ai:listThreadMessages - error
Error getting version:' [TypeError: dynamic module import unsupported]"
listThreadMessages function:
export const listThreadMessages = query({
args: {
// These arguments are required:
threadId: v.string(),
paginationOpts: paginationOptsValidator, // Used to paginate the messages.
streamArgs: vStreamArgs, // Used to stream messages.
},
handler: async (ctx, args) => {
const { threadId, paginationOpts, streamArgs } = args;
await authorizeThreadAccess(ctx, threadId);
const paginated = await listMessages(ctx, components.agent, {
threadId,
paginationOpts,
});
const streams = await syncStreams(ctx, components.agent, {
threadId,
streamArgs,
includeStatuses: ["aborted", "streaming", "finished"],
});
return {
...paginated,
streams,
// ... you can return other metadata here too.
// note: this function will be called with various permutations of delta
// and message args, so returning derived data .
};
},
});
Problem
Using a Node-only lib (e.g., @mendable/firecrawl-js
) inside a createTool
handler throws a generic “dynamic module import unsupported” that surfaces from an unrelated function like ai.listThreadMessages
, hiding the real cause.
Repro
- Import a Node-only lib in a
createTool
handler. - Use the agent with
ai.listThreadMessages
. - See: “Error getting version: [TypeError: dynamic module import unsupported]”.
Expected
Error should point to the offending tool (name + file) and say Node-only code must run in an action file with "use node"
and be invoked via ctx.runAction(...)
.
Workaround
Move Node-only usage to an internalAction
file with "use node"
and call it from the tool via ctx.runAction(...)
.
VERSION
"@convex-dev/agent": "^0.1.17",
Metadata
Metadata
Assignees
Labels
enhancementNew feature or requestNew feature or request