When using chat() from @tanstack/ai with createWorkersAiChat from @cloudflare/tanstack-ai and providing no tools, the underlying stream crashes and falls back to non-streaming, which also crashes.
Root Cause:
@tanstack/ai defaults to passing tools: [] into the adapter when no tools are configured. The @cloudflare/tanstack-ai adapter maps this directly to env.AI.run(model, { tools: [] }).
Models like @cf/google/gemma-4-26b-a4b-it and @cf/qwen/qwen3-30b-a3b-fp8 run on vLLM, which strictly rejects tools: [] with an HTTP 400 error:
Value error, 'tools' must not be an empty array. Either provide at least one tool or omit the field entirely.
This causes env.AI.run to throw a connection error in streaming mode, and the fallback non-streaming request immediately throws the same error.
Proposed Fix:
In @cloudflare/tanstack-ai, the createWorkersAiBindingFetch (or adapter parsing logic) should delete the tools property if it receives an empty array before calling binding.run().
if (inputs && Array.isArray(inputs.tools) && inputs.tools.length === 0) {
delete inputs.tools;
}
When using
chat()from@tanstack/aiwithcreateWorkersAiChatfrom@cloudflare/tanstack-aiand providing no tools, the underlying stream crashes and falls back to non-streaming, which also crashes.Root Cause:
@tanstack/aidefaults to passingtools: []into the adapter when no tools are configured. The@cloudflare/tanstack-aiadapter maps this directly toenv.AI.run(model, { tools: [] }).Models like
@cf/google/gemma-4-26b-a4b-itand@cf/qwen/qwen3-30b-a3b-fp8run on vLLM, which strictly rejectstools: []with anHTTP 400error:Value error, 'tools' must not be an empty array. Either provide at least one tool or omit the field entirely.This causes
env.AI.runto throw a connection error in streaming mode, and the fallback non-streaming request immediately throws the same error.Proposed Fix:
In
@cloudflare/tanstack-ai, thecreateWorkersAiBindingFetch(or adapter parsing logic) should delete thetoolsproperty if it receives an empty array before callingbinding.run().