Skip to content

Open-source Python library for AI browser agents, plus Browser Use Cloud: stealth browsers and a hosted agent API.

Revert "Fixed exception handling bug in agent step"

Shahar Yair8f3f87053271
diff --git a/browser_use/agent/service.py b/browser_use/agent/service.py
index 646c4ba9b..5cf1750e1 100644
--- a/browser_use/agent/service.py
+++ b/browser_use/agent/service.py
@@ -136,6 +136,9 @@ class Agent:
except Exception as e:
result = self._handle_step_error(e)
self._last_result = result
+
+ model_output = None
+
if result.error:
self.telemetry.capture(
AgentStepErrorTelemetryEvent(
@@ -143,10 +146,8 @@ class Agent:
error=result.error,
)
)
- model_output = None
- finally:
- if state:
- self._make_history_item(model_output, state, result)
+ if state:
+ self._make_history_item(model_output, state, result)
def _handle_step_error(self, error: Exception) -> ActionResult:
"""Handle all types of errors that can occur during a step"""