fix(agent): expose stable web stream message ids

This commit is contained in:
jxxghp
2026-09-12 01:25:26 +08:00
parent 9a2ad70fd3
commit 2427eb7e2f
2 changed files with 8 additions and 1 deletions

View File

@@ -290,7 +290,13 @@ def _build_web_agent_event_generator(
disconnected = False
terminal_sent = False
try:
yield {"type": "start", "session_id": session_id}
yield {
"type": "start",
"session_id": session_id,
# 让前端把本地占位助手段绑定到服务端展示段,后续 steering
# 应用事件即可按稳定 ID 定位真实消息边界。
"assistant_message_id": assistant_message_ref["message"].get("id"),
}
while not runtime_stop_state.is_system_stopped:
if await is_disconnected():
disconnected = True

View File

@@ -1480,6 +1480,7 @@ def test_web_agent_stream_queues_mid_run_input_into_the_same_assistant_stream():
assert '"status": "queued"' in second_body
assert '"status": "applied"' in first_body
assert '"assistant_message_id":' in first_body
assert first_body.count('data: {"type": "start"') == 1
assert first_body.count('data: {"type": "done"') == 1
assert len(instances) == 1