I’m running Qwen 3.8 27B in the AI assistant and keep getting hit with “The model stream stalled: no data received for 180 seconds. This is usually a transient connection issue — please try again.”. Based on the traces in my LocalAI instance, the issue is N8N hanging up after making tool calls. It could also be trying to impose a GBNF rather than letting Qwen run YAML which tanks its performance and is an issue I’ve had elsewhere - I can’t tell, the configuration parameters aren’t exposed.
This occurs when it does a tool call that needs a huge amount of prefill.
How do I fix this so it tolerates my slower model?
You can’t increase it, there’s no setting exposed. But the number tells you which limit you hit.
The runtime has two stall watchdogs: one that activates after 90 seconds of silence once content is flowing, and one that activates after 180 seconds before the first chunk. Yours says 180 seconds, so it’s the one for the first output, which is exactly your prefill case. The code comment on that constant acknowledges that large cache-miss prompts can spend between one and three minutes processing prompts before anything is emitted.
That also explains your LocalAI traces. On the deadline n8n aborts that attempt’s request to release the socket, then silently re-issues once, but only when nothing had streamed yet. So a prefill stall gives you two aborted requests.
Both timeouts are runtime options, not configuration, and there’s no env var. Other Instance AI timeouts are exposed (sandbox, confirmation, thread TTL) but not these, so it’s worth a feature request.
What helps is getting prefill under 180s. Biggest lever is prompt cache reuse on LocalAI, since the limit is written around cache misses. Then shrink what’s sent: N8N_INSTANCE_AI_OBSERVER_MESSAGE_TOKENS (default 30000) and N8N_INSTANCE_AI_REFLECTOR_OBSERVATION_TOKENS (default 40000) compress history sooner, and disabling unused tool surfaces (N8N_INSTANCE_AI_SANDBOX_ENABLED, N8N_INSTANCE_AI_BROWSER_USE_ENABLED, N8N_INSTANCE_AI_LOCAL_GATEWAY_DISABLED) trims the schema block prepended each turn.
n8n isn’t imposing one on GBNF. It uses the OpenAI-compatible provider in the AI SDK and sends plain JSON Schema tool definitions. If a grammar is being built, LocalAI builds it from these definitions, so this process takes place on your side. Having fewer tools helps too.
Hi @Wolvenmoon Welcome! n_batch decides how many prompt tokens go through each forward pass, so on the backend default a large prefill is split into many small passes and time to first token scales with that count. Raise it in the model’s options array, and put threads_batch alongside it at your physical core count: