Rebuilding legacy code with AI: one agent beats 120,000 lines of prompts

Kakaku.com is using AI to rebuild 9.6 million lines of legacy code, and it has just published an interim report. A single agent running Opus 5.5 beat an elaborate 110-agent workflow at a tenth of the cost. Tencent took almost the opposite approach and also succeeded. We compare reports from Japan, China and the US and look at what these rewrites cost and where they get stuck.

Analysis Nov 29, 2026 12 min read Original analysis by our editors
Illustrative image, AI-generated

What this is about

Having AI rewrite ancient software from scratch is the big promise in IT departments right now. Three recent field reports show what that looks like in practice. They come from Japanese price comparison site Kakaku.com, from China's Tencent and from Cisco in the US. On November 26, 2026, Kakaku.com presented an interim report at Japan's Architecture Conference 2026. The slides are only available in Japanese so far. The results aren't what you'd expect: the most elaborate rulebook delivered the worst result. Tencent, meanwhile, succeeded with almost the opposite approach. We put the cases side by side and ask what a rewrite like this costs, where it stalls and why the recipes differ so much.

Kakaku.com: 9.6 million lines and a slipped deadline

Kakaku.com runs the price comparison portal Price.com. The system is about 30 years old and consists of roughly 8 million lines of C# and 1.6 million lines of Classic ASP, a Microsoft web technology from the late nineties. According to the June slides, it spans 752 repositories, 1,353 screens, 498 batch jobs and 13,210 database tables. The project is called "DODAI" ("Debt Of Decades + AI"). The new stack is Python, FastAPI and htmx. Features, business logic and the database schema are meant to stay essentially the same.

Here's where things stand, according to the November slides from CTO Takayuki Kyowa and team lead Mitsuru Tokita:

  • 2,643 of 3,723 URLs (about 70 percent) have gone through the AI workflow. Humans are now fixing them up.
  • The first category went live in September 2026. The slides don't say which one or whether there were bugs.
  • Everything is now supposed to be done by September 2027. In June the target was still May 2027, in time for the company's 30th anniversary. The company says that after six months of real-world experience it can now estimate the effort more accurately.

110 agents versus 2

In June, the workflow consisted of 71 subagents, AI instances that each have a fixed role, spread across five phases. They were orchestrated by a harness, a scaffold of prompts, scripts and checks. By November, that scaffold had grown substantially: from 75,000 to about 120,000 lines of prompts, from around 50 to about 200 scripts, and from 71 to 110 agents. Then the team took a step back. It had an internal admin system with 19 screens and 21 URLs rebuilt three times.

Workflow (Opus 4.6) Autonomous agent (Opus 5.5) Autonomous agent (Opus 4.6)
Prompts / scripts / agents ~120,000 / ~200 / 110 ~5,000 / ~20 / 2 same as left
Internal E2E tests 514/520 (98.8%) – –
External behavioral tests 32/65 (49.2%) 65/65 not measurable (DB connection failed)
Runtime ~66 h ~3 h 56 min ~2 h 25 min
API cost ~$2,123 ~$196 ~$155

E2E (end-to-end) tests check an application from the outside, the way a user would operate it. The difference lies in who does the checking. In the workflow, the builder and the reviewer saw the same spec, so they were testing against their own template. In the autonomous approach, the agent only gets goals, constraints and acceptance criteria. It's graded by an external evaluator whose criteria it can't see. The evaluator checks the appearance, hidden URLs and requests, the values that forms submit, and whether the agent did anything forbidden. It found no violations in either autonomous run.

Do the math and the agent was about 17 times faster and 11 times cheaper than the workflow, using a twenty-fourth of the prompts. One Hatena commenter summed it up: 32 of 65 measured from the outside, 98.8 percent from the inside, "the self-evaluation trap."

Why the heavyweight rulebook lost

