Skip to content

[BUG] browser tool cannot initialize new session after close action #286

Description

@daviddmc

Checks

  • I have updated to the lastest minor and patch version of Strands
  • I have checked the documentation and this is not expected behavior
  • I have searched ./issues and there are no duplicates of my issue

Strands Version

1.10.0

Tools Package Version

0.2.9

Tools used

AgentCoreBrowser

Python Version

3.12

Operating System

macOS

Installation Method

pip

Steps to Reproduce

browser = AgentCoreBrowser()

print(browser.browser({'action':{'type':'init_session', 'session_name':'session-name-001', 'description': 'description'}}))
print(browser.browser({'action':{'type':'close', 'session_name':'session-name-001'}}))
print(browser.browser({'action':{'type':'init_session', 'session_name':'session-name-002', 'description': 'description'}}))
print(browser.browser({'action':{'type':'close', 'session_name':'session-name-002'}}))

output

{'status': 'success', 'content': [{'json': {'sessionName': 'session-name-001', 'description': 'description'}}]}
{'status': 'success', 'content': [{'text': 'Browser closed'}]}
{'status': 'error', 'content': [{'text': 'Failed to initialize session: Playwright not initialized'}]}
{'status': 'success', 'content': [{'text': 'Browser closed'}]}

Expected Behavior

Should be able to create new session after close

Actual Behavior

Failed to initialize session: Playwright not initialized

Additional Context

No response

Possible Solution

set self._started = False in the close action.

Related Issues

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Fields

    Language

    None yet

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions