Jarred Sumner: Independent Tests Made Millions of Agent-Written Lines Shippable

Bun’s creator explains why existing tests, three-way comparisons and repeated measurement mattered more than code volume.

JSJarred Sumner登壇者 · Anthropic
チャンネル
AI Engineer
公開日
2026年11月24日
動画
22:29
読了時間
6 分
スライド
3
原文
英語
YouTube で開く
スクロールすると動画は右下に小さくなって再生を続けます。字幕は閲覧言語に合わせて切り替わります。
閲覧言語2 言語で読めます
この記事はまだ日本語に翻訳されていないため、英語の原文を表示しています。
要約

30 秒でわかる

Bun creator Jarred Sumner says the way to trust a large agent-built compiler was to test it against software and test suites that existed before the project. His team compared three execution modes, fuzzed for differences and rewrote the compiler five times when performance or build speed fell short. The result, he says, used about four times less memory and started Claude Code twice as fast in internal use. He chose to speed up JavaScript instead of rewriting Claude Code in Rust because porting its tests would weaken the comparison.

  1. 1A Rust rewrite would have required rewriting the tests tooBun’s TypeScript tests could check both its Zig and Rust implementations. Claude Code’s tests would need porting, so Sumner chose to make JavaScript faster instead.
  2. 2The internal build used about four times less memorySumner says the ahead-of-time compiler also made Claude Code start about twice as fast in internal testing.
  3. 3Tests older than the project provide an independent checkThe team reused Bun, WebKit, Test262 and Claude Code tests, then compared the output of three ways of running the same program.
  4. 4Write a large batch, then compile and repair itSumner delays repeated builds during the initial burst and follows with compilation and test fixes. He says much of the millions of lines is test code.
  5. 5A 50-second build triggered another rewriteDespite acceptable runtime performance, the fourth version compiled too slowly; the fifth brought build time below 20 seconds.
  6. 6Hourly scorecards exposed regressions during the buildLong-lived agents worked on parts of the compiler while regular comparisons showed how priority metrics changed.

ポイント

  1. Choose projects whose results can be checked against independent tests that already exist.
  2. Compare the same program across implementations and use generated cases to expose discrepancies.
  3. Track build time, runtime and correctness throughout; a faster program can still be too slow to compile.
  4. Keep agents on long-lived tasks when retaining code context saves repeated work.
  5. Verify that tests actually catch failures and remeasure performance as the project changes.
全文

チャプターごとに整えた全文を読む

文字起こしのみ
01

Why Bun needed a compiler before execution

Sumner says compiling JavaScript during execution costs substantial CPU time. The team built a compiler that does more work ahead of time and rewrote it five times.

I recently merged a pull request containing several million lines of code to add an ahead-of-time compiler to Bun, the JavaScript runtime that powers Claude Code. Rather than compiling code as the program runs, this compiler does the work beforehand. The question was how to ship such a large body of agent-written code with confidence.

The initial request was to make Claude Code faster and use much less memory, with permission to change Bun or WebKit, whose JavaScriptCore engine Bun uses. Over a little more than a month, the compiler went through five rewrites; I nearly shipped one version before realizing that it took too long to build.

How you can verify the result constrains a large project more than the particular implementation you choose. The first question is how to establish that the code works and is not buggy, because that determines which approaches can be trusted.

For a typical JavaScript application, I estimate roughly half of CPU time can be spent compiling code on demand. That overhead matters especially when many Claude Code sessions run at once. Ahead-of-time compilation moves work out of the running session instead of compiling as execution proceeds.

02

Keep the tests when changing the implementation

Rewriting Claude Code in Rust would have required porting its tests. The team instead accelerated JavaScript and checked results against existing suites.

We considered rewriting Claude Code in Rust, but chose not to. Bun was suitable for a Rust rewrite because its tests were written in TypeScript and could run against both the old Zig version and the Rust version. Claude Code’s own TypeScript tests would have needed porting, making them less trustworthy as an independent check.

The memory target given to Claude Code
スライド 1 / 3The memory target given to Claude CodeThe prompt asks for a substantially smaller Claude Code startup footprint using ahead-of-time compilation.

Instead, we tried making JavaScript faster so Claude Code would not need a Rust rewrite. In our internal use the result used about four times less memory and started about twice as fast. The compiler was being tested internally and was due to reach external users soon.

One comparison involved the TypeScript 7 compiler, which was manually rewritten from JavaScript and TypeScript into Go. Sumner says its single-threaded JavaScript version compiled by Bun ran faster than the single-threaded Go port in the comparison he showed; the ahead-of-time compiler did not yet add threads.

TypeScript annotations do not have to be correct, so the compiler treats types as predictions rather than facts. It can make a faster direct field access when it can establish the relevant type behavior, and otherwise must check at runtime.

Existing tests are particularly valuable because they predate the project and its agents. We could use Bun’s own tests, WebKit tests, the JavaScript conformance suite Test262 and Claude Code’s tests, and run Bun’s test runner in the new compilation mode as well.

The compiler has two intentional breaking changes, mostly related to security and prototype pollution, which also help performance. I separate those known differences from unexpected failures rather than assuming every existing test must pass unchanged.

03

Compare three versions and fuzz for differences

The compiler runs programs in three modes and compares their behavior. Agent-generated cases add coverage, while batching helps limit repeated builds.

Compare the same program three ways
スライド 2 / 3Compare the same program three waysThe slide shows the just-in-time run and two ahead-of-time builds, with and without TypeScript types, producing the same output.

We can run an application three ways: through the ordinary just-in-time compiler, through the ahead-of-time compiler with TypeScript types, and through the ahead-of-time compiler after removing types. If all three behave alike, that is evidence for that application. Claude can also generate programs for fuzzing, which tries many patterns to find discrepancies.

