fix(opencode): считать реальный прогресс стрима для idle-детекции
All checks were successful
CI / test (pull_request) Successful in 1m9s
CI / build-and-package (amd64, linux) (pull_request) Successful in 53s
CI / build-and-package (amd64, windows) (pull_request) Successful in 52s

Растущий в один text-парт стрим (text-delta) и reasoning больше не
выглядят как зависшая нейронка: idle-таймер сбрасывается по росту
числа партов и суммарной длины text/reasoning.
This commit is contained in:
ki.sagidullin
2026-08-19 19:11:26 +05:00
parent b5fb583c90
commit be4d749c45
5 changed files with 181 additions and 54 deletions

View File

@@ -120,9 +120,10 @@ func (r *Runner) awaitVerdict(ctx context.Context, c *Client, model *ModelRef, s
admittedAt = adm.TimeCreated
}
// Прогресс = число text-партов в новых assistant-сообщениях. Рост сбрасывает
// idle-таймер (LLM стримит = жив).
lastCount := -1
// Прогресс = число контент-партов + суммарная длина их текста в новых
// assistant-сообщениях (progressOf). Рост сбрасывает idle-таймер: LLM
// стримит (даже в один растущий text-парт) или думает (reasoning) = жив.
lastParts, lastTextLen := -1, -1
lastProgress := time.Now()
launch := time.Now()
@@ -164,10 +165,11 @@ func (r *Runner) awaitVerdict(ctx context.Context, c *Client, model *ModelRef, s
return nil, err
}
cur, count := newestAssistant(msgs, admittedAt)
if count != lastCount {
cur, _ := newestAssistant(msgs, admittedAt)
parts, textLen := progressOf(msgs, admittedAt)
if parts != lastParts || textLen != lastTextLen {
lastProgress = time.Now()
lastCount = count
lastParts, lastTextLen = parts, textLen
}
now := time.Now()
if now.Sub(lastProgress) > r.IdleTimeout {