Chain multiple tasks together with the same agent and browser session.
import asyncio from dotenv import load_dotenv load_dotenv() from browser_use import Agent, BrowserProfile profile = BrowserProfile(keep_alive=True) async def main(): agent = Agent(task="Go to reddit.com", browser_profile=profile) await agent.run(max_steps=1) while True: user_response = input('\n👤 New task or "q" to quit: ') if user_response.lower() == 'q': break agent.add_new_task(f'New task: {user_response}') await agent.run() if __name__ == '__main__': asyncio.run(main())
BrowserProfile(keep_alive=True)
agent.add_new_task()
Was this page helpful?