diff --git a/sgl-router/src/routers/grpc/processing.rs b/sgl-router/src/routers/grpc/processing.rs index 7f2fe37d9..995bfbcd3 100644 --- a/sgl-router/src/routers/grpc/processing.rs +++ b/sgl-router/src/routers/grpc/processing.rs @@ -193,6 +193,8 @@ impl ResponseProcessor { (tool_calls, processed_text) = utils::parse_json_schema_response( &processed_text, &original_request.tool_choice, + &original_request.model, + history_tool_calls_count, ); } else if tool_parser_available { (tool_calls, processed_text) = self diff --git a/sgl-router/src/routers/grpc/utils.rs b/sgl-router/src/routers/grpc/utils.rs index 086d580a6..3bc3fabf1 100644 --- a/sgl-router/src/routers/grpc/utils.rs +++ b/sgl-router/src/routers/grpc/utils.rs @@ -542,6 +542,8 @@ pub fn create_stop_decoder( pub fn parse_json_schema_response( processed_text: &str, tool_choice: &Option, + model: &str, + history_tool_calls_count: usize, ) -> (Option>, String) { match tool_choice { Some(ToolChoice::Function { function, .. }) => { @@ -549,7 +551,12 @@ pub fn parse_json_schema_response( match serde_json::from_str::(processed_text) { Ok(params) => { let tool_call = ToolCall { - id: format!("call_{}", Uuid::new_v4()), + id: generate_tool_call_id( + model, + &function.name, + 0, + history_tool_calls_count, + ), tool_type: "function".to_string(), function: FunctionCallResponse { name: function.name.clone(), @@ -580,7 +587,12 @@ pub fn parse_json_schema_response( let parameters = obj.get("parameters")?; Some(ToolCall { - id: format!("call_{}_{}", i, Uuid::new_v4()), + id: generate_tool_call_id( + model, + &name, + i, + history_tool_calls_count, + ), tool_type: "function".to_string(), function: FunctionCallResponse { name,