{"id":3915,"library":"browsergym-core","title":"BrowserGym Core","description":"BrowserGym Core (version 0.14.3) is a Python library that provides the fundamental Gymnasium environment for web task automation within the Chromium browser. It serves as the base for various web agent benchmarks and is designed for researchers and developers evaluating and building web agents, particularly those leveraging Large Language Models (LLMs) for web interaction tasks. The project is under active development with a rapid release cadence.","status":"active","version":"0.14.3","language":"en","source_language":"en","source_url":"https://github.com/ServiceNow/BrowserGym","tags":["AI agents","web automation","reinforcement learning","gymnasium","chromium","playwright","benchmarking","LLM"],"install":[{"cmd":"pip install browsergym-core","lang":"bash","label":"Install core library"},{"cmd":"playwright install chromium","lang":"bash","label":"Install Playwright browser"}],"dependencies":[{"reason":"BrowserGym uses Playwright to control the Chromium browser for web interactions.","package":"playwright","optional":false},{"reason":"BrowserGym provides a gym-like environment, inheriting from Gymnasium for its API (e.g., env.step, env.reset).","package":"gymnasium","optional":false}],"imports":[{"symbol":"gym","correct":"import gymnasium as gym"},{"symbol":"BrowserEnv","correct":"from browsergym.core.env import BrowserEnv"},{"symbol":"AbstractBrowserTask","correct":"from browsergym.core.task import AbstractBrowserTask"}],"quickstart":{"code":"import gymnasium as gym\nfrom playwright.sync_api import sync_playwright\n\n# Register the 'openended' task provided by browsergym-core\nimport browsergym.core\n\n# It's good practice to install playwright chromium if not already done:\n# playwright install chromium\n\nwith sync_playwright() as p:\n    # Initialize the BrowserGym environment for an open-ended task\n    # 'headless=True' runs the browser without a visible UI\n    env = gym.make(\n        \"browsergym/openended\", \n        headless=True,\n        task_kwargs={'start_url': 'about:blank'}\n    )\n\n    try:\n        obs, info = env.reset()\n        print(f\"Initial observation keys: {obs.keys()}\")\n        print(f\"Initial info: {info}\")\n\n        # Example: taking a no-op step\n        action = env.action_space.sample()\n        obs, reward, terminated, truncated, info = env.step(action)\n\n        print(f\"Reward after one step: {reward}\")\n        print(f\"Terminated: {terminated}, Truncated: {truncated}\")\n\n    finally:\n        # Ensure the browser environment is closed properly\n        env.close()","lang":"python","description":"This quickstart demonstrates how to initialize a `browsergym-core` environment for an open-ended task, perform a reset, take a sample action, and ensure proper cleanup. It uses `gymnasium` for the environment API and `playwright.sync_api` to manage the browser context."},"warnings":[{"fix":"Run `playwright install chromium` after `pip install browsergym-core`.","message":"BrowserGym requires Playwright and its Chromium browser to be installed separately. Missing `playwright install chromium` is a common setup error.","severity":"gotcha","affected_versions":"All versions"},{"fix":"Set appropriate expectations for stability and feature completeness; contribute to its development if issues arise.","message":"BrowserGym is explicitly stated as a research tool and not a consumer product. Users should be aware it's under active development and may have rough edges.","severity":"gotcha","affected_versions":"All versions"},{"fix":"Implement robust error handling, increase timeout parameters where applicable, and refine agent logic for complex web interactions. Consider debugging with `headless=False` to observe browser behavior.","message":"Timeout errors are frequently encountered when interacting with web pages. These can be due to slow loading, complex elements, or agent actions that don't complete in time.","severity":"gotcha","affected_versions":"All versions"},{"fix":"Consult the `README.md` or documentation for the specific `browsergym-*` benchmark package you are using for its unique setup instructions.","message":"When integrating `browsergym-core` with specific benchmarks (e.g., WebArena), additional environment variables (e.g., `WA_PORT`) or benchmark-specific setup steps are often required to correctly configure task URLs and instances.","severity":"gotcha","affected_versions":"All versions"},{"fix":"Update your code to match the `gymnasium` API: `obs, info = env.reset()` and `obs, reward, terminated, truncated, info = env.step(action)`.","message":"Following Gymnasium API changes, `env.reset()` now returns `(observation, info)` and `env.step()` returns `(observation, reward, terminated, truncated, info)`. Older `(observation, info)` from `reset()` or `(observation, reward, done, info)` from `step()` patterns are deprecated.","severity":"breaking","affected_versions":"Pre-Gymnasium v0.26 environments, impacting older BrowserGym versions"}],"env_vars":null,"last_verified":"2026-04-11T00:00:00.000Z","next_check":"2026-07-10T00:00:00.000Z"}