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

+18 -1
View File
@@ -645,8 +645,25 @@ main()
assert len(requests) == 17
else:
await asyncio.wait_for(closing_request.wait(), 20)
await receive_until(lambda event: event.get("event") == "goal_status" and event.get("status") == "running")
waiting = await receive_until(lambda event: (
event.get("event") == "model_request"
and event.get("phase") == "started"
and event.get("usage", {}).get("request_count") == 16
))
assert waiting["usage"]["context_tokens"] == 10
assert len(waiting["round_usages"]) == 8
assert not any(event.get("event") == "turn_end" for event in events)
history_url = f"http://127.0.0.1:{ws_port}/api/sessions/{quote('websocket:' + chat_id, safe='')}/webui-thread"
headers = {"Authorization": f"Bearer {bootstrap['api_token']}"}
async with httpx.AsyncClient(trust_env=False) as client:
modern = await client.get(history_url, params={"include_model_requests": "1"}, headers=headers)
modern.raise_for_status()
persisted = [event for event in modern.json()["events"] if event["event"] == "model_request"]
assert persisted[-1]["request_id"] == waiting["request_id"]
assert persisted[-1]["usage"] == waiting["usage"]
legacy = await client.get(history_url, headers={**headers, "If-None-Match": modern.headers["etag"]})
assert legacy.status_code == 200
assert not any(event["event"] == "model_request" for event in legacy.json()["events"])
release_close.set()
end = await receive_until(lambda event: event.get("event") == "turn_end")
assert end.get("turn_id") == "goal-e2e"