mirror of
https://github.com/browser-use/browser-use
synced 2026-05-06 17:52:15 +02:00
Previously, done() calls inside if/else/elif blocks would only show a warning
but still execute, potentially causing tasks to never complete if the condition
wasn't met. This changes the behavior to raise a RuntimeError, forcing the LLM
to restructure code properly.
The proper pattern is:
```python
# Validate and set result variables
if condition:
result = "success"
else:
result = "failure"
# Then call done() unconditionally
await done(result, success=True)
```
Changes:
- Upgraded warning to RuntimeError in namespace.py
- Added comprehensive test suite with 5 test cases
- Tests cover if/else/elif blocks and verify standalone done() still works
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude <noreply@anthropic.com>
22 KiB
22 KiB