Skip to content

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

max wait between execution

mertunsalla0996ba39ec8
diff --git a/browser_use/agent/service.py b/browser_use/agent/service.py
index f3a0be233..b399a9455 100644
--- a/browser_use/agent/service.py
+++ b/browser_use/agent/service.py
@@ -2701,6 +2701,7 @@ class Agent(Generic[Context, AgentStructuredOutput]):
max_retries: int = 3,
skip_failures: bool = True,
delay_between_actions: float = 2.0,
+ max_step_interval: float = 5.0,
summary_llm: BaseChatModel | None = None,
ai_step_llm: BaseChatModel | None = None,
) -> list[ActionResult]:
@@ -2711,7 +2712,8 @@ class Agent(Generic[Context, AgentStructuredOutput]):
history: The history to replay
max_retries: Maximum number of retries per action
skip_failures: Whether to skip failed actions or stop execution
- delay_between_actions: Delay between actions in seconds
+ delay_between_actions: Delay between actions in seconds (used when no saved interval)
+ max_step_interval: Maximum delay from saved step_interval (caps LLM time from original run)
summary_llm: Optional LLM to use for generating the final summary. If not provided, uses the agent's LLM
ai_step_llm: Optional LLM to use for AI steps (extract actions). If not provided, uses the agent's LLM
@@ -2733,13 +2735,17 @@ class Agent(Generic[Context, AgentStructuredOutput]):
# Determine step delay
if history_item.metadata and history_item.metadata.step_interval is not None:
- step_delay = history_item.metadata.step_interval
+ # Cap the saved interval to max_step_interval (saved interval includes LLM time)
+ step_delay = min(history_item.metadata.step_interval, max_step_interval)
# Format delay nicely - show ms for values < 1s, otherwise show seconds
if step_delay < 1.0:
delay_str = f'{step_delay * 1000:.0f}ms'
else:
delay_str = f'{step_delay:.1f}s'
- delay_source = f'using saved step_interval={delay_str}'
+ if history_item.metadata.step_interval > max_step_interval:
+ delay_source = f'capped to {delay_str} (saved was {history_item.metadata.step_interval:.1f}s)'
+ else:
+ delay_source = f'using saved step_interval={delay_str}'
else:
step_delay = delay_between_actions
if step_delay < 1.0:
@@ -2942,7 +2948,13 @@ class Agent(Generic[Context, AgentStructuredOutput]):
Args:
history_file: Path to the history file
variables: Optional dict mapping variable names to new values (e.g. {'email': '[email protected]'})
- **kwargs: Additional arguments passed to rerun_history
+ **kwargs: Additional arguments passed to rerun_history:
+ - max_retries: Maximum retries per action (default: 3)
+ - skip_failures: Continue on failure (default: True)
+ - delay_between_actions: Delay when no saved interval (default: 2.0s)
+ - max_step_interval: Cap on saved step_interval (default: 5.0s)
+ - summary_llm: Custom LLM for final summary
+ - ai_step_llm: Custom LLM for extract re-evaluation
"""
if not history_file:
history_file = 'AgentHistory.json'