Skip to content

feat: recover empty and stalled responses - #4

Open
wuxiaoqiang12 wants to merge 5 commits into
developing-today:mainfrom
wuxiaoqiang12:fix-empty-response-recovery
Open

feat: recover empty and stalled responses#4
wuxiaoqiang12 wants to merge 5 commits into
developing-today:mainfrom
wuxiaoqiang12:fix-empty-response-recovery

Conversation

@wuxiaoqiang12

@wuxiaoqiang12 wuxiaoqiang12 commented Aug 11, 2026

Copy link
Copy Markdown

Summary

  • recover provider turns that complete with finish: "unknown", zero output tokens, no text, and no explicit error
  • abort requests that remain busy for 200 seconds without text, reasoning, tool activity, or output tokens, then send continue after idle
  • delay and revalidate recovery on idle, reusing the existing throttle and consecutive retry limits
  • preserve user-initiated abort behavior and suppress retries while waiting for question or permission responses, including legacy and v2 events
  • cancel the stalled-request watchdog as soon as real assistant activity begins, so long streaming responses and tool executions have no total-duration limit
  • reschedule throttled retries instead of silently dropping them and dispose pending timers cleanly
  • document retryEmptyResponses and stalledRequestTimeoutMs, and commit rebuilt dist artifacts

Motivation

Some provider failures do not emit a retryable session.error. One observed failure records an assistant message with finish: "unknown", zero output tokens, and no text, then emits session.idle. Another leaves the session busy for an unusually long time without producing any assistant activity. Both cases stop useful progress until the user manually aborts and enters continue.

This change uses strict per-turn evidence to distinguish completed empty responses and stalled first responses from normal replies, tool calls, user aborts, questions, and permission prompts. The stalled watchdog defaults to 200 seconds and can be disabled with stalledRequestTimeoutMs: 0.

Verification

  • bun test (21 tests passed)
  • bun run check
  • bun run build
  • loaded the rebuilt local plugin with OpenCode 1.17.20 in an isolated server configuration and verified /ac and /auto-continue registration

XiaoqiangWu added 2 commits August 11, 2026 12:47
Track assistant output evidence and retry strict empty unknown completions after idle. Prevent retries while aborted or waiting for questions and permissions, and cover the recovery flow with tests.

Signed-off-by: XiaoqiangWu <wuxiaoqiang.rtos@huawei.com>
Abort busy requests that produce no assistant activity for 200 seconds, then continue after idle. Preserve user abort handling and cancel the watchdog on output, questions, permissions, or tool activity.

Signed-off-by: XiaoqiangWu <wuxiaoqiang.rtos@huawei.com>
@wuxiaoqiang12 wuxiaoqiang12 changed the title fix: recover completed empty responses feat: recover empty and stalled responses Aug 11, 2026
XiaoqiangWu added 3 commits August 11, 2026 20:50
Some OpenCode versions complete empty assistant messages without emitting an idle event. Trigger the existing guarded recovery path when the final unknown completion arrives and cover the behavior with a regression test.

Signed-off-by: XiaoqiangWu <wuxiaoqiang.rtos@huawei.com>
OpenCode can update the original user message summary after an empty assistant completion. Track the active user message ID so duplicate updates do not reset the turn and cancel the queued retry.

Signed-off-by: XiaoqiangWu <wuxiaoqiang.rtos@huawei.com>
Providers can emit partial text while completing a response with an unknown finish and zero output tokens. Treat these abnormal completions as recoverable so auto-continue matches the tab status warning.

Signed-off-by: XiaoqiangWu <wuxiaoqiang.rtos@huawei.com>
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.

1 participant