Most of the code volume is tests, and five rewrites also contributed to the total. My approach is to write a large batch first, then fix it: make it compile, run tests and check that it really works. During the initial burst, repeated builds can waste time, so I prefer to build once after the batch.

04

Five rewrites traded runtime gains against build speed

Early versions improved memory and startup but had code-quality or compilation-time problems. The fifth built in under 20 seconds, Sumner says.

The first compiler leaned heavily on existing JavaScriptCore code and produced a Claude Code build that used about a gigabyte of memory. Later we added a TypeScript type checker to Bun and asked Claude to use it; startup improved about twofold and memory use fell by roughly threefold, but the generated code still had unacceptable design problems.

One example treated any access to a property named archive as potential use of Bun’s archive API. I looked at it and decided we could not ship it. I also found that large planning exercises could produce an unreasonable number of Markdown files, including 1,500 documents.

For the third compiler iteration I used 140 agents at once to write code in parallel and then get Claude Code running. The fourth version produced good code with similar runtime performance, but compilation took about 50 seconds for Claude Code; even single-digit waits for smaller projects were too long for users accustomed to JavaScript.

The fifth rewrite brought the build time below 20 seconds and produced code I considered shippable. Another rewrite remained possible later. I cautioned that a model can size up an idea incorrectly and persuade itself not to pursue it; some ideas might deserve another attempt.

05

Long-lived agents and hourly measurements

Sumner describes agents that retain context, scorecards and fuzzing. He also identifies interpreter-heavy programs where the compiler may not be faster.

My earlier Bun workflow leaned heavily on Claude Code workflows. With newer models, outside the initial burst of writing, I mostly use long-lived subagents. They retain relevant code in their context and can keep working without repeatedly rebuilding that context.

An hourly update to track progress
スライド 3 / 3An hourly update to track progressSumner used a recurring agent update to keep track of metrics in Slack.

A project this large can be difficult to follow, so I asked for an hourly scorecard with the metrics we cared about. Slack updates compared the previous result with the current one, making it easier to see whether numbers improved or regressed.

Most of the tests were not invented by the agent during this project. We extended an existing V8 JavaScript engine fuzzer to cover TypeScript types as well, and I stress that a team also has to check that its tests actually detect failures; a test that never finds bugs can create false confidence.

On the benchmarks I showed, ahead-of-time compilation generally beat the just-in-time version, but not always. Programs that frequently rely on the interpreter, such as through eval or dynamically created functions, can be slower. The compiler also bans assignments to Object.prototype, a change intended to prevent a class of prototype-pollution vulnerabilities.

06

The human job is to question and remeasure

Sumner steers agents with questions and checks benchmark results. He emphasizes test quality, frequent measurement and ambitious targets.

What do I actually do all day? I often tell agents to continue, but also ask leading questions: why are we doing this, can we do it differently, and what is taking so long? Models can invent restrictive rules or underestimate what they can accomplish, so I push them to investigate further.

In the JetStream 3 JavaScript benchmark, I showed Bun outperforming JavaScriptCore’s and Node.js’s just-in-time engines on most tests. Throughout the work, Claude Code helped build Bun’s compiler, and we used a Claude Code build produced by that compiler.

For a large agent project, testability comes first, and the tests themselves must be checked. Keep measuring actively: with so much changing, it is easy for performance to regress without anyone noticing. Before a project ships, a rewrite can sometimes be easier than refactoring.

I also encourage the models to pursue ambitious improvements. Without repeated nudges, they may settle for tiny gains when larger ones could be possible. Sumner says the compiler can be tried through Bun’s canary release and its compile command.

同じチャンネルの記事

21:22EN
AI Engineer· 2026年11月24日Steve Yegge's software factory hit a human bottleneckSteve Yegge · Gas TownHis game-building agents produced more changes than players could absorb, while cost, accumulated context and stalled tasks demanded active management.ソフトウェアファクトリーAgent orchestrationコーディングエージェント+2
スライド 3 枚20:24EN
AI Engineer· 2026年11月23日Dex Horthy: software factories still need people to review the workDex Horthy · FactoryFaster agent-written code needs checks, proportionate planning and human review, especially when a codebase must remain maintainable.ソフトウェアファクトリーコーディングエージェントSoftware engineering+2
スライド 7 枚19:56EN
AI Engineer· 2026年11月22日Armin Ronacher: Build a Software Workshop Before a FactoryArmin Ronacher · EarendilAgents can start projects faster, but human attention still limits which ones become good and stay maintained.コーディングエージェント開発ワークフローとテストHuman-AI Collaboration+2
スライド 7 枚56:08EN
AI Engineer· 2026年11月21日Ahmad Osman: Local AI Needs Better Systems, Not Just Better ModelsAhmad Osman · OsmanticThe Osmantic founder explains how hardware, tools and task-specific tests determine whether local AI is useful.AI cost & performanceモデルと学習AI agents+2
スライド 3 枚14:28EN
AI Engineer· 2026年11月20日Zach Bruggeman: Ramp Made Its Coding Agent a Shared Team ToolZach Bruggeman · RampRamp made agent sessions visible to colleagues, spreading working practices and giving reviewers evidence for changes.コーディングエージェント開発ワークフローとテストCompany Culture+2
スライド 6 枚18:30EN
AI Engineer· 2026年11月20日Zach Lloyd: Treat Coding Agents as a System You Can Measure and ImproveZach Lloyd · WarpWarp’s founder argues that teams can improve coding agents by recording their work, testing changes on real tasks and measuring cost and quality.コーディングエージェントエージェント工学評価(Evals)+2