Mingyu's Library主页

怎么验证 Agent 做的代码迁移“行为没变”:OpenAI MultiLangBench 与 COBOL 迁移评测

How to Check an Agent's Code Migration Kept Behavior: OpenAI's MultiLangBench and COBOL Migration Evals

OpenAI 10 月 19 日的评测怎么设计、数字怎么读、你能借走什么。

How OpenAI's October 19 evals are built, how to read the numbers, and what you can borrow.

2026-10-20 · AI 每日简报深度学习
2026-10-20 · AI Daily deep dive

结论先说

The short version

10 月 19 日 OpenAI 发了一篇讲“低资源编程语言”的文章,里面有两个评测。一个是让模型用 20 种语言各写一个兼容 SQLite 的数据库;一个是把 COBOL 程序迁移到别的语言,而且要求输出逐字节一致。

数字很夸张:COBOL 迁移准确率,GPT-5.6 Sol 是 5.4%,GPT-6.1 Sol 低推理强度下 86.6%,高推理强度 97.9%。但这些都是 OpenAI 自己报的。我觉得更值得学的是评测的设计:它不看代码像不像,只看“隐藏测试下行为是否完全一样”。你自己给 Agent 派迁移、重构任务时,可以照这个思路搭验收。

On October 19, OpenAI published a post about "low-resource programming languages" with two evals. One asks a model to write a SQLite-compatible database in each of 20 languages. The other migrates COBOL programs to other languages and requires byte-for-byte identical output.

The numbers are big. On COBOL migration, GPT-5.6 Sol scores 5.4%, GPT-6.1 Sol scores 86.6% at low reasoning effort and 97.9% at higher effort. All of these are OpenAI's own figures. What I think is more useful is the eval design: it doesn't ask whether the code looks right, only whether behavior under hidden tests is exactly the same. If you hand migration or refactoring jobs to an agent, you can build your acceptance checks the same way.

OpenAI 到底测了什么

What OpenAI actually measured

“低资源语言”指训练数据和文档少的语言,比如 COBOL、Fortran、Visual Basic、OCaml。文章提到它们支撑着银行、天气预报这类关键系统。

评测一:MultiLangBench(从零写软件)。任务是用 20 种语言各实现一个兼容 SQLite 的数据库引擎。每个实现拿到一个初始数据库和一条 SQL,输出的数据库用真正的 SQLite 做对照检查;测试改自 SQLite 自己的测试套件。指标是通过率和 API 成本。

评测二:COBOL 迁移(保持行为)。把 COBOL 程序迁移到 C++、Java、Kotlin、Python 或 Rust。隐藏测试要求可观察的输出逐字节一致,所有测试都过才算成功。文章特别提到 COBOL 的定点数舍入这类细节容易出错。

"Low-resource" here means languages with little training code and documentation, such as COBOL, Fortran, Visual Basic and OCaml. The post notes they underpin critical systems like banking and weather forecasting.

Eval 1: MultiLangBench (build software from scratch). The task is to implement a SQLite-compatible database engine in each of 20 languages. Each implementation gets an initial database and a SQL query, and its output database is checked against a reference SQLite. The tests are adapted from SQLite's own test suite. Metrics are pass rate and API cost.

Eval 2: COBOL migration (preserve behavior). Migrate COBOL programs to C++, Java, Kotlin, Python or Rust. Hidden tests require byte-for-byte identical observable output, and a migration counts only if every test passes. The post calls out details such as COBOL's fixed-point rounding as a risk.

验收是怎么设计的

How the acceptance check is built

迁移评测的关键是“拿旧程序当标准答案”:同一批隐藏测试先在旧程序上跑一遍,记下输出;再在 Agent 迁移出来的新程序上跑,逐字节对比。只要有一个测试不同,整个迁移算失败。

这比“让另一个模型看代码对不对”可靠得多,因为它不依赖谁的判断,只依赖输出。代价是你得先有一批能覆盖业务规则的测试。OpenAI 也在文章里说,迁移真实生产系统仍要专家评审,并按业务规则和依赖做测试。

旧程序(COBOL) Agent 迁移 新程序(如 Java) 同一批隐藏测试 先在旧程序上跑,记下输出再在新程序上跑 逐字节对比输出 全部一致 = 成功 任一不同 = 失败 所以验收看行为,不看代码长相
图 1:旧程序是标准答案,新程序必须在同一批隐藏测试上输出完全一致。

