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(),