From 2427eb7e2f6ec8da1a8d9abbe810f512e753c5f7 Mon Sep 17 00:00:00 2001 From: jxxghp Date: Sat, 12 Sep 2026 01:25:26 +0800 Subject: [PATCH] fix(agent): expose stable web stream message ids --- app/application/messaging/webagentstream.py | 8 +++++++- tests/test_web_agent_stream.py | 1 + 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/app/application/messaging/webagentstream.py b/app/application/messaging/webagentstream.py index 7e49767cc..90b64f871 100644 --- a/app/application/messaging/webagentstream.py +++ b/app/application/messaging/webagentstream.py @@ -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 diff --git a/tests/test_web_agent_stream.py b/tests/test_web_agent_stream.py index 51ab27dc5..819b3ebf0 100644 --- a/tests/test_web_agent_stream.py +++ b/tests/test_web_agent_stream.py @@ -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