Operator bpy.ops.object.modifier_add.poll() failed, context is incorrect. How to apply modifiers to an .obj file?
Ditch the operators.
Operators return a set indicating the success {FINISHED} or failure {CANCELLED} of an operation.
There a chance that import has imported nothing (and after delete all active object is None) or that the current active object is not a mesh (a &quot;subsurfable&quot; type)
In which case there is no context object and poll will fail.
However test script below ditches all but the import obj operator.
Most importers (check first)  select newly created objects ie they are members of context.selected_objects after the operator has run. . Have added note about not adding code for deleting all objects to question code, really not that important either way but could be a bit sticky for  a new user tryings it out before realizing.  Thank goodness for undo... anyway I digress
How to add modifiers using python script and set parameters?
Using python to set object shading to &#39;smooth&#39;
Here is test code, adds a subsurf modifier and smooth shading to all newly imported mesh objects.
import bpy

# FWIW Dislike this in question scripts
# 
'''
bpy.ops.object.select_all(action = &quot;SELECT&quot;)
bpy.ops.object.delete(use_global = False)
'''
# will deselect instead.

bpy.ops.object.select_all(action=&quot;DESELECT&quot;)
#Model loading
full_path_to_file = &quot;foo.obj&quot;


def surface_refinement(obs, render_levels, view_levels):
    for ob in obs:
        if not ob.type == 'MESH':
            continue
        ssm = ob.modifiers.new(&quot;SubbyO&quot;, type='SUBSURF')
        ssm.render_levels = render_levels
        ssm.levels = view_levels  
        me = ob.data
        me.polygons.foreach_set(&quot;use_smooth&quot;, (True,) * len(me.polygons))

# test call
render = 2 
view = 1 
bpy.ops.import_scene.obj(filepath=full_path_to_file) 

surface_refinement(bpy.context.selected_objects, render, view)