Files
myWiki/concepts/adapter-protocol.md

51 lines
2.0 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.

---
title: "适配器协议 (Adapter Protocol)"
created: 2026-06-15
updated: 2026-06-15
type: concept
tags: [coding-agent, evaluation, benchmarking]
sources: [raw/papers/zheng-claw-swe-bench-2026.md]
---
# 适配器协议 (Adapter Protocol)
## 定义
Claw-SWE-Bench 中的适配器协议是一组标准化的生命周期接口,用于将异构 agent harnessclaw连接到统一的 SWE-bench 评测管道。它不需要不同 harness 使用相同的内部 agent 循环,而是标准化 harness 与 benchmark 生命周期之间的接口。
## 接口方法
每个受支持的 harness 实现五个抽象方法:
| 方法 | 职责 |
|------|------|
| `create_agent` | 创建或配置 agent 实例 |
| `send_task` | 派发实例化的任务 |
| `backup_session` | 保存运行产物 |
| `delete_agent` | 清理 harness 状态 |
| `get_docker_args` | 提供 harness 特定的 Docker 参数 |
## 设计原则
1. **职责分离:** 容器管理、prompt 实例化、patch 收集、预测写入、元数据记录由 benchmark 层统一处理
2. **最小接口:** 每个 harness adapter 仅需连接其 agent 到该生命周期
3. **Patch 来源独立:** 候选 patch 从**仓库状态**收集,而非从 agent 最终消息解析——无论 harness 输出 JSON、纯文本、自然语言还是没有结构化响应
## Full Adapter vs Bare Adapter
| | Bare Adapter | Full Adapter |
|---|---|---|
| Docker 访问 | 最小 | 完整 workspace 准备 |
| Patch 提取 | 要求模型输出 unified diff | Git diff from /testbed |
| Future-Commit 清理 | 无 | 有 |
| Apply Failed | 69.1% | <1.5% |
| Pass@1 (GLM 5.1) | 19.1% | 73.4% |
**关键洞察:** Bare adapter 的瓶颈不是模型不会编辑代码而是直接生成 unified-diff 文本的脆弱性——行号上下文hunk header尾部换行都可能导致 patch 无法 apply
## 参考
- [[claw-swe-bench|Claw-SWE-Bench 论文]]
- [[agent-harness|Agent Harness]]
- [[patch-based-evaluation|Patch-Based Evaluation]]
- [[bare-adapter|Bare Adapter]]