The slides give several reasons:

  • Gaps in the spec: The workflow first wrote a spec from the legacy code and then built from that spec. Anything lost in the first step was missing from the final product, and the internal tests had no way of noticing. The agent, by contrast, read the old code and the old screens directly.
  • The harness no longer fit the model: Many parts of the harness were built to compensate for weaknesses in Opus 4.6. The newer Opus 5.5 dutifully followed every one of those steps and ended up over-checking. When the team swapped Opus 5.5 into the running workflow, API costs rose 1.4 to 2 times. After a few days, it went back to the old model. Of five countermeasures from June, three became redundant with Opus 5.5: the three-tier agent hierarchy, the rigidly structured specs and the step-by-step verification. What stayed was the automated final check and a reworked E2E fix loop.
  • Three traps that slowed the rollback: New models were first tried inside the old workflow. On top of that came sunk costs and reluctance to halt a running production line.

This matches Anthropic's own guide to harness design. It says every component of a harness encodes an assumption about what the model can't do on its own, and those assumptions go stale. Anthropic also observes that agents grade their own work "reliably too positively."

An important caveat: the slides themselves say the comparison covers only a single small system. Whether it holds for image-heavy pages or batch jobs with no UI is an open question. It's also not entirely fair, since the workflow ran on Opus 4.6 and the winner on Opus 5.5. The autonomous approach with Opus 4.6 couldn't even get the application running. Our take: a large part of the success comes from the newer model, not just the leaner approach. For the 70 percent already done, the comparison has uncomfortable consequences: those pages will now also be graded by the external evaluator. Depending on the outcome, they'll be patched or rebuilt entirely.

Tencent: hands off the legacy code

Tencent rebuilt an internal video editing tool. It had about 900,000 lines, barely any documentation, almost no tests and a single component of more than 6,000 lines. According to the original report on the 腾讯技术工程 (Tencent Engineering) channel, two to three developers took over the project in March 2026. The first test version shipped at the end of June. By the end of August, the new system consisted of about 120,000 lines of code, around 150,000 lines of documentation and more than 6,000 tests with 86 percent coverage. In the old system, not even three change requests could be implemented in half a year; in July and August, more than 30 new features were added.

Unlike at Kakaku, the AI was not allowed to port the legacy code. The old program served only as a description of what the software should do. Otherwise, the reasoning went, the AI would carry the old mess over. This was safeguarded by review steps that the Qiita translation groups into four "gatekeepers":

  1. Review before any code is written: Requirements, acceptance criteria and design are reviewed, with criteria tied to measurable thresholds.
  2. Locked thresholds: Test coverage targets live in a separate file. If the AI changes them, a human has to approve. Before this, the AI had simply rewritten vague targets to pass the check.
  3. Automated review: Eight specialized review agents each look at the code with a fresh context. A Python program tracks project state so the AI can't mark work items as done by itself. On top of that come mutation tests: the code is deliberately broken in small places, and the tests have to catch it.
  4. Human sign-off: People read the requirements, designs, the code for the most important flows and the acceptance reports.

According to the author, the mutation score (the share of injected bugs caught) was about 50 to 60. For comparison, he cites 20 to 40 for typical AI-written tests and 60 to 80 for human-written tests. Mutation testing is expensive: a test run that normally takes a minute takes more than 30 minutes with it. That's why it ran only on changed parts.

Cisco: big goal, no yardstick

According to Fortune on October 30, 27-year-old Padmanabhan Krishnamurthy is supposed to rewrite 98 percent of Cisco's legacy code within 24 months, with two people and an unlimited token budget. President Jeetu Patel is quoted as saying:

"I gave him unlimited tokens because he's going to rewrite code."

Krishnamurthy has four weeks to prove the approach works. Which products are affected and how the work will be verified isn't stated anywhere. In the Hacker News discussion, people from the networking industry point out that many bugs only show up with specific combinations of hardware and software versions. Vendor bugs, quirks in interoperating with third-party gear and hard timing constraints can't be caught after the fact by any test if they were never written down. The State of AI reaches the same conclusion: code is cheap; what matters is proof that it behaves the same.

What a rewrite costs and where it stalls

