AgentEvalTool/backend/plugins/openclaw/README.md
sinohqb a77cd83e6a v0.2.0-dev: 文件管理 + 页面布局统一 + 6 个 bug 修复
## 新增功能
- 文件管理模块:分类树 + 文件上传/下载/删除
- 文件上传支持拖拽(Dragger)+ 手动上传(customRequest 模式)

## 页面布局统一(参照评测执行页)
- 仪表盘/评测对象/评测场景/评测报告 全部改为全高 flex 布局
- 统一内联页头样式(h2 + 竖线分隔 + 描述)
- 表格撑满高度、overflow 处理
- 每页添加刷新按钮

## Bug 修复
- 分类树操作按钮 hover 不可见(CSS 规则缺失)
- 文件上传失败(multipart boundary 缺失)
- LLM API 响应 content blocks 数组格式支持(_extract_content_from_api_response)
- response_time_max_ms 被静默忽略(隐式规则传空 params)
- 空 messages 导致 IndexError 崩溃
- poll_reply 异常中止整个 run(缺 try/catch)
- engine finally 未关闭 session
- 3 个页面 UTC 时间戳解析偏差 8 小时

## 后端
- EvalEngine: poll_reply 异常保护、空 dialog 保护、session 关闭
- LLM API 响应解析支持 content-block-array 格式
- 隐式 response_time 规则正确传递 max_ms 参数

## 前端
- api.ts: 移除手动 Content-Type(让浏览器自动添加 boundary)
- Files.tsx: customRequest 替代 beforeUpload、布局优化
- index.css: 分类树 hover 规则
- Targets/Scenarios/Home/Reports: 全高布局改造
- 3 个页面时间戳改用 formatDateTime()(修复 UTC 偏差)

Co-Authored-By: Claude <noreply@anthropic.com>
2026-07-16 15:25:22 +08:00

88 lines
2.2 KiB
Markdown
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

# OpenClaw 插件 for AgentEvalTool
本目录提供 OpenClaw 调用 AgentEvalTool 的示例技能,使 OpenClaw 能够自闭环完成评测策略设计。
## 设计原则
- AgentEvalTool 作为独立的 CLI 工具集存在,负责:
- 评测对象管理
- 评测场景管理
- 评测执行与原始数据收集
- 评估分析与报告生成
- OpenClaw 通过本插件调用 `agenteval` CLI负责
- 评测策略编排(选择对象、场景、触发时机)
- 定时调度OpenClaw 自身的 cron + skill 机制)
- 结果通知与后续动作
## 前置条件
1. 已安装 AgentEvalTool CLI
```bash
pip install -e /path/to/AgentEvalTool
```
2. `agenteval` 命令已在 PATH 中可用。
3. 已通过 `agenteval target add` 注册评测对象。
4. 已通过 `agenteval scenario import` 导入评测场景。
## 接入方式
### 方式一:直接调用 CLI推荐
在 OpenClaw Skill 中直接调用系统命令:
```python
import subprocess
# 触发评测
subprocess.run([
"agenteval", "run", "start",
"--target-id", "<target-id>",
"--scenario-id", "<scenario-id>",
], check=True)
# 获取报告(需要在运行输出中解析 run_id
report = subprocess.check_output([
"agenteval", "report", "show", "<run-id>", "--format", "json",
])
```
### 方式二:使用本目录封装的 Skill
参考 `agenteval_skill.py`,在 OpenClaw 中注册技能时传入配置:
```json
{
"target_id": "<target-id>",
"scenario_id": "<scenario-id>",
"report_format": "json"
}
```
## OpenClaw 定时评测示例
OpenClaw 的 cron 配置(具体格式以 OpenClaw 平台为准):
```yaml
skill: agenteval_skill
schedule: "0 9 * * *" # 每天早上 9 点执行
config:
target_id: "<target-id>"
scenario_id: "<scenario-id>"
report_format: "json"
```
## CLI 返回的 run_id 解析
`agenteval run start` 成功后会输出:
```text
评测完成: run_id=xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx, status=completed
```
OpenClaw Skill 需要从 stdout 中提取 `run_id`,然后调用 `agenteval report show <run_id>` 获取报告。
## 扩展建议
- 可以在 OpenClaw Skill 中根据报告结果触发告警、创建工单或通知相关人员。
- 可以将报告推送到企业微信、钉钉、邮件等通道。