Skip to content

fix(cli): recover stalled response streams - #11585

Closed
marius-kilocode wants to merge 6 commits into
mainfrom
abiding-wolfberry
Closed

fix(cli): recover stalled response streams#11585
marius-kilocode wants to merge 6 commits into
mainfrom
abiding-wolfberry

Conversation

@marius-kilocode

@marius-kilocode marius-kilocode commented Jun 23, 2026

Copy link
Copy Markdown
Collaborator

Foreground subagents could remain running indefinitely through two independent client-side wait paths.

A child could finish a command, begin the next model response, emit reasoning, and then receive no further stream data while the HTTP response remained open. Without a default chunk timeout, the stream neither completed nor failed, so session retry never ran and the parent Task continued awaiting the busy child.

Subagents also inherited the interactive suggest tool. Calling it waits for a human to accept or dismiss an action, but a Task child has no reliable direct interaction surface. The child could therefore wait inside the tool while the parent only reported the Task as in progress.

The response transport now applies a two-minute default idle timeout between SSE reads. Inactivity becomes the existing retryable ProviderResponseStreamError, allowing normal session retry to resume the child. Explicit chunkTimeout values still override the default, and 0 continues to disable it. Provider-level timeout handling remains in the fetch wrapper so it preserves the typed failure required by the retry path.

Task child prompts now disable suggest, matching the existing restriction on question, so subagents cannot enter a human-interaction wait.

The WebSocket retry tests and fallback lifecycle also include the corresponding later OpenCode fixes. Exhausted HTTP fallback state is retained instead of being pruned by the stream idle interval, and retry-failure tests terminate sockets through explicit readiness signals rather than depending on short wall-clock timeouts.

@marius-kilocode
marius-kilocode requested a review from a team June 23, 2026 12:03

