diff --git a/sdk/ai/azure-ai-projects/azure/ai/projects/telemetry/_responses_instrumentor.py b/sdk/ai/azure-ai-projects/azure/ai/projects/telemetry/_responses_instrumentor.py index fdb3cc456214..5fb17ab740cd 100644 --- a/sdk/ai/azure-ai-projects/azure/ai/projects/telemetry/_responses_instrumentor.py +++ b/sdk/ai/azure-ai-projects/azure/ai/projects/telemetry/_responses_instrumentor.py @@ -557,6 +557,10 @@ def _append_to_message_attribute( new_messages: List[Dict[str, Any]], ) -> None: """Helper to append messages to an existing attribute, combining with previous messages.""" + + if not span.span_instance.is_recording(): + return + # Get existing attribute value existing_value = span.span_instance.attributes.get(attribute_name) if span.span_instance.attributes else None