Skip to content

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

Keep browser open

magmuellerdf2358d1bdeb
diff --git a/examples/try.py b/examples/try.py
index 9e1e1b732..18a250a38 100644
--- a/examples/try.py
+++ b/examples/try.py
@@ -17,6 +17,7 @@ import argparse
import asyncio
from src import Agent
+from src.controller.service import ControllerService
logging.basicConfig(level=logging.INFO)
@@ -49,6 +50,7 @@ llm = get_llm(args.provider)
agent = Agent(
task=args.query,
llm=llm,
+ controller=ControllerService(keep_open=True),
)
diff --git a/src/agent/service.py b/src/agent/service.py
index e8448739f..b198eb167 100644
--- a/src/agent/service.py
+++ b/src/agent/service.py
@@ -83,7 +83,7 @@ class AgentService:
if result.done:
logger.info('\n✅ Task completed successfully')
- logger.info(f'Extracted content: {result.extracted_content}')
+ logger.info(f'Extracted content: \n{result.extracted_content}')
return action.done, self.action_history
logger.info('\n' + '=' * 50)
@@ -110,7 +110,7 @@ class AgentService:
if result.extracted_content:
self.messages.append(
- HumanMessage(content=f'Extracted content: {result.extracted_content}')
+ HumanMessage(content=f'Extracted content:\n {result.extracted_content}')
)
# Convert action to history and update click/input fields if present