Files
awesome-reviewers/_reviewers/azure-sdk-for-net-surface-errors-appropriately.json
2025-07-03 10:48:16 +03:00

164 lines
48 KiB
JSON

[
{
"discussion_id": "2058815959",
"pr_number": 49293,
"pr_file": "sdk/ai/Azure.AI.Projects/README.md",
"created_at": "2025-04-24T16:18:50+00:00",
"commented_code": "while (toolOutputs.Count > 0);\n```\n\n#### Function call executed automatically\n\nIn addition to the manual function calls, SDK supports automatic function calling. Here is the example:\n\nHere we use other functions for demonstration:\n```C# Snippet:StreamingWithAutoFunctionCall_DefineFunctions\nprivate class Address\n{\n public string Street { get; set; }\n public string City { get; set; }\n}\n\nprivate int GetHumidityByAddress(Address address)\n{\n return (address.City == \"Seattle\") ? 60 : 80;\n}\n\nprivate string[] GetWeatherByAddresses(Dictionary<string, string>[] addresses, string unit = \"F\")\n{\n string[] temps = new string[addresses.Length];\n for (int i = 0; i < addresses.Length; i++)\n {\n if (addresses[i].TryGetValue(\"city\", out string city))\n {\n temps[i] = string.Format(\"{0}{1}\", (city == \"Seattle\") ? \"20\" : \"50\", unit);\n }\n else\n {\n throw new ArgumentException(\"Each address must contain 'street' and 'city' keys.\");\n }\n }\n return temps;\n}\n```\nNow we define the function definitions:\n```C# Snippet:StreamingWithAutoFunctionCall_DefineFunctionTools\nprivate FunctionToolDefinition geHhumidityByAddressTool = new(\n name: \"GetHumidityByAddress\",\n description: \"Get humidity by street and city\",\n parameters: BinaryData.FromObjectAsJson(\n new\n {\n Type = \"object\",\n Properties = new\n {\n Address = new\n {\n Type = \"object\",\n Properties = new\n {\n Street = new\n {\n Type = \"string\",\n Description = \"Street\"\n },\n City = new\n {\n Type = \"string\",\n Description = \"city\"\n },\n },\n Required = new[] { \"street\", \"city\" }\n }\n },\n Required = new[] { \"address\" }\n },\n new JsonSerializerOptions() { PropertyNamingPolicy = JsonNamingPolicy.CamelCase }));\n\nprivate FunctionToolDefinition getWeatherByAddressesTool = new(\n name: \"GetWeatherByAddresses\",\n description: \"Get weather by street and city\",\n parameters: BinaryData.FromObjectAsJson(\n new\n {\n Type = \"object\",\n Properties = new\n {\n Addresses = new\n {\n Type = \"array\",\n Description = \"A list of addresses\",\n Items = new\n {\n Type = \"object\",\n Properties = new\n {\n Street = new\n {\n Type = \"string\",\n Description = \"Street\"\n },\n City = new\n {\n Type = \"string\",\n description = \"city\"\n },\n },\n Required = new[] { \"street\", \"city\" }\n }\n },\n Unit = new\n {\n Type = \"string\",\n Enum = new[] { \"c\", \"f\" },\n },\n },\n Required = new[] { \"addresses\" }\n },\n new JsonSerializerOptions() { PropertyNamingPolicy = JsonNamingPolicy.CamelCase }));\n```\nUse `EnableAutoFunctionCall` to enable the auto function call:\n```C# Snippet:StreamingWithAutoFunctionCall_EnableAutoFunctionCalls\nList<ToolOutput> toolOutputs = new();\nDictionary<string, Delegate> delegates = new();\ndelegates.Add(nameof(GetWeatherByAddresses), GetWeatherByAddresses);\ndelegates.Add(nameof(GetHumidityByAddress), GetHumidityByAddress);\nAIProjectClientOptions options = new();\noptions.EnableAutoFunctionCalls(delegates);",
"repo_full_name": "Azure/azure-sdk-for-net",
"discussion_comments": [
{
"comment_id": "2058815959",
"repo_full_name": "Azure/azure-sdk-for-net",
"pr_number": 49293,
"pr_file": "sdk/ai/Azure.AI.Projects/README.md",
"discussion_id": "2058815959",
"commented_code": "@@ -647,6 +648,172 @@ do\n while (toolOutputs.Count > 0);\n ```\n \n+#### Function call executed automatically\n+\n+In addition to the manual function calls, SDK supports automatic function calling. Here is the example:\n+\n+Here we use other functions for demonstration:\n+```C# Snippet:StreamingWithAutoFunctionCall_DefineFunctions\n+private class Address\n+{\n+ public string Street { get; set; }\n+ public string City { get; set; }\n+}\n+\n+private int GetHumidityByAddress(Address address)\n+{\n+ return (address.City == \"Seattle\") ? 60 : 80;\n+}\n+\n+private string[] GetWeatherByAddresses(Dictionary<string, string>[] addresses, string unit = \"F\")\n+{\n+ string[] temps = new string[addresses.Length];\n+ for (int i = 0; i < addresses.Length; i++)\n+ {\n+ if (addresses[i].TryGetValue(\"city\", out string city))\n+ {\n+ temps[i] = string.Format(\"{0}{1}\", (city == \"Seattle\") ? \"20\" : \"50\", unit);\n+ }\n+ else\n+ {\n+ throw new ArgumentException(\"Each address must contain 'street' and 'city' keys.\");\n+ }\n+ }\n+ return temps;\n+}\n+```\n+Now we define the function definitions:\n+```C# Snippet:StreamingWithAutoFunctionCall_DefineFunctionTools\n+private FunctionToolDefinition geHhumidityByAddressTool = new(\n+ name: \"GetHumidityByAddress\",\n+ description: \"Get humidity by street and city\",\n+ parameters: BinaryData.FromObjectAsJson(\n+ new\n+ {\n+ Type = \"object\",\n+ Properties = new\n+ {\n+ Address = new\n+ {\n+ Type = \"object\",\n+ Properties = new\n+ {\n+ Street = new\n+ {\n+ Type = \"string\",\n+ Description = \"Street\"\n+ },\n+ City = new\n+ {\n+ Type = \"string\",\n+ Description = \"city\"\n+ },\n+ },\n+ Required = new[] { \"street\", \"city\" }\n+ }\n+ },\n+ Required = new[] { \"address\" }\n+ },\n+ new JsonSerializerOptions() { PropertyNamingPolicy = JsonNamingPolicy.CamelCase }));\n+\n+private FunctionToolDefinition getWeatherByAddressesTool = new(\n+ name: \"GetWeatherByAddresses\",\n+ description: \"Get weather by street and city\",\n+ parameters: BinaryData.FromObjectAsJson(\n+ new\n+ {\n+ Type = \"object\",\n+ Properties = new\n+ {\n+ Addresses = new\n+ {\n+ Type = \"array\",\n+ Description = \"A list of addresses\",\n+ Items = new\n+ {\n+ Type = \"object\",\n+ Properties = new\n+ {\n+ Street = new\n+ {\n+ Type = \"string\",\n+ Description = \"Street\"\n+ },\n+ City = new\n+ {\n+ Type = \"string\",\n+ description = \"city\"\n+ },\n+ },\n+ Required = new[] { \"street\", \"city\" }\n+ }\n+ },\n+ Unit = new\n+ {\n+ Type = \"string\",\n+ Enum = new[] { \"c\", \"f\" },\n+ },\n+ },\n+ Required = new[] { \"addresses\" }\n+ },\n+ new JsonSerializerOptions() { PropertyNamingPolicy = JsonNamingPolicy.CamelCase }));\n+```\n+Use `EnableAutoFunctionCall` to enable the auto function call:\n+```C# Snippet:StreamingWithAutoFunctionCall_EnableAutoFunctionCalls\n+List<ToolOutput> toolOutputs = new();\n+Dictionary<string, Delegate> delegates = new();\n+delegates.Add(nameof(GetWeatherByAddresses), GetWeatherByAddresses);\n+delegates.Add(nameof(GetHumidityByAddress), GetHumidityByAddress);\n+AIProjectClientOptions options = new();\n+options.EnableAutoFunctionCalls(delegates);",
"comment_created_at": "2025-04-24T16:18:50+00:00",
"comment_author": "KrzysztofCwalina",
"comment_body": "what's the error handling model for automatic tool calls? i.e. where do I handle errors that might happen in tool calls?",
"pr_file_module": null
},
{
"comment_id": "2058960638",
"repo_full_name": "Azure/azure-sdk-for-net",
"pr_number": 49293,
"pr_file": "sdk/ai/Azure.AI.Projects/README.md",
"discussion_id": "2058815959",
"commented_code": "@@ -647,6 +648,172 @@ do\n while (toolOutputs.Count > 0);\n ```\n \n+#### Function call executed automatically\n+\n+In addition to the manual function calls, SDK supports automatic function calling. Here is the example:\n+\n+Here we use other functions for demonstration:\n+```C# Snippet:StreamingWithAutoFunctionCall_DefineFunctions\n+private class Address\n+{\n+ public string Street { get; set; }\n+ public string City { get; set; }\n+}\n+\n+private int GetHumidityByAddress(Address address)\n+{\n+ return (address.City == \"Seattle\") ? 60 : 80;\n+}\n+\n+private string[] GetWeatherByAddresses(Dictionary<string, string>[] addresses, string unit = \"F\")\n+{\n+ string[] temps = new string[addresses.Length];\n+ for (int i = 0; i < addresses.Length; i++)\n+ {\n+ if (addresses[i].TryGetValue(\"city\", out string city))\n+ {\n+ temps[i] = string.Format(\"{0}{1}\", (city == \"Seattle\") ? \"20\" : \"50\", unit);\n+ }\n+ else\n+ {\n+ throw new ArgumentException(\"Each address must contain 'street' and 'city' keys.\");\n+ }\n+ }\n+ return temps;\n+}\n+```\n+Now we define the function definitions:\n+```C# Snippet:StreamingWithAutoFunctionCall_DefineFunctionTools\n+private FunctionToolDefinition geHhumidityByAddressTool = new(\n+ name: \"GetHumidityByAddress\",\n+ description: \"Get humidity by street and city\",\n+ parameters: BinaryData.FromObjectAsJson(\n+ new\n+ {\n+ Type = \"object\",\n+ Properties = new\n+ {\n+ Address = new\n+ {\n+ Type = \"object\",\n+ Properties = new\n+ {\n+ Street = new\n+ {\n+ Type = \"string\",\n+ Description = \"Street\"\n+ },\n+ City = new\n+ {\n+ Type = \"string\",\n+ Description = \"city\"\n+ },\n+ },\n+ Required = new[] { \"street\", \"city\" }\n+ }\n+ },\n+ Required = new[] { \"address\" }\n+ },\n+ new JsonSerializerOptions() { PropertyNamingPolicy = JsonNamingPolicy.CamelCase }));\n+\n+private FunctionToolDefinition getWeatherByAddressesTool = new(\n+ name: \"GetWeatherByAddresses\",\n+ description: \"Get weather by street and city\",\n+ parameters: BinaryData.FromObjectAsJson(\n+ new\n+ {\n+ Type = \"object\",\n+ Properties = new\n+ {\n+ Addresses = new\n+ {\n+ Type = \"array\",\n+ Description = \"A list of addresses\",\n+ Items = new\n+ {\n+ Type = \"object\",\n+ Properties = new\n+ {\n+ Street = new\n+ {\n+ Type = \"string\",\n+ Description = \"Street\"\n+ },\n+ City = new\n+ {\n+ Type = \"string\",\n+ description = \"city\"\n+ },\n+ },\n+ Required = new[] { \"street\", \"city\" }\n+ }\n+ },\n+ Unit = new\n+ {\n+ Type = \"string\",\n+ Enum = new[] { \"c\", \"f\" },\n+ },\n+ },\n+ Required = new[] { \"addresses\" }\n+ },\n+ new JsonSerializerOptions() { PropertyNamingPolicy = JsonNamingPolicy.CamelCase }));\n+```\n+Use `EnableAutoFunctionCall` to enable the auto function call:\n+```C# Snippet:StreamingWithAutoFunctionCall_EnableAutoFunctionCalls\n+List<ToolOutput> toolOutputs = new();\n+Dictionary<string, Delegate> delegates = new();\n+delegates.Add(nameof(GetWeatherByAddresses), GetWeatherByAddresses);\n+delegates.Add(nameof(GetHumidityByAddress), GetHumidityByAddress);\n+AIProjectClientOptions options = new();\n+options.EnableAutoFunctionCalls(delegates);",
"comment_created_at": "2025-04-24T17:54:03+00:00",
"comment_author": "howieleung",
"comment_body": "When there is error, the error will be submitted back to the model in Json format liked \"{error: \"Error message\"}\". Then model will raise another function call to retry or figure out by its knowledge instead.",
"pr_file_module": null
},
{
"comment_id": "2059164667",
"repo_full_name": "Azure/azure-sdk-for-net",
"pr_number": 49293,
"pr_file": "sdk/ai/Azure.AI.Projects/README.md",
"discussion_id": "2058815959",
"commented_code": "@@ -647,6 +648,172 @@ do\n while (toolOutputs.Count > 0);\n ```\n \n+#### Function call executed automatically\n+\n+In addition to the manual function calls, SDK supports automatic function calling. Here is the example:\n+\n+Here we use other functions for demonstration:\n+```C# Snippet:StreamingWithAutoFunctionCall_DefineFunctions\n+private class Address\n+{\n+ public string Street { get; set; }\n+ public string City { get; set; }\n+}\n+\n+private int GetHumidityByAddress(Address address)\n+{\n+ return (address.City == \"Seattle\") ? 60 : 80;\n+}\n+\n+private string[] GetWeatherByAddresses(Dictionary<string, string>[] addresses, string unit = \"F\")\n+{\n+ string[] temps = new string[addresses.Length];\n+ for (int i = 0; i < addresses.Length; i++)\n+ {\n+ if (addresses[i].TryGetValue(\"city\", out string city))\n+ {\n+ temps[i] = string.Format(\"{0}{1}\", (city == \"Seattle\") ? \"20\" : \"50\", unit);\n+ }\n+ else\n+ {\n+ throw new ArgumentException(\"Each address must contain 'street' and 'city' keys.\");\n+ }\n+ }\n+ return temps;\n+}\n+```\n+Now we define the function definitions:\n+```C# Snippet:StreamingWithAutoFunctionCall_DefineFunctionTools\n+private FunctionToolDefinition geHhumidityByAddressTool = new(\n+ name: \"GetHumidityByAddress\",\n+ description: \"Get humidity by street and city\",\n+ parameters: BinaryData.FromObjectAsJson(\n+ new\n+ {\n+ Type = \"object\",\n+ Properties = new\n+ {\n+ Address = new\n+ {\n+ Type = \"object\",\n+ Properties = new\n+ {\n+ Street = new\n+ {\n+ Type = \"string\",\n+ Description = \"Street\"\n+ },\n+ City = new\n+ {\n+ Type = \"string\",\n+ Description = \"city\"\n+ },\n+ },\n+ Required = new[] { \"street\", \"city\" }\n+ }\n+ },\n+ Required = new[] { \"address\" }\n+ },\n+ new JsonSerializerOptions() { PropertyNamingPolicy = JsonNamingPolicy.CamelCase }));\n+\n+private FunctionToolDefinition getWeatherByAddressesTool = new(\n+ name: \"GetWeatherByAddresses\",\n+ description: \"Get weather by street and city\",\n+ parameters: BinaryData.FromObjectAsJson(\n+ new\n+ {\n+ Type = \"object\",\n+ Properties = new\n+ {\n+ Addresses = new\n+ {\n+ Type = \"array\",\n+ Description = \"A list of addresses\",\n+ Items = new\n+ {\n+ Type = \"object\",\n+ Properties = new\n+ {\n+ Street = new\n+ {\n+ Type = \"string\",\n+ Description = \"Street\"\n+ },\n+ City = new\n+ {\n+ Type = \"string\",\n+ description = \"city\"\n+ },\n+ },\n+ Required = new[] { \"street\", \"city\" }\n+ }\n+ },\n+ Unit = new\n+ {\n+ Type = \"string\",\n+ Enum = new[] { \"c\", \"f\" },\n+ },\n+ },\n+ Required = new[] { \"addresses\" }\n+ },\n+ new JsonSerializerOptions() { PropertyNamingPolicy = JsonNamingPolicy.CamelCase }));\n+```\n+Use `EnableAutoFunctionCall` to enable the auto function call:\n+```C# Snippet:StreamingWithAutoFunctionCall_EnableAutoFunctionCalls\n+List<ToolOutput> toolOutputs = new();\n+Dictionary<string, Delegate> delegates = new();\n+delegates.Add(nameof(GetWeatherByAddresses), GetWeatherByAddresses);\n+delegates.Add(nameof(GetHumidityByAddress), GetHumidityByAddress);\n+AIProjectClientOptions options = new();\n+options.EnableAutoFunctionCalls(delegates);",
"comment_created_at": "2025-04-24T20:19:15+00:00",
"comment_author": "KrzysztofCwalina",
"comment_body": "I am not sure this is how we want it to work. It will hide bugs and will be hard to debug. ",
"pr_file_module": null
},
{
"comment_id": "2060477164",
"repo_full_name": "Azure/azure-sdk-for-net",
"pr_number": 49293,
"pr_file": "sdk/ai/Azure.AI.Projects/README.md",
"discussion_id": "2058815959",
"commented_code": "@@ -647,6 +648,172 @@ do\n while (toolOutputs.Count > 0);\n ```\n \n+#### Function call executed automatically\n+\n+In addition to the manual function calls, SDK supports automatic function calling. Here is the example:\n+\n+Here we use other functions for demonstration:\n+```C# Snippet:StreamingWithAutoFunctionCall_DefineFunctions\n+private class Address\n+{\n+ public string Street { get; set; }\n+ public string City { get; set; }\n+}\n+\n+private int GetHumidityByAddress(Address address)\n+{\n+ return (address.City == \"Seattle\") ? 60 : 80;\n+}\n+\n+private string[] GetWeatherByAddresses(Dictionary<string, string>[] addresses, string unit = \"F\")\n+{\n+ string[] temps = new string[addresses.Length];\n+ for (int i = 0; i < addresses.Length; i++)\n+ {\n+ if (addresses[i].TryGetValue(\"city\", out string city))\n+ {\n+ temps[i] = string.Format(\"{0}{1}\", (city == \"Seattle\") ? \"20\" : \"50\", unit);\n+ }\n+ else\n+ {\n+ throw new ArgumentException(\"Each address must contain 'street' and 'city' keys.\");\n+ }\n+ }\n+ return temps;\n+}\n+```\n+Now we define the function definitions:\n+```C# Snippet:StreamingWithAutoFunctionCall_DefineFunctionTools\n+private FunctionToolDefinition geHhumidityByAddressTool = new(\n+ name: \"GetHumidityByAddress\",\n+ description: \"Get humidity by street and city\",\n+ parameters: BinaryData.FromObjectAsJson(\n+ new\n+ {\n+ Type = \"object\",\n+ Properties = new\n+ {\n+ Address = new\n+ {\n+ Type = \"object\",\n+ Properties = new\n+ {\n+ Street = new\n+ {\n+ Type = \"string\",\n+ Description = \"Street\"\n+ },\n+ City = new\n+ {\n+ Type = \"string\",\n+ Description = \"city\"\n+ },\n+ },\n+ Required = new[] { \"street\", \"city\" }\n+ }\n+ },\n+ Required = new[] { \"address\" }\n+ },\n+ new JsonSerializerOptions() { PropertyNamingPolicy = JsonNamingPolicy.CamelCase }));\n+\n+private FunctionToolDefinition getWeatherByAddressesTool = new(\n+ name: \"GetWeatherByAddresses\",\n+ description: \"Get weather by street and city\",\n+ parameters: BinaryData.FromObjectAsJson(\n+ new\n+ {\n+ Type = \"object\",\n+ Properties = new\n+ {\n+ Addresses = new\n+ {\n+ Type = \"array\",\n+ Description = \"A list of addresses\",\n+ Items = new\n+ {\n+ Type = \"object\",\n+ Properties = new\n+ {\n+ Street = new\n+ {\n+ Type = \"string\",\n+ Description = \"Street\"\n+ },\n+ City = new\n+ {\n+ Type = \"string\",\n+ description = \"city\"\n+ },\n+ },\n+ Required = new[] { \"street\", \"city\" }\n+ }\n+ },\n+ Unit = new\n+ {\n+ Type = \"string\",\n+ Enum = new[] { \"c\", \"f\" },\n+ },\n+ },\n+ Required = new[] { \"addresses\" }\n+ },\n+ new JsonSerializerOptions() { PropertyNamingPolicy = JsonNamingPolicy.CamelCase }));\n+```\n+Use `EnableAutoFunctionCall` to enable the auto function call:\n+```C# Snippet:StreamingWithAutoFunctionCall_EnableAutoFunctionCalls\n+List<ToolOutput> toolOutputs = new();\n+Dictionary<string, Delegate> delegates = new();\n+delegates.Add(nameof(GetWeatherByAddresses), GetWeatherByAddresses);\n+delegates.Add(nameof(GetHumidityByAddress), GetHumidityByAddress);\n+AIProjectClientOptions options = new();\n+options.EnableAutoFunctionCalls(delegates);",
"comment_created_at": "2025-04-25T15:39:49+00:00",
"comment_author": "howieleung",
"comment_body": "A similar solution also used in SK and asure-ai-project sdk. In python, we would do logger.warning function to log the warning. Can C# log warning?",
"pr_file_module": null
},
{
"comment_id": "2060669666",
"repo_full_name": "Azure/azure-sdk-for-net",
"pr_number": 49293,
"pr_file": "sdk/ai/Azure.AI.Projects/README.md",
"discussion_id": "2058815959",
"commented_code": "@@ -647,6 +648,172 @@ do\n while (toolOutputs.Count > 0);\n ```\n \n+#### Function call executed automatically\n+\n+In addition to the manual function calls, SDK supports automatic function calling. Here is the example:\n+\n+Here we use other functions for demonstration:\n+```C# Snippet:StreamingWithAutoFunctionCall_DefineFunctions\n+private class Address\n+{\n+ public string Street { get; set; }\n+ public string City { get; set; }\n+}\n+\n+private int GetHumidityByAddress(Address address)\n+{\n+ return (address.City == \"Seattle\") ? 60 : 80;\n+}\n+\n+private string[] GetWeatherByAddresses(Dictionary<string, string>[] addresses, string unit = \"F\")\n+{\n+ string[] temps = new string[addresses.Length];\n+ for (int i = 0; i < addresses.Length; i++)\n+ {\n+ if (addresses[i].TryGetValue(\"city\", out string city))\n+ {\n+ temps[i] = string.Format(\"{0}{1}\", (city == \"Seattle\") ? \"20\" : \"50\", unit);\n+ }\n+ else\n+ {\n+ throw new ArgumentException(\"Each address must contain 'street' and 'city' keys.\");\n+ }\n+ }\n+ return temps;\n+}\n+```\n+Now we define the function definitions:\n+```C# Snippet:StreamingWithAutoFunctionCall_DefineFunctionTools\n+private FunctionToolDefinition geHhumidityByAddressTool = new(\n+ name: \"GetHumidityByAddress\",\n+ description: \"Get humidity by street and city\",\n+ parameters: BinaryData.FromObjectAsJson(\n+ new\n+ {\n+ Type = \"object\",\n+ Properties = new\n+ {\n+ Address = new\n+ {\n+ Type = \"object\",\n+ Properties = new\n+ {\n+ Street = new\n+ {\n+ Type = \"string\",\n+ Description = \"Street\"\n+ },\n+ City = new\n+ {\n+ Type = \"string\",\n+ Description = \"city\"\n+ },\n+ },\n+ Required = new[] { \"street\", \"city\" }\n+ }\n+ },\n+ Required = new[] { \"address\" }\n+ },\n+ new JsonSerializerOptions() { PropertyNamingPolicy = JsonNamingPolicy.CamelCase }));\n+\n+private FunctionToolDefinition getWeatherByAddressesTool = new(\n+ name: \"GetWeatherByAddresses\",\n+ description: \"Get weather by street and city\",\n+ parameters: BinaryData.FromObjectAsJson(\n+ new\n+ {\n+ Type = \"object\",\n+ Properties = new\n+ {\n+ Addresses = new\n+ {\n+ Type = \"array\",\n+ Description = \"A list of addresses\",\n+ Items = new\n+ {\n+ Type = \"object\",\n+ Properties = new\n+ {\n+ Street = new\n+ {\n+ Type = \"string\",\n+ Description = \"Street\"\n+ },\n+ City = new\n+ {\n+ Type = \"string\",\n+ description = \"city\"\n+ },\n+ },\n+ Required = new[] { \"street\", \"city\" }\n+ }\n+ },\n+ Unit = new\n+ {\n+ Type = \"string\",\n+ Enum = new[] { \"c\", \"f\" },\n+ },\n+ },\n+ Required = new[] { \"addresses\" }\n+ },\n+ new JsonSerializerOptions() { PropertyNamingPolicy = JsonNamingPolicy.CamelCase }));\n+```\n+Use `EnableAutoFunctionCall` to enable the auto function call:\n+```C# Snippet:StreamingWithAutoFunctionCall_EnableAutoFunctionCalls\n+List<ToolOutput> toolOutputs = new();\n+Dictionary<string, Delegate> delegates = new();\n+delegates.Add(nameof(GetWeatherByAddresses), GetWeatherByAddresses);\n+delegates.Add(nameof(GetHumidityByAddress), GetHumidityByAddress);\n+AIProjectClientOptions options = new();\n+options.EnableAutoFunctionCalls(delegates);",
"comment_created_at": "2025-04-25T18:00:04+00:00",
"comment_author": "KrzysztofCwalina",
"comment_body": "there is no really a good way to do it. This is why in CM protoype, we had APIs for the caller to issue the tool call directly and handle errors if they want: https://github.com/Azure/azure-sdk-for-net/blob/main/sdk/cloudmachine/Azure.Projects/samples/HelloRAG/Program.cs#L57\r\n\r\nIn addition, in our automatic runner, there is a virtual method that the user can override to hook up any error handlers they want: https://github.com/Azure/azure-sdk-for-net/blob/main/sdk/cloudmachine/Azure.Projects.AI/src/Agents/ChatRunner.cs#L146",
"pr_file_module": null
},
{
"comment_id": "2060896976",
"repo_full_name": "Azure/azure-sdk-for-net",
"pr_number": 49293,
"pr_file": "sdk/ai/Azure.AI.Projects/README.md",
"discussion_id": "2058815959",
"commented_code": "@@ -647,6 +648,172 @@ do\n while (toolOutputs.Count > 0);\n ```\n \n+#### Function call executed automatically\n+\n+In addition to the manual function calls, SDK supports automatic function calling. Here is the example:\n+\n+Here we use other functions for demonstration:\n+```C# Snippet:StreamingWithAutoFunctionCall_DefineFunctions\n+private class Address\n+{\n+ public string Street { get; set; }\n+ public string City { get; set; }\n+}\n+\n+private int GetHumidityByAddress(Address address)\n+{\n+ return (address.City == \"Seattle\") ? 60 : 80;\n+}\n+\n+private string[] GetWeatherByAddresses(Dictionary<string, string>[] addresses, string unit = \"F\")\n+{\n+ string[] temps = new string[addresses.Length];\n+ for (int i = 0; i < addresses.Length; i++)\n+ {\n+ if (addresses[i].TryGetValue(\"city\", out string city))\n+ {\n+ temps[i] = string.Format(\"{0}{1}\", (city == \"Seattle\") ? \"20\" : \"50\", unit);\n+ }\n+ else\n+ {\n+ throw new ArgumentException(\"Each address must contain 'street' and 'city' keys.\");\n+ }\n+ }\n+ return temps;\n+}\n+```\n+Now we define the function definitions:\n+```C# Snippet:StreamingWithAutoFunctionCall_DefineFunctionTools\n+private FunctionToolDefinition geHhumidityByAddressTool = new(\n+ name: \"GetHumidityByAddress\",\n+ description: \"Get humidity by street and city\",\n+ parameters: BinaryData.FromObjectAsJson(\n+ new\n+ {\n+ Type = \"object\",\n+ Properties = new\n+ {\n+ Address = new\n+ {\n+ Type = \"object\",\n+ Properties = new\n+ {\n+ Street = new\n+ {\n+ Type = \"string\",\n+ Description = \"Street\"\n+ },\n+ City = new\n+ {\n+ Type = \"string\",\n+ Description = \"city\"\n+ },\n+ },\n+ Required = new[] { \"street\", \"city\" }\n+ }\n+ },\n+ Required = new[] { \"address\" }\n+ },\n+ new JsonSerializerOptions() { PropertyNamingPolicy = JsonNamingPolicy.CamelCase }));\n+\n+private FunctionToolDefinition getWeatherByAddressesTool = new(\n+ name: \"GetWeatherByAddresses\",\n+ description: \"Get weather by street and city\",\n+ parameters: BinaryData.FromObjectAsJson(\n+ new\n+ {\n+ Type = \"object\",\n+ Properties = new\n+ {\n+ Addresses = new\n+ {\n+ Type = \"array\",\n+ Description = \"A list of addresses\",\n+ Items = new\n+ {\n+ Type = \"object\",\n+ Properties = new\n+ {\n+ Street = new\n+ {\n+ Type = \"string\",\n+ Description = \"Street\"\n+ },\n+ City = new\n+ {\n+ Type = \"string\",\n+ description = \"city\"\n+ },\n+ },\n+ Required = new[] { \"street\", \"city\" }\n+ }\n+ },\n+ Unit = new\n+ {\n+ Type = \"string\",\n+ Enum = new[] { \"c\", \"f\" },\n+ },\n+ },\n+ Required = new[] { \"addresses\" }\n+ },\n+ new JsonSerializerOptions() { PropertyNamingPolicy = JsonNamingPolicy.CamelCase }));\n+```\n+Use `EnableAutoFunctionCall` to enable the auto function call:\n+```C# Snippet:StreamingWithAutoFunctionCall_EnableAutoFunctionCalls\n+List<ToolOutput> toolOutputs = new();\n+Dictionary<string, Delegate> delegates = new();\n+delegates.Add(nameof(GetWeatherByAddresses), GetWeatherByAddresses);\n+delegates.Add(nameof(GetHumidityByAddress), GetHumidityByAddress);\n+AIProjectClientOptions options = new();\n+options.EnableAutoFunctionCalls(delegates);",
"comment_created_at": "2025-04-25T21:22:03+00:00",
"comment_author": "howieleung",
"comment_body": "I just read the code in the link. I think it make sense to add handlers streaming, but I would not want to do it now for just onToolCall. It makes more sense to come up with a list of handler and implement after GA. And this is not going to be a breaking change. Are you OK?",
"pr_file_module": null
},
{
"comment_id": "2061032463",
"repo_full_name": "Azure/azure-sdk-for-net",
"pr_number": 49293,
"pr_file": "sdk/ai/Azure.AI.Projects/README.md",
"discussion_id": "2058815959",
"commented_code": "@@ -647,6 +648,172 @@ do\n while (toolOutputs.Count > 0);\n ```\n \n+#### Function call executed automatically\n+\n+In addition to the manual function calls, SDK supports automatic function calling. Here is the example:\n+\n+Here we use other functions for demonstration:\n+```C# Snippet:StreamingWithAutoFunctionCall_DefineFunctions\n+private class Address\n+{\n+ public string Street { get; set; }\n+ public string City { get; set; }\n+}\n+\n+private int GetHumidityByAddress(Address address)\n+{\n+ return (address.City == \"Seattle\") ? 60 : 80;\n+}\n+\n+private string[] GetWeatherByAddresses(Dictionary<string, string>[] addresses, string unit = \"F\")\n+{\n+ string[] temps = new string[addresses.Length];\n+ for (int i = 0; i < addresses.Length; i++)\n+ {\n+ if (addresses[i].TryGetValue(\"city\", out string city))\n+ {\n+ temps[i] = string.Format(\"{0}{1}\", (city == \"Seattle\") ? \"20\" : \"50\", unit);\n+ }\n+ else\n+ {\n+ throw new ArgumentException(\"Each address must contain 'street' and 'city' keys.\");\n+ }\n+ }\n+ return temps;\n+}\n+```\n+Now we define the function definitions:\n+```C# Snippet:StreamingWithAutoFunctionCall_DefineFunctionTools\n+private FunctionToolDefinition geHhumidityByAddressTool = new(\n+ name: \"GetHumidityByAddress\",\n+ description: \"Get humidity by street and city\",\n+ parameters: BinaryData.FromObjectAsJson(\n+ new\n+ {\n+ Type = \"object\",\n+ Properties = new\n+ {\n+ Address = new\n+ {\n+ Type = \"object\",\n+ Properties = new\n+ {\n+ Street = new\n+ {\n+ Type = \"string\",\n+ Description = \"Street\"\n+ },\n+ City = new\n+ {\n+ Type = \"string\",\n+ Description = \"city\"\n+ },\n+ },\n+ Required = new[] { \"street\", \"city\" }\n+ }\n+ },\n+ Required = new[] { \"address\" }\n+ },\n+ new JsonSerializerOptions() { PropertyNamingPolicy = JsonNamingPolicy.CamelCase }));\n+\n+private FunctionToolDefinition getWeatherByAddressesTool = new(\n+ name: \"GetWeatherByAddresses\",\n+ description: \"Get weather by street and city\",\n+ parameters: BinaryData.FromObjectAsJson(\n+ new\n+ {\n+ Type = \"object\",\n+ Properties = new\n+ {\n+ Addresses = new\n+ {\n+ Type = \"array\",\n+ Description = \"A list of addresses\",\n+ Items = new\n+ {\n+ Type = \"object\",\n+ Properties = new\n+ {\n+ Street = new\n+ {\n+ Type = \"string\",\n+ Description = \"Street\"\n+ },\n+ City = new\n+ {\n+ Type = \"string\",\n+ description = \"city\"\n+ },\n+ },\n+ Required = new[] { \"street\", \"city\" }\n+ }\n+ },\n+ Unit = new\n+ {\n+ Type = \"string\",\n+ Enum = new[] { \"c\", \"f\" },\n+ },\n+ },\n+ Required = new[] { \"addresses\" }\n+ },\n+ new JsonSerializerOptions() { PropertyNamingPolicy = JsonNamingPolicy.CamelCase }));\n+```\n+Use `EnableAutoFunctionCall` to enable the auto function call:\n+```C# Snippet:StreamingWithAutoFunctionCall_EnableAutoFunctionCalls\n+List<ToolOutput> toolOutputs = new();\n+Dictionary<string, Delegate> delegates = new();\n+delegates.Add(nameof(GetWeatherByAddresses), GetWeatherByAddresses);\n+delegates.Add(nameof(GetHumidityByAddress), GetHumidityByAddress);\n+AIProjectClientOptions options = new();\n+options.EnableAutoFunctionCalls(delegates);",
"comment_created_at": "2025-04-25T23:37:09+00:00",
"comment_author": "KrzysztofCwalina",
"comment_body": "Adding it after GA will be a breaking change, won't it? Non-streaming tool calls will be intercepted and handled automatically. This means custom user code that handles these tool calls won't execute anymore. Unless you add more knobs/options to preserve compat, and then it just adds complexity to the API. ",
"pr_file_module": null
},
{
"comment_id": "2062963457",
"repo_full_name": "Azure/azure-sdk-for-net",
"pr_number": 49293,
"pr_file": "sdk/ai/Azure.AI.Projects/README.md",
"discussion_id": "2058815959",
"commented_code": "@@ -647,6 +648,172 @@ do\n while (toolOutputs.Count > 0);\n ```\n \n+#### Function call executed automatically\n+\n+In addition to the manual function calls, SDK supports automatic function calling. Here is the example:\n+\n+Here we use other functions for demonstration:\n+```C# Snippet:StreamingWithAutoFunctionCall_DefineFunctions\n+private class Address\n+{\n+ public string Street { get; set; }\n+ public string City { get; set; }\n+}\n+\n+private int GetHumidityByAddress(Address address)\n+{\n+ return (address.City == \"Seattle\") ? 60 : 80;\n+}\n+\n+private string[] GetWeatherByAddresses(Dictionary<string, string>[] addresses, string unit = \"F\")\n+{\n+ string[] temps = new string[addresses.Length];\n+ for (int i = 0; i < addresses.Length; i++)\n+ {\n+ if (addresses[i].TryGetValue(\"city\", out string city))\n+ {\n+ temps[i] = string.Format(\"{0}{1}\", (city == \"Seattle\") ? \"20\" : \"50\", unit);\n+ }\n+ else\n+ {\n+ throw new ArgumentException(\"Each address must contain 'street' and 'city' keys.\");\n+ }\n+ }\n+ return temps;\n+}\n+```\n+Now we define the function definitions:\n+```C# Snippet:StreamingWithAutoFunctionCall_DefineFunctionTools\n+private FunctionToolDefinition geHhumidityByAddressTool = new(\n+ name: \"GetHumidityByAddress\",\n+ description: \"Get humidity by street and city\",\n+ parameters: BinaryData.FromObjectAsJson(\n+ new\n+ {\n+ Type = \"object\",\n+ Properties = new\n+ {\n+ Address = new\n+ {\n+ Type = \"object\",\n+ Properties = new\n+ {\n+ Street = new\n+ {\n+ Type = \"string\",\n+ Description = \"Street\"\n+ },\n+ City = new\n+ {\n+ Type = \"string\",\n+ Description = \"city\"\n+ },\n+ },\n+ Required = new[] { \"street\", \"city\" }\n+ }\n+ },\n+ Required = new[] { \"address\" }\n+ },\n+ new JsonSerializerOptions() { PropertyNamingPolicy = JsonNamingPolicy.CamelCase }));\n+\n+private FunctionToolDefinition getWeatherByAddressesTool = new(\n+ name: \"GetWeatherByAddresses\",\n+ description: \"Get weather by street and city\",\n+ parameters: BinaryData.FromObjectAsJson(\n+ new\n+ {\n+ Type = \"object\",\n+ Properties = new\n+ {\n+ Addresses = new\n+ {\n+ Type = \"array\",\n+ Description = \"A list of addresses\",\n+ Items = new\n+ {\n+ Type = \"object\",\n+ Properties = new\n+ {\n+ Street = new\n+ {\n+ Type = \"string\",\n+ Description = \"Street\"\n+ },\n+ City = new\n+ {\n+ Type = \"string\",\n+ description = \"city\"\n+ },\n+ },\n+ Required = new[] { \"street\", \"city\" }\n+ }\n+ },\n+ Unit = new\n+ {\n+ Type = \"string\",\n+ Enum = new[] { \"c\", \"f\" },\n+ },\n+ },\n+ Required = new[] { \"addresses\" }\n+ },\n+ new JsonSerializerOptions() { PropertyNamingPolicy = JsonNamingPolicy.CamelCase }));\n+```\n+Use `EnableAutoFunctionCall` to enable the auto function call:\n+```C# Snippet:StreamingWithAutoFunctionCall_EnableAutoFunctionCalls\n+List<ToolOutput> toolOutputs = new();\n+Dictionary<string, Delegate> delegates = new();\n+delegates.Add(nameof(GetWeatherByAddresses), GetWeatherByAddresses);\n+delegates.Add(nameof(GetHumidityByAddress), GetHumidityByAddress);\n+AIProjectClientOptions options = new();\n+options.EnableAutoFunctionCalls(delegates);",
"comment_created_at": "2025-04-28T06:25:29+00:00",
"comment_author": "howieleung",
"comment_body": "No worry! beside create_run, Python SDK has a function called create_and_process_run. For non-streaming, users either call create_run followed by writing their own while-loop and call function tool manually. Or they call create_and_process_run that call create_run and embed the while-loop with auto function calls. Currently this SDK doesn't have something similar to create_and_process_run. I have discussed with Jarno this release we will do auto function call for streaming only. We might consider to create createAndRunProcess with auto function call for non-streaming.",
"pr_file_module": null
}
]
},
{
"discussion_id": "2164226771",
"pr_number": 50725,
"pr_file": "sdk/identity/Azure.Identity/CHANGELOG.md",
"created_at": "2025-06-24T14:44:09+00:00",
"commented_code": "### Bugs Fixed\n\n- `ManagedIdentityCredential` now retries 410 status responses for at least 70 seconds total duration as required by [Azure IMDS documentation](https://learn.microsoft.com/en-us/azure/virtual-machines/instance-metadata-service?tabs=windows#errors-and-debugging). Previously, 410 responses were retried with the same short exponential backoff as other status codes, resulting in insufficient retry duration ([#50724](https://github.com/Azure/azure-sdk-for-net/issues/50724)).",
"repo_full_name": "Azure/azure-sdk-for-net",
"discussion_comments": [
{
"comment_id": "2164226771",
"repo_full_name": "Azure/azure-sdk-for-net",
"pr_number": 50725,
"pr_file": "sdk/identity/Azure.Identity/CHANGELOG.md",
"discussion_id": "2164226771",
"commented_code": "@@ -8,6 +8,7 @@\n \n ### Bugs Fixed\n \n+- `ManagedIdentityCredential` now retries 410 status responses for at least 70 seconds total duration as required by [Azure IMDS documentation](https://learn.microsoft.com/en-us/azure/virtual-machines/instance-metadata-service?tabs=windows#errors-and-debugging). Previously, 410 responses were retried with the same short exponential backoff as other status codes, resulting in insufficient retry duration ([#50724](https://github.com/Azure/azure-sdk-for-net/issues/50724)).",
"comment_created_at": "2025-06-24T14:44:09+00:00",
"comment_author": "scottaddie",
"comment_body": "```suggestion\r\n- `ManagedIdentityCredential` now retries 410 status responses for at least 70 seconds total duration as required by [Azure IMDS documentation](https://learn.microsoft.com/azure/virtual-machines/instance-metadata-service?tabs=windows#errors-and-debugging). Previously, 410 responses were retried with the same short exponential backoff as other status codes, resulting in insufficient retry duration ([#50724](https://github.com/Azure/azure-sdk-for-net/issues/50724)).\r\n```",
"pr_file_module": null
},
{
"comment_id": "2164232457",
"repo_full_name": "Azure/azure-sdk-for-net",
"pr_number": 50725,
"pr_file": "sdk/identity/Azure.Identity/CHANGELOG.md",
"discussion_id": "2164226771",
"commented_code": "@@ -8,6 +8,7 @@\n \n ### Bugs Fixed\n \n+- `ManagedIdentityCredential` now retries 410 status responses for at least 70 seconds total duration as required by [Azure IMDS documentation](https://learn.microsoft.com/en-us/azure/virtual-machines/instance-metadata-service?tabs=windows#errors-and-debugging). Previously, 410 responses were retried with the same short exponential backoff as other status codes, resulting in insufficient retry duration ([#50724](https://github.com/Azure/azure-sdk-for-net/issues/50724)).",
"comment_created_at": "2025-06-24T14:46:18+00:00",
"comment_author": "Copilot",
"comment_body": "Updated the CHANGELOG URL format as suggested. Commit 6789abc.",
"pr_file_module": null
}
]
},
{
"discussion_id": "2124977732",
"pr_number": 50394,
"pr_file": "sdk/servicebus/Azure.Messaging.ServiceBus/CHANGELOG.md",
"created_at": "2025-06-03T21:40:43+00:00",
"commented_code": "### Other Changes\n\n- Updated retry policy behavior when the service is throttling and the `TryTimeout` is shorter than the standard throttling time of 30 seconds. Previously, the operation was immediately canceled with a server busy exception. With these changes, the operation will begin consuming retry attempts while throttling until either the server busy state is cleared or all configured retry attempts are exhausted. ([#50121](https://github.com/Azure/azure-sdk-for-net/issues/50121))",
"repo_full_name": "Azure/azure-sdk-for-net",
"discussion_comments": [
{
"comment_id": "2124977732",
"repo_full_name": "Azure/azure-sdk-for-net",
"pr_number": 50394,
"pr_file": "sdk/servicebus/Azure.Messaging.ServiceBus/CHANGELOG.md",
"discussion_id": "2124977732",
"commented_code": "@@ -12,6 +12,7 @@\n \n ### Other Changes\n \n+- Updated retry policy behavior when the service is throttling and the `TryTimeout` is shorter than the standard throttling time of 30 seconds. Previously, the operation was immediately canceled with a server busy exception. With these changes, the operation will begin consuming retry attempts while throttling until either the server busy state is cleared or all configured retry attempts are exhausted. ([#50121](https://github.com/Azure/azure-sdk-for-net/issues/50121))",
"comment_created_at": "2025-06-03T21:40:43+00:00",
"comment_author": "jsquire",
"comment_body": "```suggestion\r\n- Updated retry policy behavior when the service is throttling and the `TryTimeout` is shorter than the standard throttling time of 30 seconds. Previously, the operation was immediately canceled with a server busy exception. With these changes, the operation will begin consuming retry attempts while throttling until either the server busy state is cleared or all configured retry attempts are exhausted. ([#50121](https://github.com/Azure/azure-sdk-for-net/issues/50121))\r\n\r\n```",
"pr_file_module": null
}
]
}
]