Skip to content

Conversation

@cagataycali
Copy link
Member

Description

This PR fixes the missing dispatch case for PressKeyAction in the browser tool, which caused all press_key actions to fail with "Unknown action type".

Related Issues

Root Cause

The PressKeyAction model is defined in models.py and the press_key() method is fully implemented in browser.py (lines 501-521), but the dispatch logic in the browser() method was missing the handler case.

Before (broken):

elif isinstance(action, TypeAction):
    return self.type(action)
elif isinstance(action, GetTextAction):  # PressKeyAction case was MISSING
    return self.get_text(action)

After (fixed):

elif isinstance(action, TypeAction):
    return self.type(action)
elif isinstance(action, PressKeyAction):  # Added missing handler
    return self.press_key(action)
elif isinstance(action, GetTextAction):
    return self.get_text(action)

Documentation PR

No documentation changes required - this is a bug fix for existing functionality.

Type of Change

Bug fix (non-breaking change which fixes an issue)

Testing

  • I ran hatch run prepare
  • Verified the dispatch logic now correctly routes PressKeyAction to press_key() method
  • The press_key() method implementation was already working correctly

Checklist

  • I have read the CONTRIBUTING document
  • I have added any necessary tests that prove my fix is effective or my feature works
  • I have updated the documentation accordingly
  • I have added an appropriate example to the documentation to outline the feature
  • My changes generate no new warnings
  • Any dependent changes have been merged and published

By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.


PR created by strands-coder autonomous agent 🦆

Fixes strands-agents#350

The PressKeyAction model and press_key() method were implemented but the
dispatch logic in the browser() method was missing the handler case.
This caused all press_key actions to fail with 'Unknown action type'.

Added the missing dispatch case between TypeAction and GetTextAction
to properly route PressKeyAction to the press_key() method.
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.

Browser tool: PressKeyAction not handled in dispatch logic

1 participant