kilocode icon indicating copy to clipboard operation
kilocode copied to clipboard

[CRITICAL]: Task execution stops unexpectedly with local vLLM (Qwen3.5-27B) and large context window

Open mixonij opened this issue 7 months ago • 12 comments

Description

Description

When running a task with a locally deployed Qwen3.5-27B model via vLLM, the execution stops unexpectedly before completion. The model is configured with a 128K token context window.

Expected Behavior

The task should run continuously and complete successfully (either with a final answer or a proper error).

Actual Behavior

The task stops unexpectedly in the middle of execution. Kilo Code’s loading indicator disappears, and no further output is produced. No explicit error message is shown in the UI. I had to write "continue" in chat for resuming task.

Image

Heap snapshot

heap-9136-2026-04-27T061436901Z.zip

Plugins

No response

Kilo version

7.2.14

Steps to reproduce

  1. Start VS Code Kilo Code extension (v7.2.14).
  2. Start a new task, for example: "Refactor the error handling logic in a large source file (>1500 lines)." or Create new component.
  3. Wait and observe — the task stops mid‑way.

Operating System

Windows 10

mixonij avatar Apr 27 '26 06:04 mixonij

The same in Kilo CLI

mixonij avatar Apr 27 '26 06:04 mixonij

The same on qwen3.6-27B with latest kilo version and cloud model.

Image

Heap snapshot

heap-76296-2026-04-27T071746758Z.zip

mixonij avatar Apr 27 '26 07:04 mixonij

Same

s8n-anton avatar Apr 27 '26 08:04 s8n-anton

@marius-kilocode

s8n-anton avatar Apr 27 '26 08:04 s8n-anton

Same issue https://github.com/Kilo-Org/kilocode/issues/8476

mixonij avatar Apr 28 '26 07:04 mixonij

Local fix

Fix: Premature Session Termination with Qwen3.5 27B

Problem

When using Qwen/Qwen3.5-27B model via OpenAI-compatible API, the agent would prematurely terminate after tool call execution. Users were forced to type "continue" to resume work.

Analysis

Logs revealed the following sequence:

finish-step: stop
loop check: { lastAssistantFinish: "stop", ... }
exiting loop: { finish: "stop", ... }

Root Cause: The Qwen3.5 27B model, after executing a tool call, was responding with an empty message containing finish_reason="stop" (without any text content or subsequent tool calls). The agent interpreted this as session completion and exited the loop.

Solution

File: packages/opencode/src/session/prompt.ts:368-376

Change: Added content presence check for the last assistant message before exiting the loop.

// BEFORE
if (
  lastAssistant?.finish &&
  !["tool-calls", "unknown"].includes(lastAssistant.finish) &&
  lastUser.id < lastAssistant.id
) {
  break
}

// AFTER
const lastAssistantMsg = msgs.find(m => m.info.id === lastAssistant?.id)
const hasContent = lastAssistantMsg && lastAssistantMsg.parts.some(p => p.type === "text" || p.type === "tool")
if (
  lastAssistant?.finish &&
  !["tool-calls", "unknown"].includes(lastAssistant.finish) &&
  lastUser.id < lastAssistant.id &&
  hasContent  // ← NEW CHECK
) {
  break
}

Logic

The agent now exits the loop only if:

  1. finish is not "tool-calls" or "unknown"
  2. The last user message is older than the last assistant message
  3. NEW: Assistant message contains content (text or tool)

If Qwen sends an empty message with finish="stop", the agent does not exit the loop and waits for the next iteration.

mixonij avatar Apr 28 '26 17:04 mixonij

Image

Just had an agent running fine with Qwen3.6 35B A3B in LM Studio for a longer session. Those local models are hard to setup locally correctly.

The above suggested fix is probably not very safe since empty assistant messages with finish="stop" are normally a valid terminal state.

Can you try if Qwen3.6 works better for you?

marius-kilocode avatar Apr 28 '26 21:04 marius-kilocode

@marius-kilocode The problem in Dense models (Qwen3.5 27B, Qwen3.6 27B). Qwen3.6 35B A3B has MoE architecture and there is no problems (or I accidentally did not notice). Unexpected task termination only on Qwen3.5 27B/Qwen3.6 27B. Tested on both local and cloud models. I understand that fix is not safe, just in case of detailing problem.

mixonij avatar Apr 29 '26 06:04 mixonij

I guess the problem might be on Qwen3.5 9B too

mixonij avatar Apr 29 '26 06:04 mixonij

@marius-kilocode , I experience same problem on Qwen3.6 35B A3B.

kaomoneus avatar Jun 09 '26 09:06 kaomoneus

Same here on Qwen3.6 35B A3B

steffanhalv avatar Jun 12 '26 11:06 steffanhalv

To stay organized issues are automatically closed after 60 days of no activity. If the issue is still relevant please reopen it or create a fresh new one.

github-actions[bot] avatar Aug 12 '26 06:08 github-actions[bot]