From ed965ac6c20bee3375c68ee0b8b42e87193dbee2 Mon Sep 17 00:00:00 2001 From: mertunsall Date: Fri, 1 Aug 2025 20:18:57 +0100 Subject: [PATCH] increment step at the end --- browser_use/agent/service.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/browser_use/agent/service.py b/browser_use/agent/service.py index ba1361921..5ee89c9fb 100644 --- a/browser_use/agent/service.py +++ b/browser_use/agent/service.py @@ -760,9 +760,6 @@ class Agent(Generic[Context, AgentStructuredOutput]): # Check again for paused/stopped state after getting model output await self._raise_if_stopped_or_paused() - # Increment step counter at the end of each step - self.state.n_steps += 1 - # Handle callbacks and conversation saving await self._handle_post_llm_processing(browser_state_summary, input_messages) @@ -879,6 +876,9 @@ class Agent(Generic[Context, AgentStructuredOutput]): ) self.eventbus.dispatch(step_event) + # Increment step counter after step is fully completed + self.state.n_steps += 1 + async def _handle_final_step(self, step_info: AgentStepInfo | None = None) -> None: """Handle special processing for the last step""" if step_info and step_info.is_last_step():