Skip to content

fix(tools): browser handlers TypeError on unexpected LLM params + fuzzy_match docstring#1735

Merged
teknium1 merged 1 commit intomainfrom
fix/tool-handler-safety
Mar 17, 2026
Merged

fix(tools): browser handlers TypeError on unexpected LLM params + fuzzy_match docstring#1735
teknium1 merged 1 commit intomainfrom
fix/tool-handler-safety

Conversation

@teknium1
Copy link
Copy Markdown
Contributor

Summary

1. Browser tool handler safety (browser_tool.py)

browser_click, browser_type, and browser_scroll handlers used **args spread which passed ALL dict keys as keyword arguments. If the LLM sent unexpected parameters (e.g. {"ref": "@e5", "timeout": 10}), the spread would cause a TypeError: 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_all flag. Updated to match actual code order.

Test plan

  • python -m pytest tests/tools/test_fuzzy_match.py -n0 -q → 9 passed ✔
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.
@teknium1 teknium1 merged commit 23a3f01 into main Mar 17, 2026
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

1 participant