Checks
Strands Version
1.35.0
Tools Package Version
0.4.0
Tools used
AgentCoreBrowser
Python Version
3.10
Operating System
Amazon Linux 2
Installation Method
pip
Steps to Reproduce
- Create an AgentCoreBrowser instance (this sets the event loop on the current thread)
- Pass browser_instance.browser as a tool to a strands Agent
- Call agent.stream_async() from within an already-running async event loop (e.g. uvicorn, asyncio.run(main()))
- Send a message that causes the model to invoke the browser tool
The tool call fails with RuntimeError: There is no current event loop in thread 'asyncio_0'.
This does not reproduce with the sync agent() call — only stream_async() / invoke_async().
Expected Behavior
tool executes successfully.
Actual Behavior
blocking error.
Additional Context
My understanding of why this is happening:
Browser.init creates an event loop and registers it on the current thread.
_execute_async is defined as a synchronous method.
Therefore calling _execute_async causes strands to dispatch it to another thread based on the logic in _stream.
However, that thread is different from the one where the browser was initiated, meaning its missing the event loop leading to the error.
Possible Solution
Add asyncio.set_event_loop(self._loop) in Browser._execute_async before nest_asyncio.apply(), so the
browser's loop is registered on whatever thread runs the tool.
Related Issues
No response
Checks
Strands Version
1.35.0
Tools Package Version
0.4.0
Tools used
AgentCoreBrowser
Python Version
3.10
Operating System
Amazon Linux 2
Installation Method
pip
Steps to Reproduce
The tool call fails with RuntimeError: There is no current event loop in thread 'asyncio_0'.
This does not reproduce with the sync agent() call — only stream_async() / invoke_async().
Expected Behavior
tool executes successfully.
Actual Behavior
blocking error.
Additional Context
My understanding of why this is happening:
Browser.init creates an event loop and registers it on the current thread.
_execute_async is defined as a synchronous method.
Therefore calling
_execute_asynccauses strands to dispatch it to another thread based on the logic in_stream.However, that thread is different from the one where the browser was initiated, meaning its missing the event loop leading to the error.
Possible Solution
Add
asyncio.set_event_loop(self._loop)in Browser._execute_async before nest_asyncio.apply(), so thebrowser's loop is registered on whatever thread runs the tool.
Related Issues
No response