Skip to content

[AISBench] New harbor adapter - #503

Merged
Libotry merged 76 commits into
AISBench:masterfrom
SJTUyh:new_harbor
Sep 3, 2026
Merged

Libotry merged 76 commits into
AISBench:masterfrom
SJTUyh:new_harbor

Conversation

@SJTUyh

@SJTUyh SJTUyh commented Aug 29, 2026 •

Copy link
Copy Markdown
Collaborator

Thanks for your contribution; we appreciate it a lot. The following instructions will make your pull request healthier and help you get feedback more easily. If you do not understand some items, don't worry, just make the pull request and seek help from maintainers.
感谢您的贡献,我们非常重视。以下说明将使您的拉取请求更健康,更易于获得反馈。如果您不理解某些项目,请不要担心,只需提交拉取请求并从维护人员那里寻求帮助即可。

PR Type / PR类型

  • Feature(功能新增)
  • Bugfix(Bug 修复)
  • Docs(文档更新)
  • CI/CD(持续集成/持续部署)
  • Refactor(代码重构)
  • Perf(性能优化)
  • Dependency(依赖项更新)
  • Test-Cases(测试用例更新)
  • Other(其他)

Related Issue | 关联 Issue
Fixes #(issue ID / issue 编号) / Relates to #(issue ID / issue 编号)
Fixes #516

🔍 Motivation / 变更动机

AISBench 原生仅具备推理/精度/性能测评能力,缺少对 Agent(智能体) 的测评能力。本 PR 引入一套完全独立的 Agent 测评链路,通过集成 Harbor 框架,让用户能用熟悉的 AISBench 方式发起 Agent 测评:

  • 一条命令(--mode agent)拉起 Harbor 评测,实时查看每个 case 状态;
  • 内置 Harbor 定义的全量 Agent(terminus-2、claude-code、openhands、dsh 等),也支持自定义 module.path:ClassName;
  • 不同 Agent 对同一含义参数传入方式不同(kwargs / 环境变量),由参数适配器统一转换,用户只使用一套统一语义参数;
  • 支持 Harbor 全量数据集来源(本地任务目录、registry name@version、package org/name@ref);
  • 独立精简依赖集,不依赖 AISBench 原生繁重依赖,不影响既有功能。

📝 Modification / 修改内容

新增(✅)

  • cli/argument_parser.py:_agent_parser() 新增 agent 参数组 + --mode 增加 agent/agent_viz(-a/--agent、--api-base、--agent-api-key、-p/--agent-dataset-path、-d/--dataset、-n/--n-concurrent、-k/--n-attempts、-e/--environment、--timeout-multiplier、--max-retries、--monitor-port、--purge-exception-cases 等)。
  • cli/workers.py:新增 AgentEval worker + WORK_FLOW 增加 agent/agent_viz;_apply_cli_args 合并 CLI 参数到模型/数据集配置。
  • runners/harbor_runner.py:HarborRunner(单任务进程内 / 多任务子进程 + 看板;Ctrl+C 清理、超时兜底;--purge-exception-cases 预清理)。
  • runners/harbor_monitor.py:HarborMonitor + HarborMonitorServer(标准库 http.server,两级快照 + 实时 HTTP 端点)。
  • tasks/custom_tasks/harbor_agent_task.py:HarborAgentTask(兼容全部 Agent、全量数据集来源、进度指标)。
  • utils/agent_params.py:AgentParamAdapter(显式映射 + 描述符发现 + 兜底约定 + 按 Agent 默认注入;含 dsh 等新接入 Agent)。
  • summarizers/harbor.py:HarborSummarizer(单表 + 单 CSV)。
  • requirements/agent.txt、setup.py extras_require["agent"]:独立依赖集。
  • UT:tests/UT/{utils,runners,tasks/custom_tasks,summarizers} 新增 Harbor 相关测试。
  • 文档:docs/source_{zh_cn,en}/ 新增/更新 Agent 测评指南、CLI 参数说明、场景简介。

改造(🧩 惰性化/增强)

  • runners/base.py:TasksMonitor.stop_state_board 停止标志。
  • runners/local.py、utils/config/run.py、datasets/__init__.py、tasks/__init__.py、utils/file/__init__.py、openicl/icl_inferencer/icl_base_local_inferencer.py 等:惰性导入以支持 agent 独立依赖集。

📐 Associated Test Results / 关联测试结果

  • Harbor 相关 UT 全量通过,关键模块覆盖率达标:
    • runners/harbor_runner.py ≈ 90%,runners/harbor_monitor.py ≈ 96%,tasks/custom_tasks/harbor_agent_task.py ≥ 90%,summarizers/harbor.py 100%,utils/agent_params.py ≥ 80%(行超过 80%、分支超过 70%,满足设计约束)。
  • 运行命令:python3 run_tests.py UT/(全量通过,总覆盖率 ≥ 80%)。
  • 端到端:ais_bench <cfg> --mode agent -a terminus-2 --model ... --api-base ... -p ... --monitor-port 8788 可实时查看 case 状态并输出单表 + CSV。

和harbor精度比较:
https://github.com/SJTUyh/benchmark/wiki/%E3%80%90%E9%AA%8C%E8%AF%81%E6%8A%A5%E5%91%8A%E3%80%91AISBench%E6%8E%A5%E5%85%A5harbor%E6%A1%86%E6%9E%B6

⚠️ BC-breaking (Optional) / 向后不兼容变更(可选)

新引入的 Agent 相关 CLI 均为本次新增,不影响既有 all/infer/eval/perf 等模式。两点命名说明:

  • Agent 侧 API key 参数命名为 --agent-api-key,数据集路径命名为 -p/--agent-dataset-path,以避免与既有 api_model 的 --api-key、--path 冲突(两组参数可并行解析)。
  • 对本仓库其它模块无破坏:改造均为函数内惰性导入或增量字段,向后兼容。

⚠️ Performance degradation (Optional) / 性能下降(可选)

无。新增链路与原生链路隔离;监控服务仅定时读取落盘文件并按 mtime 增量缓存,高频刷新开销低。

🌟 Use cases (Optional) / 使用案例(可选)

  1. 命令行方式:
    ais_bench --mode agent -a terminus-2 --model hosted_vllm/qwen3 \
              --api-base http://0.0.0.0:8080/v1 -p /path/to/terminal-bench-2 \
              -n 5 -k 1 -e docker --monitor-port 8788
  2. 自定义配置文件方式:参考 ais_bench/configs/agent_example/harbor_agent_task.py。
  3. 中断续测:--reuse <ts>;异常用例自动重试:--reuse <ts> --purge-exception-cases。
  4. 仅汇总:--mode agent_viz --reuse <ts>。
  5. 文档已更新:docs/source_zh_cn/base_tutorials/scenes_intro/agent_benchmark.md 及英文版、all_params/cli_args.md(中/英)、scenes_intro/home.md(中/英)。

✅ Checklist / 检查列表

Before PR:

  • Pre-commit 或其他 linting 工具已用于修复潜在的 lint 问题。
  • 新增功能已由完整单元测试覆盖(Harbor 各组件均新增 UT)。
  • 所有相关文档(API 文档、文档字符串、示例/教程)已更新以反映这些更改。

After PR:

  • 若对下游或其他相关项目有潜在影响,已在相关项目中测试此 PR。
  • CLA 已签署,且本 PR 中的所有提交者均已签署 CLA。

👥 Collaboration Info / 协作信息

  • Suggested Reviewers / 建议审核人: @xxx
  • Relevant Module Owners / 相关模块负责人: @xxx

🌟 Useful CI Command / 实用的CI命令

Command / 命令 Introduction / 介绍
/gemini review Performs a code review for the current pull request in its current state by Gemini. / 对当前拉取请求在当前状态下由 Gemini 执行代码审核。
/gemini summary Provides a summary of the current pull request in its current state by Gemini. / 对当前拉取请求在当前状态下由 Gemini 提供摘要。
/gemini help Displays a list of available commands of Gemini. / 显示 Gemini 可用命令的列表。
/readthedocs build Triggers a build of the documentation for the current pull request in its current state by Read the Docs. / 触发当前拉取请求在当前状态下由 Read the Docs 构建文档。
/pr_check 手动重新触发 PR 合入质量检查工作流(PR Quality Check),并在 PR 上评论即可生效。 / Manually re-runs the PR Quality Check workflow by commenting on the pull request.

@SJTUyh
SJTUyh temporarily deployed to smoke-test-approval September 1, 2026 00:58 — with GitHub Actions Inactive
@github-actions

github-actions Bot commented Sep 1, 2026

Copy link
Copy Markdown

🚫 PR 合入质量检查未通过,PR 已被禁止合入。

未通过项:large_pr、no_issue、no_review

  • 超大 PR:新增代码 4763 行,超过 1000 行上限,建议拆分。
  • 未关联 Issue:请在 PR 描述中关联 Issue,例如 Fixes #123 或 Relates to #123。
  • 无检视意见:请至少邀请一位 reviewer 提交检视意见(Approve / Request changes / Comment 均可)。

请按上述提示整改后,重新推送(push)或评论本 PR 即可触发再次检查。

@github-actions

github-actions Bot commented Sep 1, 2026

Copy link
Copy Markdown

🚫 PR 合入质量检查未通过,PR 已被禁止合入。

未通过项:large_pr、no_issue、no_review

  • 超大 PR:新增代码 4841 行,超过 1000 行上限,建议拆分。
  • 未关联 Issue:请在 PR 描述中关联 Issue,例如 Fixes #123 或 Relates to #123。
  • 无检视意见:请至少邀请一位 reviewer 提交检视意见(Approve / Request changes / Comment 均可)。

请按上述提示整改后,重新推送(push)或评论本 PR 即可触发再次检查。

@github-actions

github-actions Bot commented Sep 1, 2026

Copy link
Copy Markdown

🚫 PR 合入质量检查未通过,PR 已被禁止合入。

未通过项:large_pr、no_issue、no_review

  • 超大 PR:新增代码 5239 行,超过 1000 行上限,建议拆分。
  • 未关联 Issue:请在 PR 描述中关联 Issue,例如 Fixes #123 或 Relates to #123。
  • 无检视意见:请至少邀请一位 reviewer 提交检视意见(Approve / Request changes / Comment 均可)。

请按上述提示整改后,重新推送(push)或评论本 PR 即可触发再次检查。

@SJTUyh
SJTUyh had a problem deploying to smoke-test-approval September 2, 2026 02:32 — with GitHub Actions Failure
@github-actions github-actions Bot added review_opened PR 中存在未闭环的检视意见,所有检视意见必须闭环后才能合入 and removed no_review PR 未包含任何检视意见,合入前必须包含检视意见 labels Sep 2, 2026
@github-actions

github-actions Bot commented Sep 2, 2026

Copy link
Copy Markdown

🚫 PR 合入质量检查未通过,PR 已被禁止合入。

未通过项:large_pr、no_issue、review_opened

  • 超大 PR:新增代码 5240 行,超过 1000 行上限,建议拆分。
  • 未关联 Issue:请在 PR 描述中关联 Issue,例如 Fixes #123 或 Relates to #123。
  • 检视意见未闭环:还存在 1 条未 Resolve 的检视意见,请全部 Resolve 后再合入。

请按上述提示整改后,重新推送(push)或评论本 PR 即可触发再次检查。

@SJTUyh
SJTUyh temporarily deployed to smoke-test-approval September 2, 2026 03:17 — with GitHub Actions Inactive
@SJTUyh
SJTUyh requested a review from Libotry September 3, 2026 01:23
@SJTUyh
SJTUyh temporarily deployed to smoke-test-approval September 3, 2026 01:29 — with GitHub Actions Inactive
@github-actions github-actions Bot removed no_issue PR 未关联任何 Issue,合入前必须关联 Issue review_opened PR 中存在未闭环的检视意见,所有检视意见必须闭环后才能合入 labels Sep 3, 2026
@github-actions

github-actions Bot commented Sep 3, 2026

Copy link
Copy Markdown

🚫 PR 合入质量检查未通过,PR 已被禁止合入。

未通过项:large_pr

  • 超大 PR:新增代码 5241 行,超过 1000 行上限,建议拆分。

请按上述提示整改后,重新推送(push)或评论本 PR 即可触发再次检查。

@Libotry

Libotry commented Sep 3, 2026

Copy link
Copy Markdown
Collaborator

超大PR已报备评审

@Libotry
Libotry merged commit 25df868 into AISBench:master Sep 3, 2026
6 of 7 checks passed

This branch was previously deployed

1 inactive deployment
smoke-test-approval — c24c72a1 Deployed Sep 3, 2026 by SJTUyh via run_smoke_test_cases #668
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

docs feature large_pr PR 新增代码超过 1000 行,建议拆分为更小的 PR test-cases

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[需求] AISBench需要能够接入harbor框架

2 participants