Skip to content

Conversation

waleedalzarooni
Copy link
Collaborator

Description

This is a preliminary implementation of a reflection mechanism to be included in the hybrid_browser-toolkit

Checklist

Go over all the following points, and put an x in all the boxes that apply.

  • [ X] I have read the CONTRIBUTION guide (required)
  • I have linked this PR to an issue using the Development section on the right sidebar or by adding Fixes #issue-number in the PR description (required)
  • [ X] I have checked if any dependencies need to be added or updated in pyproject.toml and uv lock
  • [ X] I have updated the tests accordingly (required for a bug fix or a new feature)
  • [X ] I have updated the documentation if needed:
  • [X ] I have added examples if this is a new feature

If you are unsure about any of these, don't hesitate to ask. We are here to help!

Copy link
Contributor

coderabbitai bot commented Sep 15, 2025

Important

Review skipped

Auto reviews are disabled on this repository.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

✨ Finishing touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch browser-reflection-wrapper

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@waleedalzarooni
Copy link
Collaborator Author

@nitpicker55555, here's my initial implementation. Let me know what you think of my approach, I also included an example file to show how it works, will deal with further refinement (exception handling, etc) in the next commit!

@nitpicker55555
Copy link
Collaborator

Thanks for your contribution! Have you test it in wordle game or https://github.com/MinorJerry/WebVoyager/blob/main/data/WebVoyager_data.jsonl top 10 questions?

@waleedalzarooni
Copy link
Collaborator Author

Thanks for your contribution! Have you test it in wordle game or https://github.com/MinorJerry/WebVoyager/blob/main/data/WebVoyager_data.jsonl top 10 questions?

will do!

@nitpicker55555
Copy link
Collaborator

I think you only want to push these commits?

  1. aa5652f - metadata additions
  2. 48147d3 - nonagent planning model / tag for loop prevention
  3. 5c7b3f2 - preliminary reflection implementation
    please clean other commits

@waleedalzarooni waleedalzarooni force-pushed the browser-reflection-wrapper branch from aa5652f to 0ba17cb Compare September 22, 2025 10:05
@waleedalzarooni
Copy link
Collaborator Author

I think you only want to push these commits?

  1. aa5652f - metadata additions
  2. 48147d3 - nonagent planning model / tag for loop prevention
  3. 5c7b3f2 - preliminary reflection implementation
    please clean other commits

All done!

# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
Copy link
Collaborator

Choose a reason for hiding this comment

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

Is this empty file?

Copy link
Collaborator

Choose a reason for hiding this comment

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

Thanks for working on the reflection wrapper feature. I've reviewed the implementation and have some suggestions.

The current approach adds significant complexity by intercepting every browser action and asking an LLM whether to proceed or change the action. This doubles the API calls and introduces unpredictable behavior. Additionally,
clearing the agent's conversation history before each action (self.agent.reset()) removes valuable context that the agent needs to maintain state.

I'd suggest a simpler approach: instead of intercepting execution, we could add optional parameters like thinking and next_goal to the browser action methods. Here's how it could work:

 def add_reasoning_params(func):
      """Add optional reasoning parameters without changing execution flow"""
      @wraps(func)
      async def wrapper(self, *args, thinking: Optional[str] = None, 
                       next_goal: Optional[str] = None, **kwargs):
          # Log reasoning if provided
          if thinking:
              logger.info(f"[{func.__name__}] Thinking: {thinking}")
          if next_goal:
              logger.info(f"[{func.__name__}] Next goal: {next_goal}")

          # Execute original function without interference
          return await func(self, *args, **kwargs)

      # Update docstring to include new parameters
      if func.__doc__:
          additional_docs = """
          Additional Parameters:
              thinking (Optional[str]): Your reasoning for this action.
              next_goal (Optional[str]): What you plan to do after this action.
          """
          wrapper.__doc__ = func.__doc__.rstrip() + "\n" + additional_docs

      return wrapper

This would allow agents to provide their reasoning when calling the toolkit:

  await toolkit.browser_click(
      ref="submit_button",
      thinking="Form is complete, submitting to server",
      next_goal="Wait for confirmation page to load"
  )

@waleedalzarooni waleedalzarooni force-pushed the browser-reflection-wrapper branch from 0ba17cb to f8af6ab Compare September 26, 2025 12:47
@waleedalzarooni
Copy link
Collaborator Author

@nitpicker55555 new implementation uploaded run python WebVoyager_wrapper_ts.py --num-tasks 10 results should be promising!

@waleedalzarooni waleedalzarooni marked this pull request as ready for review October 1, 2025 14:44
@waleedalzarooni
Copy link
Collaborator Author

@nitpicker55555 Latest experiment setup, results were 4 incorrect out of 50 for reflection mechanism, 5 incorrect for non-reflective

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.

2 participants