diff --git a/templates/components/engines/python/agent/tools/openapi_action.py b/templates/components/engines/python/agent/tools/openapi_action.py
index 1e1a8e3041bbd0f74f0f84be0a4ef988d3353c95..e9f1933224a713f9dea3ca3461c8894d02ea63a5 100644
--- a/templates/components/engines/python/agent/tools/openapi_action.py
+++ b/templates/components/engines/python/agent/tools/openapi_action.py
@@ -50,7 +50,7 @@ class OpenAPIActionToolSpec(OpenAPIToolSpec, RequestsToolSpec):
                 )
             spec = yaml.safe_load(response.text)
         elif uri.startswith("file"):
-            filepath = uri[7:]  # Remove the 'file://' scheme
+            filepath = urlparse(uri).path
             with open(filepath, "r") as file:
                 spec = yaml.safe_load(file)
         else: