Implement browser session inactivity timeout and cleanup

- Updated `.env.example` to include `BROWSER_INACTIVITY_TIMEOUT` for auto-cleanup of inactive sessions.
- Enhanced `cli.py` to load the new inactivity timeout configuration into environment variables.
- Added background thread functionality in `browser_tool.py` to periodically clean up inactive browser sessions based on the configured timeout.
- Improved session management by tracking last activity timestamps and ensuring cleanup occurs when sessions exceed inactivity limits.
This commit is contained in:
teknium1 2026-01-31 21:42:15 -08:00
parent c360da4f35
commit 20f2875472
6 changed files with 336 additions and 4 deletions

View file

@ -106,9 +106,12 @@ BROWSERBASE_PROXIES=true
# Enable advanced stealth mode (default: false, requires Scale Plan)
BROWSERBASE_ADVANCED_STEALTH=false
# Browser session timeout in seconds (default: 300)
# Browser session timeout in seconds - Browserbase session duration (default: 300)
BROWSER_SESSION_TIMEOUT=300
# Browser inactivity timeout in seconds - auto-cleanup inactive sessions (default: 120)
BROWSER_INACTIVITY_TIMEOUT=120
# =============================================================================
# LEGACY/OPTIONAL
# =============================================================================