fix: register menu_tool and upload_tool, and return structured results from select_option - #22
Open
FritzHeider wants to merge 5 commits into
Open
fix: register menu_tool and upload_tool, and return structured results from select_option#22FritzHeider wants to merge 5 commits into
FritzHeider wants to merge 5 commits into
Conversation
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.
Problem
menu_toolandupload_toolare defined insrc/agent/tools/service.pyand imported insrc/agent/tools/__init__.py, but neither is listed inBUILTIN_TOOLS. The agent is never offered them, so they are effectively dead code — there is currently no way for the agent to select an option in a<select>dropdown.Registering them surfaced a second problem:
select_optionreturned a baretrue/falsethat nothing consumed, so every failure looked identical to success.menu_toolwould report"Selected X"even when the option didn't exist, when the element wasn't a<select>, or when the XPath resolved to nothing — leaving the agent to continue on a page that never changed.Changes
menu_toolandupload_toolinBUILTIN_TOOLS.Browser.select_option/Page.select_option_atnow return a structured dict —{selected, notFound, available}on success, or{error: 'not_found'}/{error: 'not_select', tag}— instead of a silent boolean.availableis capped at 30 options.menu_toolraises on each failure shape, and includes the dropdown's actual options when a label doesn't match, so the agent can retry with a real value rather than guessing. This matters in practice for near-miss text — a typographic apostrophe vs. an ASCII one, for instance.selectedIndexfor single-select (the previous loop set.selectedon options, which misbehaves on single-select) and firesinputbeforechange, which several frameworks need to register the update.json.dumpsrather than string-concatenated, so labels containing quotes no longer break the injected script.Tests
Adds
tests/test_menu_tool.py— 9 tests covering registration, the structured result shapes, eachmenu_toolerror path, and theselect_option_atparity. They stubexecute_script, so no browser is required.Merges cleanly onto current
main.