From 87fc8cc3b7669cd141ca80d575506d402291b086 Mon Sep 17 00:00:00 2001 From: oudecheng <13802883547@139.com> Date: Fri, 12 Jun 2026 11:48:01 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E6=9B=B4=E6=96=B0=E5=B7=A5=E5=85=B7?= =?UTF-8?q?=E8=B0=83=E7=94=A8=E7=9A=84ID=E5=A4=84=E7=90=86=E9=80=BB?= =?UTF-8?q?=E8=BE=91=EF=BC=8C=E7=A1=AE=E4=BF=9D=E5=9C=A8=E7=BC=BA=E5=A4=B1?= =?UTF-8?q?=E6=97=B6=E7=94=9F=E6=88=90=E5=94=AF=E4=B8=80ID?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/gateway/ws.rs | 6 +++--- src/protocol/ws_adapter.rs | 6 +++--- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/gateway/ws.rs b/src/gateway/ws.rs index 9f92b8d..1b64e9d 100644 --- a/src/gateway/ws.rs +++ b/src/gateway/ws.rs @@ -767,7 +767,7 @@ fn chat_message_to_ws_outbound(msg: &crate::bus::ChatMessage) -> Vec let tc_reasoning = if has_content_or_reasoning { None } else { msg.reasoning_content.clone() }; for tool_call in tool_calls { outbound.push(WsOutbound::ToolCall { - id: msg.id.clone(), + id: tool_call.id.clone(), tool_call_id: tool_call.id.clone(), tool_name: tool_call.name.clone(), arguments: tool_call.arguments.clone(), @@ -798,7 +798,7 @@ fn chat_message_to_ws_outbound(msg: &crate::bus::ChatMessage) -> Vec let tool_state = msg.tool_state.as_ref().unwrap_or(&ToolMessageState::Completed); match tool_state { ToolMessageState::Completed => vec![WsOutbound::ToolResult { - id: msg.id.clone(), + id: msg.tool_call_id.clone().unwrap_or_else(|| uuid::Uuid::new_v4().to_string()), tool_call_id: msg.tool_call_id.clone().unwrap_or_default(), tool_name: msg.tool_name.clone().unwrap_or_default(), content: msg.content.clone(), @@ -809,7 +809,7 @@ fn chat_message_to_ws_outbound(msg: &crate::bus::ChatMessage) -> Vec timestamp: Some(msg.timestamp / 1000), }], ToolMessageState::PendingUserAction => vec![WsOutbound::ToolPending { - id: msg.id.clone(), + id: msg.tool_call_id.clone().unwrap_or_else(|| uuid::Uuid::new_v4().to_string()), tool_call_id: msg.tool_call_id.clone().unwrap_or_default(), tool_name: msg.tool_name.clone().unwrap_or_default(), content: msg.content.clone(), diff --git a/src/protocol/ws_adapter.rs b/src/protocol/ws_adapter.rs index c581420..6e08e79 100644 --- a/src/protocol/ws_adapter.rs +++ b/src/protocol/ws_adapter.rs @@ -32,7 +32,7 @@ pub(crate) fn ws_outbound_from_chat_message(message: &ChatMessage) -> Vec Vec vec![WsOutbound::ToolResult { - id: message.id.clone(), + id: message.tool_call_id.clone().unwrap_or_else(|| uuid::Uuid::new_v4().to_string()), tool_call_id: message.tool_call_id.clone().unwrap_or_default(), tool_name: message.tool_name.clone().unwrap_or_default(), content: message.content.clone(), @@ -74,7 +74,7 @@ pub(crate) fn ws_outbound_from_chat_message(message: &ChatMessage) -> Vec vec![WsOutbound::ToolPending { - id: message.id.clone(), + id: message.tool_call_id.clone().unwrap_or_else(|| uuid::Uuid::new_v4().to_string()), tool_call_id: message.tool_call_id.clone().unwrap_or_default(), tool_name: message.tool_name.clone().unwrap_or_default(), content: message.content.clone(),