Project Scope Effort / cost (per source)
Kakaku, insurance category (May) 88 screens, 36,194 lines of Python 134 h, $6,921 API (~$79 per screen)
Kakaku, comparison system 21 URLs Workflow ~$101/URL, agent ~$9/URL
Kakaku, ongoing – ¥4.4 million per month in AI fees for developers (roughly €25,000)
Bun (Zig → Rust), per Anthropic ~1M lines ~$165,000 at API prices
Tencent 900,000 → 120,000 lines 2–3 people, ~6 months; no cost figures
Cisco "98%" 2 people, unlimited tokens, 24 months (target)

For comparison, a thought experiment rather than a forecast: if each of Kakaku's 3,723 URLs cost as much as in the test, that would come to about $35,000 with the agent and about $376,000 with the workflow. So compute isn't the problem. The slides don't say how big the team is or what the project costs overall.

The June figures on code shrinkage are worth double-checking. For the insurance category, the slide talks about a "43.4% reduction." But the table shows a ratio: 43.4 percent of the actual application code remains (29,505 instead of 67,931 lines), which is a reduction of about 57 percent. For credit cards it's minus 34 percent; for water dispensers it's plus 10.5 percent.

Three problems come up in every report:

  • Hidden business rules: At Kakaku, they got lost through the spec. At Tencent, the AI filled gaps with "typical" solutions instead of asking, for example around timeouts or missing fields in old data. Forrester analyst Biswajeet Mahapatra writes: "Behavior is not intent." Only humans can explain why a rule exists.
  • The database: For 26 simple queries in a row, Python with SQLAlchemy took 18.66 milliseconds, .NET just 4.44 milliseconds. SQLAlchemy is an ORM, a tool that translates database access into application code. It triggered 68.5 instead of 26 roundtrips per request (trips to the database and back). With custom optimization, that dropped to 5.55 milliseconds. Python with PostgreSQL and an async driver managed 1.52 milliseconds. Under load, a gap of roughly 2x remained. Whether the company will switch databases is open. The lesson from the slides: benchmark your language-and-database combination early.
  • Tests the AI writes itself: At Kakaku, that was the 98.8 percent internal pass rate; at Tencent, it's why mutation testing was needed. We already reported on Anthropic's Rust rewrite and how far passing tests and real behavior diverged there.

Why the recipes contradict each other

At first glance, Kakaku says "read the legacy code" and Tencent says "don't touch it." But their goals differ. Kakaku wants to rebuild a large portal as faithfully as possible, with the same database and the same business logic. Every intermediate translation loses information. Tencent wanted to free an internal tool with few users from its baggage and extend it quickly. For that, you have to redefine what the software should do anyway.

On one point, everyone agrees: whoever writes the code must not also sign it off. At Kakaku, that's the external evaluator with hidden criteria; at Tencent, it's locked thresholds and mutation testing. Anthropic recommends testing the evaluator against deliberately broken code first. Thoughtworks requires that every rule derived from legacy code be traceable to a file and line.

The bigger picture

Our take: The Kakaku slides are valuable because they reveal what hardly anyone else shows: a slipped deadline, a rolled-back model upgrade and a rulebook that turned out to be a liability. The comment "12,000 … sorry, 120,000 lines of prompts as the new debt" from the Togetter roundup hits a sore spot. A harness tailored to one model goes stale with the next. But the evidence is just one comparison on a single system, with 65 tests and two different models. Whether the lean agent performs as well across 3,700 URLs remains to be seen.

The most important takeaway from all three cases is unspectacular: generating code has become cheap, verifying it hasn't. Tencent took that seriously and has numbers to show for it. Cisco has so far only announced a goal. If you're planning a rewrite like this yourself, build an independent evaluator first, and only then unleash the agents.

#legacy-code#ai-agents#software-development#tencent#claude-opus#migration

Ask the AI assistant

Questions about this article, installation or background? Our assistant knows this page and runs on our own machine, not in someone else's cloud.

Connecting …

The Assistant is an AI (Gemma 4) and can make mistakes – please check important details against the source. Questions are used only to generate an answer and are deleted after one hour. Please don't enter any personal data.

Comments

What do you think? Already tried it? Write it here, no sign-up needed.

  1. Loading comments …

Comments are public. Links aren't allowed, and we delete abusive posts. You can delete your own comment at any time in this browser. Learn more in the Privacy Policy.