-
Notifications
You must be signed in to change notification settings - Fork 8.2k
add first step logging to take step #2927
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
Agent Task Evaluation Results: 1/3 (33%)View detailed results
Check the evaluate-tasks job for detailed task execution logs. |
# First step | ||
self._log_first_step_startup() | ||
await self._execute_initial_actions() | ||
|
There was a problem hiding this comment.
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)
There was a problem hiding this 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() |
There was a problem hiding this comment.
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) -> 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) |
There was a problem hiding this comment.
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's feedback about matching the project'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"Input '{params.text}' into element {params.index}."
- logger.info(msg)
+ logger.debug(msg)
# Include input coordinates in metadata if available
</file context>
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() |
There was a problem hiding this comment.
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) -> 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>
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.