tool execution hangs indefinitely when using the SDK in cloudflare agents-starter template #5353
-
Vercel AI SDK tools execution gets stuck on await when using cloudflare/agents-starter templateI'm encountering an issue where tool execution gets stuck on await when using the Cloudflare agents-starter template with Vercel's AI SDK. Issue DescriptionWhen attempting to execute a tool using the AI SDK's tool execution functionality, the code hangs indefinitely on the await call. Interestingly, the tool executing works perfectly fine in fetch function call. export default {
async fetch(request: Request, env: Env, ctx: ExecutionContext) {
const mcpClient = await createMCPClient({
transport: {
type: "sse",
url: "http://localhost:50729/sse",
},
});
const tools = await mcpClient.tools();
result = await tools.add.execute(
{ a: 12, b: 233 },
{ messages: [], toolCallId: "xxxx" }
)
console.log(result);
return new Response("hello world", { status: 200 });
} ReproductionI'm using code based on the Cloudflare agents-starter template with Vercel's AI SDK. Here's the relevant part of my code that I added in the above codebase here: // This gets stuck and never resolves
console.log(
"result: ",
await env.tools.add.execute(
{ a: 102, b: 23 },
{ messages: [], toolCallId: "43" }
)
);
console.log("waiting...."); // This line is never reached
I'm currently running this locally using `wrangler dev`. |
Beta Was this translation helpful? Give feedback.
Replies: 3 comments 3 replies
-
I had an issue using Bun with Vercel AI as no errors show - and just hangs. Using ts-node instead works and at least shows errors to debug. |
Beta Was this translation helpful? Give feedback.
-
@unique1o1 @leomercier are you both using
Could you provide more context on:
|
Beta Was this translation helpful? Give feedback.
-
@unique1o1 I see! Instead of storing tools in global env, you can use the |
Beta Was this translation helpful? Give feedback.
@unique1o1 I see! Instead of storing tools in global env, you can use the
executions
argument inprocessToolCalls
to call tools in theagents-starter
template.