Skip to content

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

bugfix

mertunsall87e3529e8598
diff --git a/browser_use/controller/service.py b/browser_use/controller/service.py
index 1d20df52f..69afeef78 100644
--- a/browser_use/controller/service.py
+++ b/browser_use/controller/service.py
@@ -661,12 +661,15 @@ Explain the content of the page and that the requested information is not availa
if len(result) > MAX_MEMORY_SIZE:
lines = result.splitlines()
display = ''
+ lines_count = 0
for line in lines:
if len(display) + len(line) < MAX_MEMORY_SIZE:
display += line + '\n'
+ lines_count += 1
else:
break
- memory = f'{display}{len(lines) - len(display)} more lines...'
+ remaining_lines = len(lines) - lines_count
+ memory = f'{display}{remaining_lines} more lines...' if remaining_lines > 0 else display
else:
memory = result
logger.info(f'💾 {memory}')