feat(webui): distinguish context compaction reasons (NAN-324) (#6389)
* feat(webui): distinguish context compaction reasons (NAN-324) * fix(webui): describe idle compaction cancellation as interruption * docs: omit compaction notice details from configuration guide * fix(i18n): make compaction notices read naturally * fix(i18n): keep CJK compaction notices concise * fix(i18n): describe idle compaction as unfinished
This commit is contained in:
1 parent
084b6bb394
commit
bc5c58d239
38 files changed
+540
-23
No files matched your search
@@ -11,5 +11,9 @@
|
||||
{"event":"retry_status","chat_id":"chat","state":"waiting","attempt":1,"max_attempts":4,"error_kind":"connection","retry_after_s":2},
|
||||
{"event":"retry_status","chat_id":"chat","state":"recovered","attempt":2,"max_attempts":4,"error_kind":"connection"},
|
||||
{"event":"retry_status","chat_id":"chat","state":"cleared","attempt":2,"max_attempts":4,"error_kind":"connection"},
|
||||
{"event":"retry_status","chat_id":"chat","state":"exhausted","attempt":4,"max_attempts":4,"error_kind":"connection"}
|
||||
{"event":"retry_status","chat_id":"chat","state":"exhausted","attempt":4,"max_attempts":4,"error_kind":"connection"},
|
||||
{"event":"context_compaction","chat_id":"chat","compaction_id":"reason-idle","phase":"succeeded","reason":"idle"},
|
||||
{"event":"context_compaction","chat_id":"chat","compaction_id":"reason-context_pressure","phase":"succeeded","reason":"context_pressure"},
|
||||
{"event":"context_compaction","chat_id":"chat","compaction_id":"reason-manual","phase":"succeeded","reason":"manual"},
|
||||
{"event":"context_compaction","chat_id":"chat","compaction_id":"reason-provider_native","phase":"succeeded","reason":"provider_native"}
|
||||
]
|
||||
@@ -10,7 +10,10 @@ export interface RecoveryState {
|
||||
failure_error_kind?: string
|
||||
}
|
||||
|
||||
export type CompactionReason = "idle" | "context_pressure" | "manual" | "provider_native"
|
||||
|
||||
export interface ContextCompaction {
|
||||
reason?: CompactionReason
|
||||
id: string
|
||||
phase: "started" | "succeeded" | "failed" | "cancelled"
|
||||
}
|
||||
@@ -32,6 +35,7 @@ export type NotificationEvent =
|
||||
turn_id?: string
|
||||
compaction_id: string
|
||||
phase: ContextCompaction["phase"]
|
||||
reason?: CompactionReason
|
||||
}
|
||||
|
||||
function isRecord(value: unknown): value is Record<string, unknown> {
|
||||
@@ -42,6 +46,10 @@ function optional(value: unknown, type: "boolean" | "number" | "string"): boolea
|
||||
return value === undefined || typeof value === type
|
||||
}
|
||||
|
||||
export function isCompactionReason(value: unknown): value is CompactionReason {
|
||||
return value === "idle" || value === "context_pressure" || value === "manual" || value === "provider_native"
|
||||
}
|
||||
|
||||
export function isCompactionPhase(value: unknown): value is ContextCompaction["phase"] {
|
||||
return value === "started" || value === "succeeded" || value === "failed" || value === "cancelled"
|
||||
}
|
||||
@@ -69,7 +77,9 @@ export function decodeNotification(value: unknown): NotificationEvent | null | u
|
||||
return isRecoveryState(value) ? value as unknown as NotificationEvent : null
|
||||
}
|
||||
return typeof value.compaction_id === "string" && value.compaction_id.length > 0
|
||||
&& isCompactionPhase(value.phase) ? value as unknown as NotificationEvent : null
|
||||
&& isCompactionPhase(value.phase)
|
||||
&& (value.reason === undefined || isCompactionReason(value.reason))
|
||||
? value as unknown as NotificationEvent : null
|
||||
}
|
||||
|
||||
function isRetryStatus(value: Record<string, unknown>): boolean {
|
||||
|
||||
Reference in new issue
Block a user