Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -109,13 +109,28 @@ async def forward_incremental(
snapshot: BrowserSnapshot,
previous_action_list: list[InteractionAction],
) -> PossibleActionSpace:
errors: list[str] = []
_last_error: Exception | None = None

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🛠️ Refactor suggestion | 🟠 Major | ⚡ Quick win

_last_error is dead code — remove it entirely.

The variable is assigned on line 113 and updated on line 118, but never read. Unlike forward(), forward_incremental does not re-raise on exhaustion, so there is no consumer for this value. The underscore prefix suppresses the lint warning (F841) but the assignment itself still adds noise.

♻️ Proposed fix
         errors: list[str] = []
-        _last_error: Exception | None = None
         for _ in range(self.max_tries):
             try:
                 return await self.pipe.forward_incremental(snapshot, previous_action_list)
             except Exception as e:
-                _last_error = e
                 errors.append(str(e))
                 if self.verbose:

Also applies to: 118-118

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@packages/notte-browser/src/notte_browser/tagging/action/llm_taging/base.py`
at line 113, The variable _last_error is unused dead code; remove its
declaration and any assignments to it (the class-level declaration "_last_error:
Exception | None = None" and the update inside the forward_incremental
implementation) so that only live variables remain; search for "_last_error" and
delete its definition and any lines that set it within the method(s) (e.g.,
forward_incremental) and run linters/tests to confirm no references remain.

for _ in range(self.max_tries):
try:
return await self.pipe.forward_incremental(snapshot, previous_action_list)
except Exception:
pass
except Exception as e:
_last_error = e
errors.append(str(e))
if self.verbose:
logger.debug(
f"forward_incremental: failed to parse action list but retrying. Start of error msg: {str(e)[:200]}..."
)
if self.verbose:
logger.debug("Failed to get action list after max tries => returning previous action list")
logger.debug(
f"Failed to get incremental action list after {self.max_tries} tries with errors: {errors} => returning previous action list"
)
self.tracer.trace(
status="failure",
pipe_name=self.pipe.__class__.__name__,
nb_retries=len(errors),
error_msgs=errors,
)
return PossibleActionSpace(
# TODO: get description from previous action list
description="",
Expand Down
Loading