Skip to content

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

README: FAQ on replaying a saved run without a model call per step (tested)

Gregor Žuničc607f8b575fc
diff --git a/README.md b/README.md
index 87cf8ec1c..7411b95ba 100644
--- a/README.md
+++ b/README.md
@@ -347,6 +347,34 @@ Choose how much you want to manage:
You can also host the Python library and browsers on your own infrastructure.
</details>
+<details>
+<summary><b>Can I rerun a task without calling the model on every step?</b></summary>
+
+Yes. Save a successful run, then replay its clicks and typing with new values. The snippet below runs inside an async function:
+
+```python
+from browser_use import Agent, ChatBrowserUse
+
+llm = ChatBrowserUse()
+agent = Agent(task='Open https://example.com/billing and request an invoice copy for Ada Lovelace, [email protected]', llm=llm)
+await agent.run()
+agent.save_history('invoice_run.json')
+print(agent.detect_variables()) # names come from the form's fields, e.g. 'name' and 'email'
+
+# Later: the same clicks and typing with new values, no model call per step
+results = await Agent(task='', llm=llm).load_and_rerun(
+ 'invoice_run.json', variables={'name': 'Grace Hopper', 'email': '[email protected]'}, skip_failures=False
+)
+```
+
+- Use the variable names `detect_variables()` prints. An unknown name is skipped with a warning, and the recorded value is typed instead.
+- Extract steps and the closing summary still call the model.
+- If the page changed, the replay raises `RuntimeError` at the first step it cannot match. The steps before it already ran, so check whether the form was sent before you run the agent again.
+- The saved file holds the values the agent typed. Pass `sensitive_data` to the agent to keep secrets out of it.
+
+[Example](examples/features/rerun_history.py)
+</details>
+
<br/>
## Related Repositories