The key idea in a migration eval is to treat the old program as the answer key. The same hidden tests run on the old program first and the output is recorded. Then they run on the program the agent produced, and outputs are compared byte for byte. One differing test fails the whole migration.

That is far more reliable than asking another model whether the code looks right, because it doesn't depend on anyone's judgment, only on output. The cost is that you need tests that cover the business rules first. OpenAI also says in the post that migrating real production systems still needs expert review and tests against the system's business rules and dependencies.

Old program (COBOL) Agent migrates New program (e.g. Java) Same hidden tests Run on old program first, record outputThen run on new program Byte-for-byte compare All match = pass Any diff = fail So acceptance checks behavior, not how the code looks
Figure 1: the old program is the answer key; the new one must produce identical output on the same hidden tests.

分数说明了什么

What the scores say

文章给出的数字(都是 OpenAI 自己的结果,我没找到独立复现):

  • MultiLangBench,最高推理强度:GPT-6 Astra 平均 87.4%,GPT-5.6 Sol 是 26.8%。20 种语言里有 19 种超过 83%,最难的 COBOL 是 72%。
  • GPT-6 Luna(更便宜的型号):平均 40.3%,每个样本约 $0.77,GPT-5.6 Sol 约 $3.48,便宜约 78%。
  • COBOL 迁移:GPT-6.1 Sol 低推理强度 86.6%,成本约为 GPT-5.6 Sol 的 61%;高推理强度到 97.9%,接近把这个评测做满。GPT-5.6 Sol 是 5.4%。
MultiLangBench 通过率(%):GPT-5.6 Sol → GPT-6 Astra(最高推理强度)COBOL10.9%72.1%OCaml25.6%85.8%Fortran21.4%83.5%Visual Basic27.5%89.4%GPT-5.6 SolGPT-6 Astra
图 2:四种低资源语言的通过率变化。浅色是 GPT-5.6 Sol,深色是 GPT-6 Astra。

我的看法:从 5.4% 到 86.6% 是一次大跳跃,但“接近做满”也意味着这个评测可能快没有区分度了。这点是我的推测,文章没这么说。