const customFetch = options["fetch"]
const chunkTimeout = options["chunkTimeout"]
const chunkTimeout = streamTimeout({

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

WARNING: The new default idle timeout cannot be disabled from config

This makes STREAM_IDLE_TIMEOUT_MS apply to every provider that leaves chunkTimeout unset, but packages/opencode/src/config/provider.ts still defines chunkTimeout as PositiveInt. In practice that means users cannot set provider.<id>.options.chunkTimeout: 0 in kilo.json to opt out of the new 2-minute cutoff, so providers that legitimately pause for longer will now fail without a supported escape hatch.


Reply with @kilocode-bot fix it to have Kilo Code address this issue.

@kilo-code-bot

kilo-code-bot Bot commented Jun 23, 2026

Copy link
Copy Markdown
Contributor

Code Review Summary

Status: 1 Issue Found | Recommendation: Address before merge

Overview

Severity Count
CRITICAL 0
WARNING 1
SUGGESTION 0

Fix these issues in Kilo Cloud

Issue Details (click to expand)

WARNING

File Line Issue
packages/opencode/src/plugin/openai/ws-pool.ts 183 Skipping fallback entries during pruning makes the session-keyed websocket pool retain one PoolEntry per exhausted session until plugin disposal, which can grow without bound in long-lived processes.
Files Reviewed (3 files)
  • packages/opencode/src/plugin/openai/ws-pool.ts - 1 issue
  • packages/opencode/src/plugin/openai/ws.ts - 0 issues
  • packages/opencode/test/plugin/openai-ws.test.ts - 0 issues
Previous Review Summaries (3 snapshots, latest commit 7265d56)

Current summary above is authoritative. Previous snapshots are kept for context only.

Previous review (commit 7265d56)

Status: 1 Issue Found | Recommendation: Address before merge

Overview

Severity Count
CRITICAL 0
WARNING 1
SUGGESTION 0

Fix these issues in Kilo Cloud

Issue Details (click to expand)

WARNING

File Line Issue
packages/opencode/src/provider/provider.ts 1683 Default 2-minute idle timeout still cannot be disabled from config because packages/opencode/src/config/provider.ts keeps chunkTimeout as PositiveInt, so provider.<id>.options.chunkTimeout: 0 is rejected.
Files Reviewed (12 files)
  • .changeset/recover-stalled-streams.md - 0 issues
  • packages/opencode/src/kilocode/provider/provider.ts - 0 issues
  • packages/opencode/src/kilocode/session/llm.ts - 0 issues
  • packages/opencode/src/plugin/openai/ws-pool.ts - 0 issues
  • packages/opencode/src/plugin/openai/ws.ts - 0 issues
  • packages/opencode/src/provider/provider.ts - 1 issue
  • packages/opencode/src/session/llm.ts - 0 issues
  • packages/opencode/src/tool/task.ts - 0 issues
  • packages/opencode/test/kilocode/session-prompt-permission-refresh.test.ts - 0 issues
  • packages/opencode/test/kilocode/session/llm.test.ts - 0 issues
  • packages/opencode/test/plugin/openai-ws.test.ts - 0 issues
  • packages/opencode/test/tool/task.test.ts - 0 issues

Previous review (commit 4bc9e27)

Status: 1 Issue Found | Recommendation: Address before merge

Overview

Severity Count
CRITICAL 0
WARNING 1
SUGGESTION 0

Fix these issues in Kilo Cloud

Issue Details (click to expand)

WARNING

File Line Issue
packages/opencode/src/provider/provider.ts 1683 Default 2-minute idle timeout still cannot be disabled from config because packages/opencode/src/config/provider.ts keeps chunkTimeout as PositiveInt, so provider.<id>.options.chunkTimeout: 0 is rejected.
Files Reviewed (5 files)
  • .changeset/recover-stalled-streams.md - 0 issues
  • packages/opencode/src/provider/provider.ts - 1 issue
  • packages/opencode/src/tool/task.ts - 0 issues
  • packages/opencode/test/kilocode/session-prompt-permission-refresh.test.ts - 0 issues
  • packages/opencode/test/tool/task.test.ts - 0 issues

Previous review (commit f6805e0)

Status: 1 Issue Found | Recommendation: Address before merge

Overview

Severity Count
CRITICAL 0
WARNING 1
SUGGESTION 0

Fix these issues in Kilo Cloud

Issue Details (click to expand)

WARNING

File Line Issue
packages/opencode/src/provider/provider.ts 1682 Default 2-minute idle timeout cannot be disabled from config because chunkTimeout still only accepts positive integers.
Files Reviewed (7 files)
  • .changeset/recover-stalled-streams.md - 0 issues
  • packages/opencode/src/kilocode/provider/provider.ts - 0 issues
  • packages/opencode/src/kilocode/session/llm.ts - 0 issues
  • packages/opencode/src/provider/provider.ts - 1 issue
  • packages/opencode/src/session/llm.ts - 0 issues
  • packages/opencode/test/kilocode/session-prompt-permission-refresh.test.ts - 0 issues
  • packages/opencode/test/kilocode/session/llm.test.ts - 0 issues

Reviewed by gpt-5.4-2026-03-05 · Input: 89.2K · Output: 8.1K · Cached: 252.4K

Review guidance: REVIEW.md from base branch main

const now = Date.now()
for (const [key, entry] of pool) {
if (entry.busy) continue
if (entry.fallback) continue // kilocode_change - port upstream #30586

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

WARNING: Permanent fallback entries can accumulate per session

pool is keyed by session-id / x-session-affinity, so every session that exhausts websocket retries leaves behind one PoolEntry. Skipping fallback entries here means those entries are never removed until the plugin is disposed, which can turn into an unbounded map in long-lived CLI or extension processes. A bounded TTL for fallback entries would preserve the sticky fallback behavior without pinning every failed session forever.


Reply with @kilocode-bot fix it to have Kilo Code address this issue.

@github-actions

github-actions Bot commented Aug 3, 2026

Copy link
Copy Markdown
Contributor

To stay organized pull requests are automatically closed after 30 days of inactivity. If the pull request is still relevant please reopen it or create a fresh new one.

@github-actions github-actions Bot closed this Aug 3, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants