Repository navigation
fix(interactive_browser): close remote browsers when the server shuts down - #5982
Merged
Merged
Conversation
The server had no shutdown hook, so a process that exited, or one uvicorn worker that stopped, left the remote browsers it held open until the provider ended them. Chain a lifespan in setup_webserver that closes every browser the process still holds, local and remote. Browsers close concurrently, each bounded by a timeout; a failed or stuck close is logged and does not stop the others. Closes #5979 Signed-off-by: Ananth Subramaniam <[email protected]>
…e close A limit around the whole close could cancel the provider release partway, so a slow Lexmount close skipped the delete that ends the session. Bound each CDP teardown step instead, which also keeps a dead endpoint from hanging verify or a re-seed, and let the provider release run under its own limits. Document that Gym's launcher kills a server one second after SIGINT by default, and how long to allow a remote browser to close. Signed-off-by: Ananth Subramaniam <[email protected]>
ananthsub
force-pushed
the
ananthsub/interactive-browser-shutdown
branch
from
November 13, 2026 18:28
f0a9c89 to
d0e58f9
Compare
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.
What changed and why
Fixes #5979.
interactive_browserhad no shutdown hook. When the server process exited, the browsers it held stayed open. For theremote_cdpbackend with thelexmountprovider, that means remote browsers kept running until the provider ended them. The server requiresnum_workers: 1, so the case is the single server process stopping.setup_webservernow wrapsapp.router.lifespan_context, the same wayswebench_proandofficeqastop their sandboxes, and calls a newshutdown()when the server stops.shutdown()closes every browser the process still holds, local and remote, all at once. Each close goes through the existing release path, which logs a failed close instead of raising, so one failure does not stop the others.verify, a re-seed or shutdown, before the provider release ran. The provider release keeps its own limits; Lexmount allows 30 seconds for each of its two calls.session.closeand beforesessions.delete, the call that ends the Lexmount session, which would bring the leak back exactly when the service is slow.server_shutdown_timeout_seconds, which defaults to 1 second. A remote close can take up to about 100 seconds when the provider is slow. The README now explains this and gives an example value for remote backends, and the module docstring points to it.Validation
uv syncinresources_servers/interactive_browser, thenpytest tests).pre-commit run --filespasses on the changed files.Rollout evidence
N/A: this change only adds cleanup when the server shuts down and limits on teardown steps. It does not touch the agent, the tools or how episodes are scored.