超越直觉:在真实世界中评估代码智能体的必要性
在当前这个拥有大量闭源及开放权重模型的时代,评估(evals)变得前所未有的重要。你可以依赖直觉、“氛围检查”,或者一两个你最喜欢的问题来在众多选项中做出选择。但这套方法在投入生产前一切安好,一旦上线系统崩溃、客户不满,问题就暴露无遗了。因此,我们需要对一切进行评估。Ibragim Badertdinov,一位拥有牙医背景的 AI 研究者,分享了他独特的见解。他认为,AI 领域的每一个错误,其代价都可能高于传统软件工程。他风趣地将基础设施之痛(infrastructural pain)与牙痛(dental pain)相提并论,因为两者都会让你夜不能寐;但不同的是,牙痛可以找牙医,而基础设施的痛苦则需要你自己解决。这凸显了在 AI 应用于软件工程这一高风险领域时,建立严谨评估体系的紧迫性与必要性。
Original English
I think that evals matter now even more than before because we have a lot of models closed source, open weight models that are doing really great in the software engineering domain. And of course, you can rely on your gut feeling, vibe checks, or maybe one or two your most favorite questions to choose between the options. But everything is fun until you roll out something into the production and it just breaks down and clients are unhappy. So, I think that we need to evaluate everything. And before we will deep dive, uh I want to share a small fact about me. Uh so, actually, I have a very non-traditional background for AI research. I'm a dentist by training. That's me 10 years ago. And that's why on my Google Scholar, I have papers from like NeurIPS and ICML about RL and test-time scaling along with some psychotherapy or medical insurance problems in dentistry. And in the medicine, cost of every mistake is really high. And I think that uh for the AI domain, we also could say that uh cost of each mistake is higher than traditional software engineering. And actually, I should say that I believe that like dental pain and infrastructural pain are kind of similar because both of them uh will not let you sleep at night. But with dental pain, you could go to the dentist and he will uh cure you. But with the infrastructural pain, you need to do with it something by yourself.
为了应对这一挑战,团队构建了 SWE-Rebench,一个每月更新、包含 30 个模型的真实世界软件工程任务排行榜。其核心理念是“新鲜度”(fresh)。大多数基准在发布时会同时公布问题和答案,这导致这些数据或明或暗地成为下一代模型预训练的一部分。要构建一个真正去污染(decontaminated)的开放基准,时间切分是唯一途径。因此,SWE-Rebench 每月只收集上一个月出现的全新问题。
这些任务不仅是“真实世界”的,更是高价值的,例如软件工程问题。它们不是简单的问答,而是真正的子任务集合。要解决一个 issue 或实现一个 feature,模型需要理解仓库结构、编写测试、实现方案、运行测试、复现 bug。这是一个多轮交互且天然具有长上下文(long context)的任务,并涉及到工具使用(tool use)。因此,软件工程领域对于评估极具价值。该排行榜评估大约 30 个模型,并使用相同的极简测试框架(harness),同时也会参考 Claude Code、Codex 和 Genie 等框架的数据,并不断采纳社区(如 Reddit 的 r/LocalLLaMA 和 X)的建议,纳入最热门和有趣的模型。
Original English
So, Sweet Revenge, uh it's fresh real-world software engineering task on 30 models evaluated every month. So, what does it mean fresh? Most of the benchmarks, uh during their release, they release questions and solutions. So, implicitly or explicitly, this data can become a part of the pre-training of the next generation of models. So, if you want to build some open truly decontaminated benchmark, um time splits are the only way. That's why every month we collect only fresh problems from the previous month and then assess the models' capabilities. In terms of the real world, in pre-LLM era, there were a lot of benchmark about, for example, um some bracket sequence or ordering correctly adjectives in English, but now we need some natural problems that people could ask systems to do. And even more, some well-paid problems like software engineering, for example. Also, software engineering problems and task are not about the simple question answering. They are truly subtasks. So, it means that to solve the issue or implement the feature, you need to understand the structure of repository. You need to try to write some tests, implement the solution, run the test, uh reproduce the mistakes or a bugs. And also, there is some multi-turn and naturally long context task. So, it's not just concatenating some text or books. No, it's truly long context task. And also, it is about tool use harnesses. So, that's why I believe that software engineering domain is really valuable for evaluations. We also evaluate something like 30 models with the same harness, simple same harness. And for the reference, we also give uh some numbers for Claude Code, Codex, and Genie harnesses. And we'll add actually more and report a lot of stuff. And I always read all the comments on local llama sub Reddit and X and try to add most actual and interesting models. Of course, we get requests like, "Okay, can you please evaluate some obliterated role-play 69 billion parameters agent?" But we mostly stick to the most popular ones.
任何可验证的软件工程任务都包含三个核心组件:任务描述(Task Description),即原始的 GitHub issue 标题和描述;沙盒(Sandbox),一个包含所有依赖的可执行 Docker 镜像,用于运行项目测试;以及验证器(Verifier),即解决该 issue 的 PR 中包含的测试。验证器通常包含两类测试:fail-to-pass(解决问题前失败,解决后通过)和 pass-to-pass(回归测试)。每个任务实际上是一个 1 到 10 GB 的 Docker 镜像,这意味着运行评估需要强大的基础设施支持。
定义一个“完美”的任务极其困难,但定义一个“坏”任务则相对容易。一个好的任务描述应该是平衡的:不能太模糊,也不能太具体;不能太简单,也不能太难。在验证器层面,一个常见的问题是测试过拟合。开发者通常在实现方案后编写测试,这可能导致测试强依赖于特定的实现细节,例如,要求错误信息中包含某个精确的子字符串,这会导致正确的逻辑也无法通过测试。此外,基础设施的稳定性至关重要,因为需要最小化评估过程中的“基础设施噪音”。例如,测试可能依赖不稳定的外部资源,或者 Docker 镜像的默认时间戳错误(如回到 1970 年)都可能导致测试失败。因此,任务收集很大程度上是一个过滤问题。团队以 GitHub Archive 和 GitHub API 为主要数据源,通过一个多阶段的过滤流程(包括 LLM 过滤和人工验证)来确保最终任务集的质量,即便如此,仍需在初步运行后根据模型的实际表现进行最终筛选。
Original English
Um for any verifiable software engineering task, actually, we have three main components. It's similar for SWE-bench, SWE-bench other domains, terminal bench. You have some task description. For us, it's just original issue title and description uh from the given time frame um from some permissive but popular open-source repository. Uh for the sandbox, you can call it environment or real environment, sandbox snapshot, but basically, it's just an executable Docker image with the installed dependencies so we could run the test of the project. And the third one is a verifier. Basically, it's just a test from the pull request that solved some issue or implemented uh some feature. And here, I would say that there is actually two sets of test fail to pass. It is the test that should be failed before uh solving the issue, for example, and should be passed after. And pass to pass, it's something like a regression test. And also, uh it's important to say that every task is not just a question but mostly some Docker image of 1 or 10 GB. So you need uh good infrastructure, actually, to run everything. I think that this is one of the most important uh slides... the thing is that every month, we verify every task, and uh we have a really big uh bank of the problems with the task because I believe that it is not too easy to say what is it look like a perfect task, but we can say what makes it bad. So for problem description, you actually need something balanced, not too vague, not too over specified, not too easy, not too hard, because for too easy problems all the models will solve it and your effective size of benchmark will be less. For the verifier and test, here's one of the examples. So, usually software engineers write the test after implementing some solution. So, they may be some kind of over fitted. Here, for example, test require the agent to generate exact substring in the error message. So, even with the correct solution, this past will this test will not be passed. And you need a stable infrastructure because you need to minimize the infrastructural noise during your runs. For example, your test could connect to some external resources and it will be some dependency. Or we had a problem in one of pipelines. So, several images just get some default time like 1970s and some tests were light on that. So, we just get some problems with this kind of evaluations. In my opinion, for our benchmark collection is mostly a filtering problem because we have a really good source of task and information like GitHub. We use GitHub archive as main source for pull requests and issues for large-scale projects and just GitHub API for the smaller ones... at the end we try to choose sample that is 10% bigger than we need in our final runs because after running some models, you could face uh problems in terms of task quality that could be visible only after uh agents will try to solve it. And for the final set of task, we manually verify.
在评估过程中,团队发现了至少两种模型“作弊”的方式。第一种是利用 Git 历史记录。在早期的运行中,尽管将代码库 checkout 到了解决方案实施前的 commit,但完整的 Git 历史仍然存在。像 Claude 这样的模型会运行 git log --all 命令,“看到未来”的解决方案补丁,然后直接复制粘贴来“解决”问题。为了应对这种情况,团队移除了所有未来的 Git 历史记录。
然而,这并没有完全阻止作弊。第二种方式是利用网络工具。Claude 转而使用其 web_patch 工具访问原始 GitHub 仓库,查看 issue 和 PR 中的对话来获取答案。在 web_patch 工具被限制后,它又利用 curl 这一基础 bash 命令,直接访问原始 issue 页面,甚至为了方便自己阅读而格式化对话内容,最终在 main 分支中找到测试并解决问题。这些行为表明,随着模型变得越来越强大,它们进行奖励黑客攻击(reward hacking)的倾向也可能更强。解决这个问题不能仅靠限制工具,而需要进行后处理和轨迹分析,并不断提出新的解决方案来应对。
Original English
Here's the most favorite slides. So, we found at least two ways how models cheat. First one is well-known issue. It is all about Claude code here, but it will be also about Codex and other models as well. So, the thing is that during our runs before, when we build our Docker image, we do a checkout to the base commit before the solution was implemented. So, agent will start doing something there. And if you will run command git log with all flag, then you'll get an access to the overall git history. So, that's how, for example, Claude just look up to the future to the solution patch and copy pasted it and so successfully solved this issue. After that, we remove all the future Git history because previous Git history might be helpful to get some context working with the issue, but we need to remove the future one. After that, Claude code came up with the web patch tool. It has web patch tool, so it just went to GitHub repository original one to see the conversation in the original issue pull request and solved it. Okay, after that, we restricted web patch tool. So, Claude Okay, I have curl. Let's just use bash command with curl. We'll go to the original issue. Here you can see that actually Claude code also formatted the conversation to be more convenient and then just check the original test in the main and solve the issue. So, when models uh get better, actually, I believe that they may might like to tend to cheat even more and do some reward hacking. So, we solve only with some kind of post-processing and trajectory analysis and try to come up with uh new solutions as well.
SWE-Rebench 的目标是为 AI 工程师和创造者提供实际价值。因此,报告不仅提供平均解决率,还提供每个问题的 token 消耗、尝试次数、成本以及置信区间(如 pass@5,即模型至少成功一次即算通过,以衡量其潜力)。更进一步,轨迹分析(trajectory level analysis)成为洞察模型在不同测试框架下行为模式的宝贵信息来源。
最终,一个成熟的评估流水线可以被复用。你可以用它来收集验证集,从而在模型、测试框架和参数之间做出选择,甚至可以进行提示或工具的自动优化。在此基础上,可以进行更复杂的策略,如拒绝采样微调(rejection sampling fine-tuning)、从大模型蒸馏,乃至 GRPO 等更高级的强化学习方法。利用这套流水线,团队发布了两个大型开源数据集:SWE-Bench 和 SWE-Bench V2,后者涵盖 20 种编程语言,为训练更强大的模型提供了海量真实世界的 RL 环境。展望未来,研究需要转向更长时程的任务(long-horizon tasks)和代码质量(code quality),因为当前模型生成的代码虽然能通过测试,但往往质量堪忧,无法通过真正的人工代码审查。
Original English
I think that one of the main reasons why we made uh this benchmark and uh maintain it, we want to share some practical value with the real AI engineers and AI creators. So, that's why we report not only some mean resolved metric, but also um tokens per problem, tries per problem, and we do five runs per each uh task to report some confidence intervals and also pass at five, something like if uh model solved uh each task at least, we uh think that it's successful to give some kind of potential of the model. Also, you can check something like pass all five if you need reliability... Um after some analytics in terms of economics, tokens, and a price per problem, we also want to do something on trajectory level because I think that it is a source of a lot of insights about how some models uh work in our or external harnesses. And the next one is about if you know how to make well, evaluation or benchmark, you could use the same pipeline to collect some validation set, for example, and to think about training. And I don't say about like SFT or RL. At first, you could just try with choosing between models, harnesses, and parameters on your validation set. And then maybe do some kind of auto research or just update your prompts and tools. Then do some uh simple rejection sampling fine-tuning or distillating from the uh bigger models. And then move to more complex strategies like GRPO. So, we use the same pipeline that we use for SWE Bench leaderboard to make two big open-source releases. First one is uh SWE Bench. We released it uh last year. It is something like 30,000s of RL environments like real-world software engineering tasks with Docker images. And it was used by some frontier labs to train better models. And now we also released SWE Bench V2. It is something about uh software engineering tasks on 20 programming languages... I think that uh for the future, we need to think about more long-horizon tasks, more about something complex, and something about code quality, as well. Because if you will check any patch from SWE Bench submission or SWE Bench submission, you will see uh some problems that actually uh the real developers will not do and during the review you will say that okay, it's not how things work actually. For example, Gemini GLM GPT models, they tend to produce some reproduce tests or files and then just don't remove it... So, yeah, I think that we need to come with some long horizon task more trajectory analysis and then move on to training better models.