fix(webui): update usage and tool progress during active turns (#6553)

* fix(webui): stream model status and usage during active turns

* fix(webui): keep live rounds and active-run status consistent

* fix(webui): reuse existing run indicators without extra status text

* fix(webui): preserve live activity and batch durable delivery

Cancel and drain sibling tools when progress notifications fail, retain balanced checkpoints, and keep model telemetry separate from answer provenance.

Group-commit already queued activity at the channel delivery boundary while preserving FIFO, generation ownership, per-envelope admission, and commit-before-fanout semantics. Isolate invalid members without dropping valid neighboring events.

Retain tool detail lazy grouping and cover scheduling, cancellation, persistence, encoding failures, and projection regressions.

* test(webui): separate standard-library imports in batch regression

* test: tighten live execution checks and clarify contracts

* refactor: remove redundant live execution comments

* refactor: settle tool results through one output path
This commit is contained in:
chengyongru authored and GitHub committed 2026-11-04 16:27:24 +08:00
1 parent 006a535537
commit 8ff04aad2b
52 files changed
+2065 -211

No files matched your search

+14
View File
@@ -387,6 +387,19 @@ function parseThreadProjectionEvent(value: unknown): ThreadProjectionEvent {
|| !isCompactionPhase(value.phase)
|| (value.reason !== undefined && !isCompactionReason(value.reason))) break;
return value as unknown as ThreadProjectionEvent;
case "model_request": {
const isUsage = (usage: unknown) => isRecord(usage)
&& Object.values(usage).every((count) => typeof count === "number" && Number.isFinite(count) && count >= 0);
if (typeof value.request_id !== "string" || !value.request_id
|| typeof value.run_id !== "string" || !value.run_id
|| !Number.isSafeInteger(value.sequence) || Number(value.sequence) < 0
|| !["started", "completed", "failed", "cancelled"].includes(String(value.phase))
|| (value.usage !== undefined && !isUsage(value.usage))
|| (value.round_usages !== undefined && (!Array.isArray(value.round_usages) || !value.round_usages.every(isUsage)))
|| (value.context_window_tokens !== undefined && (typeof value.context_window_tokens !== "number"
|| !Number.isFinite(value.context_window_tokens) || value.context_window_tokens < 0))) break;
return value as unknown as ThreadProjectionEvent;
}
case "turn_end":
return value as unknown as ThreadProjectionEvent;
}
@@ -436,6 +449,7 @@ export async function fetchWebuiThread(
if (options?.direction) params.set("direction", options.direction);
if (options?.before) params.set("before", options.before);
if (options?.after) params.set("after", options.after);
params.set("include_model_requests", "1");
const query = params.toString();
const suffix = query ? `?${query}` : "";
const url = `${resolvedBase}/api/sessions/${encodeURIComponent(key)}/webui-thread${suffix}`;