From ed8a975b5b06e70797c4846357bf7cf8e9619b75 Mon Sep 17 00:00:00 2001 From: Tao Chen Date: Thu, 4 Jun 2026 15:34:36 -0700 Subject: [PATCH] fix: enable automatic exception recording on MCP spans Remove record_exception=False and set_status_on_exception=False from create_mcp_client_span. Let OTel handle exception recording and status setting automatically. The manual set_mcp_span_error calls for tools/call still correctly set error.type (which OTel's automatic handling doesn't touch), so tool_error is preserved. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> --- python/packages/core/agent_framework/observability.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/python/packages/core/agent_framework/observability.py b/python/packages/core/agent_framework/observability.py index b8c485abb4..1487799290 100644 --- a/python/packages/core/agent_framework/observability.py +++ b/python/packages/core/agent_framework/observability.py @@ -2053,8 +2053,8 @@ def create_mcp_client_span( with trace.use_span( span=span, end_on_exit=True, - record_exception=False, - set_status_on_exception=False, + record_exception=True, + set_status_on_exception=True, ) as current_span: yield current_span