fix(tools): browser handlers TypeError on unexpected LLM params + fuzzy_match docstring#1735
Merged
fix(tools): browser handlers TypeError on unexpected LLM params + fuzzy_match docstring#1735
Conversation
1. browser_tool.py: Replace **args spread on browser_click, browser_type, and browser_scroll handlers with explicit parameter extraction. The **args pattern passed all dict keys as keyword arguments, causing TypeError if the LLM sent unexpected parameters. Now extracts only the expected params (ref, text, direction) with safe defaults. 2. fuzzy_match.py: Update module docstring to match actual strategy order in code. Block anchor was listed as #3 but is actually #7. Multi-occurrence is not a separate strategy but a flag. Updated count from 9 to 8.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
1. Browser tool handler safety (browser_tool.py)
browser_click,browser_type, andbrowser_scrollhandlers used**argsspread which passed ALL dict keys as keyword arguments. If the LLM sent unexpected parameters (e.g.{"ref": "@e5", "timeout": 10}), the spread would cause aTypeError: unexpected keyword argument.Fix: Extract only the expected parameters with
.get()and safe defaults, matching the pattern used by all other browser tool handlers (navigate, snapshot, vision, etc.).2. Fuzzy match docstring (fuzzy_match.py)
The module docstring listed block_anchor as strategy #3, but it's actually #7 in the code. Multi-occurrence was listed as strategy #9 but is just the
replace_allflag. Updated to match actual code order.Test plan
python -m pytest tests/tools/test_fuzzy_match.py -n0 -q→ 9 passed ✔