diff --git a/python/packages/core/agent_framework/_mcp.py b/python/packages/core/agent_framework/_mcp.py index 9eba9cfc6a..272b291705 100644 --- a/python/packages/core/agent_framework/_mcp.py +++ b/python/packages/core/agent_framework/_mcp.py @@ -950,7 +950,7 @@ class MCPTool: with get_mcp_call_span(span_attributes) as span: # Try the operation, reconnecting once if the connection is closed - _span_error_set = False + span_error_set = False for attempt in range(2): try: # Capture the JSON-RPC request ID before the call is made. @@ -976,11 +976,11 @@ class MCPTool: error_msg = text or str(parsed) span.set_attribute(OtelAttr.ERROR_TYPE, "ToolError") span.set_status(trace.StatusCode.ERROR, error_msg) - _span_error_set = True + span_error_set = True raise ToolExecutionException(error_msg) return parser(result) except ToolExecutionException as ex: - if not _span_error_set: + if not span_error_set: span.set_attribute(OtelAttr.ERROR_TYPE, type(ex).__name__) span.set_status(trace.StatusCode.ERROR, str(ex)) raise