fix(opencode): считать реальный прогресс стрима для idle-детекции
Растущий в один text-парт стрим (text-delta) и reasoning больше не выглядят как зависшая нейронка: idle-таймер сбрасывается по росту числа партов и суммарной длины text/reasoning.
This commit is contained in:
@@ -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 {
|
||||
|
||||
Reference in New Issue
Block a user