You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: src/backend/common/telemetry/patch_instrumentor.py
+19-2Lines changed: 19 additions & 2 deletions
Original file line number
Diff line number
Diff line change
@@ -1,4 +1,15 @@
1
-
"""\nPatch for Azure AI telemetry instrumentors.\n\nFixes GitHub issue: https://github.com/microsoft/semantic-kernel/issues/13715\n\nThe bug: agent_api_response_to_str() in both azure.ai.agents and azure.ai.projects\nraises ValueError when response_format is a dict (e.g. from Semantic Kernel's AzureAIAgent).\nIt only handles str and None types.\n\nThe fix: Monkey-patch that method to convert dict/other types to JSON string instead of raising.\nMust be called BEFORE configure_azure_monitor() triggers any instrumentation.\n"""
The bug: agent_api_response_to_str() in both azure.ai.agents and azure.ai.projects
7
+
raises ValueError when response_format is a dict (e.g. from Semantic Kernel's AzureAIAgent).
8
+
It only handles str and None types.
9
+
10
+
The fix: Monkey-patch that method to convert dict/other types to JSON string instead of raising.
11
+
Must be called BEFORE configure_azure_monitor() triggers any instrumentation.
12
+
"""
2
13
3
14
importjson
4
15
importlogging
@@ -23,7 +34,13 @@ def patch_instrumentors():
23
34
"""
24
35
Patch Azure AI telemetry instrumentors to handle dict response_format.
25
36
26
-
This fixes the ValueError: \"Unknown response format <class 'dict'>\" error\n that occurs when Semantic Kernel's AzureAIAgent passes a dict as response_format\n and Azure Monitor telemetry instrumentor tries to serialize it.\n\n Patches both azure.ai.agents and azure.ai.projects packages.\n Must be called BEFORE configure_azure_monitor().\n """
37
+
This fixes the ValueError: "Unknown response format <class 'dict'>" error
38
+
that occurs when Semantic Kernel's AzureAIAgent passes a dict as response_format
39
+
and Azure Monitor telemetry instrumentor tries to serialize it.
40
+
41
+
Patches both azure.ai.agents and azure.ai.projects packages.
42
+
Must be called BEFORE configure_azure_monitor().
43
+
"""
27
44
# Patch azure.ai.agents (primary package with the bug)
0 commit comments