Skip to content

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

fix: re-raise control-flow exceptions (InterruptedError, CancelledError)

Tonyfd7eeeb15f5b
diff --git a/browser_use/agent/service.py b/browser_use/agent/service.py
index 09ada94dc..e07276d96 100644
--- a/browser_use/agent/service.py
+++ b/browser_use/agent/service.py
@@ -2808,6 +2808,9 @@ class Agent(Generic[Context, AgentStructuredOutput]):
break
except Exception as e:
+ # Re-raise control-flow exceptions to preserve stop/pause/interrupt behavior
+ if isinstance(e, (InterruptedError, asyncio.CancelledError)):
+ raise
# Handle any exceptions during action execution
self.logger.error(f'❌ Executing action {i + 1} failed -> {type(e).__name__}: {e}')
await self._demo_mode_log(