Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Conversation

MagMueller
Copy link
Collaborator

@MagMueller MagMueller commented Sep 2, 2025

Auto-generated PR for: add first step logging to take step


Summary by cubic

Log the startup message only when the agent takes its first step, instead of during initialization, to ensure a single, accurate "starting" log. Also reduce log noise by changing input_text logs from info to debug.

@MagMueller MagMueller merged commit 3a86e7a into main Sep 2, 2025
11 checks passed
@MagMueller MagMueller deleted the add-first-step-logging-to-take-step branch September 2, 2025 19:13
Copy link

github-actions bot commented Sep 2, 2025

Agent Task Evaluation Results: 1/3 (33%)

View detailed results
Task Result Reason
amazon_laptop ✅ Pass The agent successfully navigated to amazon.com, searched for 'laptop', and returned the name of the first laptop result along with additional relevant details. The output meets all the criteria specified in the task.
browser_use_pip ❌ Fail The agent failed to find the required pip installation command 'pip install browser-use' and reported being blocked by CAPTCHAs and malformed queries during its search. Therefore, the task was not completed successfully as per the success criteria.
captcha_cloudflare ❌ Fail The agent failed to solve the captcha as indicated by the error message 'Cloudflare Turnstile solved incorrectly, please try again.' Consequently, the success message and the dictionary containing the 'hostname' value did not appear, preventing extraction of the required hostname. Therefore, the task was not completed successfully.

Check the evaluate-tasks job for detailed task execution logs.

# First step
self._log_first_step_startup()
await self._execute_initial_actions()

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Bug: Redundant Logging and Actions on First Step

The startup message logs multiple times, and initial actions can run redundantly. This is because _log_first_step_startup() and _execute_initial_actions() are called in run(), take_step(), and step(), all using len(self.history.history) == 0 to identify the first step. As history is only populated after a step completes, this check is true in multiple places during initial execution.

Additional Locations (1)

Fix in Cursor Fix in Web

Copy link
Contributor

@cubic-dev-ai cubic-dev-ai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

3 issues found across 2 files

React with 👍 or 👎 to teach cubic. You can also tag @cubic-dev-ai to give feedback, ask questions, or re-run the review.

self.step_start_time = time.time()

# Show startup message on first step
self._log_first_step_startup()
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Startup message will be logged twice on the first step: here and again in step(); remove this call or guard to avoid duplicate logs.

Prompt for AI agents
Address the following comment on browser_use/agent/service.py at line 620:

<comment>Startup message will be logged twice on the first step: here and again in step(); remove this call or guard to avoid duplicate logs.</comment>

<file context>
@@ -617,6 +616,9 @@ async def step(self, step_info: AgentStepInfo | None = None) -&gt; None:
 		self.step_start_time = time.time()
 
+		# Show startup message on first step
+		self._log_first_step_startup()
+
 		browser_state_summary = None
</file context>

input_metadata = await event.event_result(raise_if_any=True, raise_if_none=False)
msg = f"Input '{params.text}' into element {params.index}."
logger.info(msg)
logger.debug(msg)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Logging raw input text to debug can expose sensitive data; redact or avoid logging the actual text (e.g., respect has_sensitive_data) to prevent leaks.

(Based on your team's feedback about matching the project's tab-based indentation, the fix suggestion preserves tabs.)

Prompt for AI agents
Address the following comment on browser_use/tools/service.py at line 328:

<comment>Logging raw input text to debug can expose sensitive data; redact or avoid logging the actual text (e.g., respect has_sensitive_data) to prevent leaks.

(Based on your team&#39;s feedback about matching the project&#39;s tab-based indentation, the fix suggestion preserves tabs.)</comment>

<file context>
@@ -325,7 +325,7 @@ async def input_text(params: InputTextAction, browser_session: BrowserSession, h
 				input_metadata = await event.event_result(raise_if_any=True, raise_if_none=False)
 				msg = f&quot;Input &#39;{params.text}&#39; into element {params.index}.&quot;
-				logger.info(msg)
+				logger.debug(msg)
 
 				# Include input coordinates in metadata if available
</file context>
Suggested change
logger.debug(msg)
logger.debug(f"Input '{'[REDACTED]' if has_sensitive_data else params.text}' into element {params.index}.")

if len(self.history.history) == 0:
# First step
self._log_first_step_startup()
await self._execute_initial_actions()
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

First-step handling is duplicated across run(), take_step(), and step() using the history-length check, which can trigger the startup log and initial actions multiple times. Consolidate this into a single entry point or guard with a one-time flag to ensure first-step initialization runs exactly once.

Prompt for AI agents
Address the following comment on browser_use/agent/service.py at line 1135:

<comment>First-step handling is duplicated across run(), take_step(), and step() using the history-length check, which can trigger the startup log and initial actions multiple times. Consolidate this into a single entry point or guard with a one-time flag to ensure first-step initialization runs exactly once.</comment>

<file context>
@@ -1122,6 +1129,11 @@ async def take_step(self, step_info: AgentStepInfo | None = None) -&gt; tuple[bool,
+		if len(self.history.history) == 0:
+			# First step
+			self._log_first_step_startup()
+			await self._execute_initial_actions()
+
 		await self.step(step_info)
</file context>

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant