fix(webui): preserve answer checkpoints and stream order (#6368)

* fix(webui): preserve answer checkpoints and stream order

* fix(stream): close hosted-tool answer segments at the producer
This commit is contained in:
chengyongru authored and GitHub committed 2026-10-21 18:30:52 +08:00
1 parent d2ab462b42
commit 76da55994b
19 files changed
+745 -195

No files matched your search

+4 -2
View File
@@ -1,4 +1,4 @@
/** Byte- and entry-bounded in-memory LRU for JSON-shaped WebUI state. */
/** Byte- and entry-bounded in-memory LRU for WebUI state. */
export class MemoryLruCache<T> {
private entries = new Map<string, { value: T; bytes: number }>();
private sizes = new WeakMap<object, number>();
@@ -46,7 +46,9 @@ export class MemoryLruCache<T> {
if (!value || typeof value !== "object") return 8;
const cached = this.sizes.get(value);
if (cached !== undefined) return cached;
const size = 32 + Object.values(value).reduce<number>(
const values = value instanceof Map ? Array.from(value.entries())
: value instanceof Set ? Array.from(value) : Object.values(value);
const size = 32 + values.reduce<number>(
(total, item) => total + this.estimate(item),
0,
);