From 6c438f7a4da234028e97dad38d4ab8f2e8514f31 Mon Sep 17 00:00:00 2001 From: Florian Egger Date: Tue, 19 May 2026 21:24:38 +0200 Subject: [PATCH] fix: remove artificial MAX_STREAM_CHUNKS limit that cut off long responses The plugin hard-capped streaming responses at 1000 chunks. For large models like qwen2.5:32b generating detailed answers, this limit was easily exceeded, causing the response to stop mid-sentence. The Ollama stream already terminates naturally when the model sends the final done signal, so the artificial chunk limit served no purpose. - src/chat-view.ts: Remove chunkCount tracking and MAX_STREAM_CHUNKS constant. Let the stream run until Ollama signals completion. --- main.js | 6 ------ src/chat-view.ts | 7 ------- 2 files changed, 13 deletions(-) diff --git a/main.js b/main.js index 33fc725..3f6b802 100644 --- a/main.js +++ b/main.js @@ -9337,7 +9337,6 @@ ${userMessage}` : userMessage; const stream = this.ollamaClient.streamChat(completeMessages, tools); let fullResponse = ""; let toolCalls = []; - let chunkCount = 0; for await (const chunk of stream) { if (chunk.content) { fullResponse += chunk.content; @@ -9350,10 +9349,6 @@ ${userMessage}` : userMessage; if (chunk.tool_calls) { toolCalls = [...toolCalls, ...chunk.tool_calls]; } - chunkCount++; - if (chunkCount > MAX_STREAM_CHUNKS) { - break; - } } if (toolCalls.length > 0) { await this.processToolCalls( @@ -9391,7 +9386,6 @@ ${userMessage}` : userMessage; } } }; -var MAX_STREAM_CHUNKS = 1e3; var MAX_TOOL_CALLS = 5; // src/constants.ts diff --git a/src/chat-view.ts b/src/chat-view.ts index 7a2f14f..4bbff71 100755 --- a/src/chat-view.ts +++ b/src/chat-view.ts @@ -487,7 +487,6 @@ export class ChatView extends ItemView { let fullResponse = ''; let toolCalls: OllamaToolCall[] = []; - let chunkCount = 0; for await (const chunk of stream) { if (chunk.content) { @@ -502,11 +501,6 @@ export class ChatView extends ItemView { if (chunk.tool_calls) { toolCalls = [...toolCalls, ...chunk.tool_calls]; } - - chunkCount++; - if (chunkCount > MAX_STREAM_CHUNKS) { - break; - } } // Process tool calls if any @@ -575,5 +569,4 @@ export class ChatView extends ItemView { private conversationStateManager: ConversationStateManager; } -const MAX_STREAM_CHUNKS = 1000; const MAX_TOOL_CALLS = 5;