Skip to content

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

fix(agent): Add max steps error to agent history #439

shyanilMishra9e142699690a
diff --git a/browser_use/agent/service.py b/browser_use/agent/service.py
index f4cd25fd5..7e364bcf3 100644
--- a/browser_use/agent/service.py
+++ b/browser_use/agent/service.py
@@ -566,7 +566,9 @@ class Agent(Generic[Context]):
await self.register_done_callback(self.state.history)
break
else:
- logger.info('❌ Failed to complete task in maximum steps')
+ error_message = 'Failed to complete task in maximum steps'
+ self.history.add_error(error_message)
+ logger.info(f'❌ {error_message}')
return self.state.history
finally: