fix(agent): preserve streamed replies after model failures (#6494)

* fix(agent): preserve streamed replies after model failures

* test(webui): settle lazy imports and async settings saves

* test(agent): synchronize estimation checks at the operation boundary

* docs(webui): explain retained replies after stream failures
This commit is contained in:
chengyongru authored and GitHub committed 2026-10-27 16:22:33 +08:00
1 parent b6536bfc5e
commit 219c8bb2bc
31 files changed
+462 -27

No files matched your search

+1 -1
View File
@@ -5,7 +5,7 @@
{"event":"context_compaction","chat_id":"chat","compaction_id":"c1","phase":"cancelled"},
{"event":"recovery_state","chat_id":"chat","status":"resuming","recovery_id":"r1","attempts":0},
{"event":"recovery_state","chat_id":"chat","status":"awaiting_user","recovery_id":"r1","attempts":1,"reason":"tool_state_unknown","can_continue":false},
{"event":"recovery_state","chat_id":"chat","status":"awaiting_user","recovery_id":"r2","attempts":0,"reason":"model_request_failed","failure_error_kind":"connection"},
{"event":"recovery_state","chat_id":"chat","status":"awaiting_user","recovery_id":"r2","attempts":0,"reason":"model_request_failed","failure_error_kind":"connection","reply_preserved":true},
{"event":"recovery_state","chat_id":"chat","status":"recovered","recovery_id":"r1","attempts":1},
{"event":"recovery_state","chat_id":"chat","status":"failed","recovery_id":"r1","attempts":2},
{"event":"retry_status","chat_id":"chat","state":"waiting","attempt":1,"max_attempts":4,"error_kind":"connection","retry_after_s":2},
+2
View File
@@ -8,6 +8,7 @@ export interface RecoveryState {
attempts?: number
can_continue?: boolean
failure_error_kind?: string
reply_preserved?: boolean
}
export type CompactionReason = "idle" | "context_pressure" | "manual" | "provider_native"
@@ -63,6 +64,7 @@ export function isRecoveryState(value: unknown): value is RecoveryState {
&& optional(value.attempts, "number")
&& optional(value.can_continue, "boolean")
&& optional(value.failure_error_kind, "string")
&& optional(value.reply_preserved, "boolean")
}
/** Undefined means another protocol family; null means a malformed notification. */