Old systems

Can an AI agent read old code?

Yes, and quickly. It also gets some things wrong with confidence, so an engineer checks its map against the running system.

By the duyan team · Updated · 4 min read

Old systems

In short

  • A coding agent reads old code faster than a person, and drafts a useful map of it.
  • It also fills gaps with plausible guesses, stated as facts.
  • Much of a system lives outside the code, where an agent can't see it.
  • Treat the agent's map as a draft until an engineer checks it against the running system.

Our view

An AI coding agent is now the fastest way to draw a first map of an old system. It reads code nobody has opened in years, and explains it in plain words.

It also gets things wrong with confidence. So we treat its map as a draft, and an engineer checks each claim against the running system.

What models do well

A model reads quickly and doesn't tire. It can go through thousands of files, then summarise what each part does and what calls what.

Old languages are less of a barrier than many expect. In our work, models explain old PHP and Visual Basic well enough to start from.

Research backs this up. In a 2024 study, researchers asked models to comment old code line by line.

The code was a health records system in MUMPS, and mainframe programs in assembly. The assembly was harder for the models.

Overall, their comments were mostly accurate, complete and useful. They compared well with comments people had written.

A model also drafts the documents nobody wrote. These include a list of screens, the tables each one touches and the rules buried in the code.

Where they get it wrong with confidence

A model fills gaps with what sounds likely. When it can't see how something works, it may describe how such things usually work.

Package names show how far this goes. A study published in 2025 generated 576,000 code samples from 16 models.

On average, at least 5.2% of the packages that commercial models suggested didn't exist. For open-source models, the figure was 21.7%.

Those were made⁠-⁠up names that looked right. Old code invites the same slip. A model may describe a function from its name, without checking what the code inside does.

Large systems add a second problem. A whole codebase rarely fits into one request.

So the agent reads it in pieces, and may miss a link between them.

Long inputs carry a risk too. A 2023 study by Nelson Liu and colleagues tested this. Models used the start and end of a long input better than the middle.

What the code doesn't show

Much of an old system lives outside its code. An agent reading the repository won't see:

  • settings on the live server, and secrets it reads when it starts
  • scheduled jobs set up by hand on the server
  • logic inside the database, such as triggers and stored procedures
  • other systems that call this one, or that it calls
  • data that breaks the rules the code assumes
  • code that's in the repository but never runs, or runs but isn't in the repository

A model also can't tell which odd behaviour the business relies on. A rounding quirk may be a bug, or the way your accountant expects the figures.

How an engineer checks the map

The check is plain work. An engineer takes each claim on the map and tests it against the system.

They run a request and watch what happens. They read the logs and the database, and compare both with the map.

They pin down current behaviour with tests that record what the system does today, odd parts included. These tests then guard every later change.

They ask the people who use the system where it surprises them. Each claim on the map is then marked as checked or still unchecked.

When we'd lean on it less

Some systems give the agent too little to work with. If there's no copy you can run, and no data to compare, the map stays a well-written guess.

Code that moves money or affects safety needs more checks. The agent still helps with the reading, and people make more of the calls.

Some logic lives in a vendor product's settings, outside any code you hold. There, the people who configured it know more than the code does.

What to ask whoever maps your system

  • Which claims on the map were checked against the running system, and how?
  • What did the agent read, and what did it skip?
  • Does the map cover scheduled jobs, server settings and the database?
  • Where does the code disagree with what your team says the system does?

A good map answers these in writing. It also tells you which parts are still unknown.

Start with the map

We map what the old code does, then move it one part at a time while it keeps running.

Sources

  1. Colin Diggs and others, "Leveraging LLMs for Legacy Code Modernization: Challenges and Opportunities for LLM⁠-⁠Generated Documentation", arXiv:2411.14971, November 2024, arxiv.org (accessed 5 November 2026)
  2. Joseph Spracklen and others, "We Have a Package for You! A Comprehensive Analysis of Package Hallucinations by Code Generating LLMs", 34th USENIX Security Symposium, 2025, arxiv.org (accessed 5 November 2026)
  3. Nelson F. Liu and others, "Lost in the Middle: How Language Models Use Long Contexts", Transactions of the Association for Computational Linguistics, arXiv:2307.03172, arxiv.org (accessed 5 November 2026)

Tell us the job

Bring a job to build or a role to fill. We reply within one working day, with questions or a next step.