Numbers from the post (all OpenAI's own results; I found no independent reproduction):

  • MultiLangBench at maximum reasoning effort: GPT-6 Astra averages 87.4% versus 26.8% for GPT-5.6 Sol. It scores above 83% in 19 of 20 languages; COBOL, the hardest, is 72%.
  • GPT-6 Luna (the cheaper model): 40.3% average at about $0.77 per sample, versus about $3.48 for GPT-5.6 Sol, roughly 78% cheaper.
  • COBOL migration: GPT-6.1 Sol hits 86.6% at low reasoning effort at about 61% of GPT-5.6 Sol's API cost, and 97.9% at higher effort, close to saturating the benchmark. GPT-5.6 Sol scores 5.4%.
MultiLangBench pass rate (%): GPT-5.6 Sol → GPT-6 Astra (max reasoning effort)COBOL10.9%72.1%OCaml25.6%85.8%Fortran21.4%83.5%Visual Basic27.5%89.4%GPT-5.6 SolGPT-6 Astra
Figure 2: pass rate change in four low-resource languages. Light bars are GPT-5.6 Sol, dark bars are GPT-6 Astra.

My take: going from 5.4% to 86.6% is a big jump, but "close to saturating" also means the eval may soon stop telling models apart. That is my speculation; the post doesn't say it.

MultiLangBench 在 GitHub 上怎么跑

How MultiLangBench works on GitHub

仓库是 openai/MultiLangBench(Apache-2.0)。README 的要点:

  • 任务是让模型凭 SQLite 3.40.1 文档实现 SQLite。约 5.1 万条 TCL 测试里,约 2.4 万条被转成了评测格式。
  • 每条测试有三部分:initial_database、user_query、validation_query。验证查询在真正的 SQLite 3.40.1 上跑,输出必须与期望字符串完全一致。
  • 模型的程序接收数据库路径作为命令行参数,从 stdin 读 SQL。
  • 环境要求:放入文档、清掉环境里所有 SQLite 痕迹(仓库有示例脚本 scripts/remove_sqlite.sh,README 要求你自己再验证)、断网。
  • 标准评测用 272 条测试(名字以 00、01、02 开头);允许跑全集,但要注明。崩溃、输出不一致、超过 60 秒都算失败;没用指定语言,通过率记 0。

README 没写具体的运行命令,也没列出 20 种语言的名字,所以想复现要自己搭运行脚本。这点我没法替它补。

The repo is openai/MultiLangBench (Apache-2.0). Key points from the README:

  • The task is to implement SQLite from the SQLite 3.40.1 docs. Of roughly 51k TCL tests, about 24k were converted to the eval format.
  • Each test has three parts: initial_database, user_query and validation_query. The validation query runs on real SQLite 3.40.1, and the output must match the expected string exactly.
  • The model's program takes a database path as a command-line argument and reads SQL from stdin.
  • Environment setup: put the docs in, remove every trace of SQLite (the repo has an example scripts/remove_sqlite.sh, and the README tells you to verify it yourself), and block internet access.
  • The standard eval uses 272 tests (names starting with 00, 01 or 02); running the full set is allowed but must be noted. Crashes, mismatches and timeouts over 60 seconds count as failures; writing in the wrong language sets the pass rate to 0.

The README gives no run commands and doesn't name the 20 languages, so reproducing it means writing your own runner. I can't fill that gap for it.

你能借走什么

What you can borrow

  • 先固定“标准答案”。迁移前先在旧系统上录一批输入输出(真实流量、业务样例、边界值),再让 Agent 动手。
  • 验收只看输出。不要让 Agent 自己判断“我改对了”;让脚本逐字节比较,差异附上输入,方便人看。
  • 测试对 Agent 隐藏。评测里用的是隐藏测试,防止 Agent 为了过测试而写死答案。你自己的验收集也该和 Agent 能看到的示例分开。
  • 留意最容易错的地方。OpenAI 点名了定点数舍入。老系统里的金额、日期、字符串截断、补零规则,都值得单独写测试。
  • 断网、清环境。MultiLangBench 要求断网并删掉 SQLite,为的是防止模型直接调用现成实现。你做“从零重写”类任务时也要想清楚这一点。

以上是我从评测设计里总结的做法,不是 OpenAI 的官方建议。

  • Fix the answer key first. Before migrating, record a set of inputs and outputs from the old system (real traffic, business samples, edge values), then let the agent start.
  • Accept on output only. Don't let the agent decide "I got it right." Compare byte by byte with a script and attach the input to every diff so a human can read it.
  • Hide the tests from the agent. The eval uses hidden tests so the agent can't hard-code answers. Keep your own acceptance set separate from any examples the agent can see.
  • Watch the usual traps. OpenAI names fixed-point rounding. Money amounts, dates, string truncation and zero-padding rules in old systems deserve their own tests.
  • Cut the network, clean the environment. MultiLangBench blocks internet access and removes SQLite so the model can't call an existing implementation. Think about this for any from-scratch rewrite task.

These are my takeaways from the eval design, not official OpenAI advice.

还没弄清楚的

What is still unclear

文章没有公开 COBOL 迁移评测本身(只说了 MultiLangBench 的评测在 GitHub 上);所以 86.6% 和 97.9% 没法自己复现。测试集里的 COBOL 程序有多大、多复杂,我也没看到。

还有一点:评测的是“输出一致”,不是“代码好维护”。迁移出来的 Java 能不能让团队接手,是另一个问题。这篇文章没覆盖。

The post doesn't release the COBOL migration eval itself (only MultiLangBench is on GitHub), so the 86.6% and 97.9% figures can't be reproduced by you. I also didn't see how large or complex the COBOL programs in the test set are.

One more thing: the eval measures matching output, not maintainable code. Whether a team can take over the migrated Java is a separate question this post doesn't cover.

小词典

Glossary

低资源语言
训练数据和文档都少的编程语言,如 COBOL、Fortran。
隐藏测试(hidden tests)
Agent 看不到的测试,防止它为了通过测试而写死答案。
byte-for-byte
逐字节一致:连空格、小数位都必须相同。
定点数舍入
按固定小数位做的十进制运算,舍入规则和浮点数不同,迁移时容易出现一分钱的差。
推理强度(reasoning effort)
让模型想多久的档位,越高通常越准也越贵。
Low-resource language
A programming language with little training data and documentation, such as COBOL or Fortran.
Hidden tests
Tests the agent can't see, so it can't hard-code answers to pass them.
Byte-for-byte
Exactly identical output, down to spaces and decimal places.
Fixed-point rounding
Decimal math with a fixed number of places. Its rounding rules differ from floating point, so a migration can end up a cent off.
Reasoning effort
A setting for how long the model thinks. Higher is usually more accurate and more expensive.

来源

Sources

文中数字均来自这两个页面,是 OpenAI 自己的结果。我没有找到独立复现。以原文为准。

All numbers come from these two pages and are OpenAI's own results. I found no independent reproduction. Defer to the originals.