fix: store AgentCore browser client for proper session cleanup#365
Open
omerio wants to merge 1 commit intostrands-agents:mainfrom
Open
fix: store AgentCore browser client for proper session cleanup#365omerio wants to merge 1 commit intostrands-agents:mainfrom
omerio wants to merge 1 commit intostrands-agents:mainfrom
Conversation
The session_client was not being stored in _client_dict after creation, causing close_platform() to iterate over an empty dict and never call client.stop() to terminate AgentCore browser sessions. This fix stores the session_client in _client_dict using the session_id as the key, allowing close_platform() to properly terminate all sessions when the browser is closed. Fixes strands-agents#205
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.
Description
The session_client was not being stored in _client_dict after creation in create_browser_session(), causing close_platform() to iterate over an empty dict and never call client.stop() to terminate AgentCore browser sessions.
This resulted in:
Browser sessions remaining in "READY" status in AWS Console after calling close()
The close() action returning success but not actually terminating the remote session
Applications hanging indefinitely as reported in #205
This fix adds a single line to store the session_client in _client_dict using the session_id as the key, allowing close_platform() to properly terminate all sessions when the browser is closed.
Related Issues
Fixes #205
Documentation PR
N/A - No documentation changes required for this bug fix.
Type of Change
Bug fix
Testing
Tested manually by:
Creating an AgentCore browser session
Performing browser actions (navigate, get_text, screenshot)
Calling close() action
Verifying via AWS CLI that sessions are now properly terminated (status: TERMINATED) instead of remaining in READY state
aws bedrock-agentcore list-browser-sessions --browser-identifier aws.browser.v1 --region us-west-2Before fix: Sessions remained in READY status after close After fix: Sessions properly show TERMINATED status
hatch run prepareChecklist
By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.