跳转到主要内容
欢迎为 browseruse-bench 项目做出贡献!本指南将帮助你了解如何参与项目开发。

开发环境设置

1

Fork 仓库

在 GitHub 上 Fork browseruse-bench 仓库
2

克隆代码

git clone https://github.com/your-username/browseruse-bench.git
cd browseruse-bench
3

安装依赖

# 使用 uv(推荐)
uv sync --all-extras

# 或使用 pip
pip install -e ".[all,dev]"
4

创建分支

git checkout -b feature/your-feature-name

贡献类型

添加新 Agent

  1. browseruse_bench/agents/ 中新增 Agent 模块(如 your_agent.py
  2. 实现 BaseAgent.run_task 并使用 @register_agent 注册
  3. configs/agents/<agent>/config.yaml 中添加运行配置(可选 config.yaml.example
  4. browseruse_bench/agents/__init__.py 中导入模块
  5. 在根目录 config.yaml 中注册 Agent
  6. 更新文档
详见 添加新 Agent 对于浏览器类 Agent 或新增浏览器类型,也请遵循 接入自定义 Agent 中的约束与检查清单。

添加新 Benchmark

  1. benchmarks/ 目录下创建新 Benchmark 目录
  2. 准备任务数据和 data_info.json
  3. 实现评估器(可选)
  4. 更新文档
详见 自定义 Benchmark

修复 Bug

  1. 创建 Issue 描述问题
  2. 提交包含修复的 PR
  3. 确保测试通过

改进文档

  1. 修改 docs/ 目录下的文档
  2. 提交 PR

添加新 Agent

目录结构

browseruse_bench/
└── agents/
    └── your_agent.py
config/
└── agents/
    └── your-agent/
        ├── config.yaml
        └── config.yaml.example  # 可选示例配置
密钥请放在根目录 .env,YAML 配置中不要写入敏感信息。

实现接口

新 Agent 需要继承 BaseAgent 并实现 run_task
from __future__ import annotations

import logging
from pathlib import Path
from typing import Any, Dict

from browseruse_bench.agents.base import BaseAgent
from browseruse_bench.agents.registry import register_agent

logger = logging.getLogger(__name__)


@register_agent
class YourAgent(BaseAgent):
    name = "your-agent"

    def run_task(
        self,
        task_info: Dict[str, Any],
        agent_config: Dict[str, Any],
        task_workspace: Path,
    ) -> Dict[str, Any]:
        task_id = task_info.get("task_id", "unknown")
        logger.info("Running task %s", task_id)
        return {
            "task_id": task_id,
            "status": "success",
            "answer": "",
            "metrics": {"steps": 0},
        }

注册 Agent

  1. browseruse_bench/agents/__init__.py 中导入模块:
from browseruse_bench.agents import your_agent  # noqa: F401
  1. 在根目录 config.yaml 中新增 Agent 配置:
agents:
  your-agent:
    path: browseruse_bench/agents
    entrypoint: scripts/agent_runner.py
    config: configs/agents/your-agent/config.yaml
    supported_benchmarks:
      - Online-Mind2Web
    venv: .venv

代码规范

格式化

# 使用 ruff 格式化
ruff format .

# 检查代码风格
ruff check .

类型检查

# 使用 mypy 进行类型检查
mypy browseruse_bench

测试

# 运行所有测试
pytest tests/

# 运行特定测试
pytest tests/test_eval.py -v

提交 PR

1

确保测试通过

pytest tests/
ruff check .
2

提交更改

git add .
git commit -m "feat: add your feature description"
3

推送分支

git push origin feature/your-feature-name
4

创建 PR

在 GitHub 上创建 Pull Request,描述你的更改

Commit 规范

使用 Conventional Commits 格式:
  • feat: 新功能
  • fix: Bug 修复
  • docs: 文档更新
  • refactor: 代码重构
  • test: 添加测试
  • chore: 其他更改
示例:
feat: add WebArena benchmark support
fix: resolve timeout issue in browser-use agent
docs: update quickstart guide