AI Coding Agents: Why Legacy Code Needs Context12 min read2,454 words

AI Coding Agents: Why Legacy Code Needs Context

See why AI coding agents drift in legacy code, how context changes results, and how to measure engineering ROI before scaling automation across your team.

AI coding agentsAI coding driftlegacy code modernizationAI coding ROIcontext engineering
AI Coding Agents: Why Legacy Code Needs Context

Why AI Coding Agents Drift in Legacy Code - and What to Do About It

AI coding agents can churn out code quickly - and still create more work than they remove. The problem shows up fast in legacy systems. An agent might access a repository, but not the internal libraries, conventions, and business rules that tell you what "good" looks like in your company. The patch can look reasonable in a pull request while forcing engineers to rewrite, replace, or undo parts of it.

A DesignVerse report on 15 private enterprise codebases puts numbers on this. In their tests, two coding agents reused approved internal components in 55% to 59% of tasks when they didn't have extra company context. DesignVerse's context-engineered system did so in 92%. Those numbers are eye-catching - but the comparison needs a careful read. The study isn't "same model, with vs. without context," and the productivity savings referenced come from a separate client case.

This article breaks down what the benchmark actually measured, why agents drift in the real world, how to assess whether the payoff is real, and how to run a test on your own code before rolling anything out broadly.

What did the AI coding drift report measure?

DesignVerse tested coding agents on 15 private enterprise codebases in aviation, banking, defence, software services and consultancy. The systems were 15 to 20 years old, exceeded one million lines of code, and were maintained by engineering teams of around 20 people. Most were written in Ada, C++ or COBOL - languages and environments that don't show up much in many public coding benchmarks.

The benchmark compared two widely used agents (Agent A and Agent B) against DesignVerse's own context-engineered system. The first two had full repository access in their standard setup, without custom rules or additional company context. DesignVerse's system used its own model and pulled in relevant code plus engineering and business documents for each call.

That distinction is the whole point - and also where people can overread it. This isn't an "is context worth it?" test that isolates context by running the same agent twice. It's more like "a typical agent setup vs. a context-engineered system." The results support the practical case for adding context, but they don't prove that context alone explains the gap. Model choice and other system differences could be part of the story.

The reported measures

A task counted as a failure if an agent invented an interface or library, or picked a public component when an internal one already existed. On that measure, the unmanaged agents used approved internal components in 55% to 59% of tasks. DesignVerse reported 92% for its system.

The report also looked at repeatability. When given the same task, the unmanaged agents produced the same answer 61% to 69% of the time. DesignVerse reported 97%. The benchmark used roughly ten tasks per codebase (with up to 40 for some systems). Tasks ranged from small refactors and unit tests to changes that spanned multiple systems. DesignVerse's CEO said some changes could take an engineer around 100 hours.

The report further notes that, without a context layer, agents read a median of ten tokens for every token of accepted code. One legacy-system measurement hit 150 to one. That ratio can be a useful clue about how much noise an agent is chewing through compared with what it outputs - but it doesn't, by itself, tell you about cost, quality, or time saved.

How much weight should you give the results?

DesignVerse and client engineers graded the work together using the report's published rubric. The teams received the same tasks, prompts, tool access, time limits, and grading process, according to the report. The company also discloses that all 15 organisations were working with or evaluating DesignVerse. That access made it possible to test on private code, but it's also why you should treat the findings as vendor-reported evidence rather than an independent, industry-wide study.

If you're an engineering leader, the useful takeaway isn't "you'll hit 92% too." It's that repository access by itself may not give an agent enough operational knowledge. A benchmark on your own code is much more informative than assuming a published number transfers cleanly to your environment.

Why do coding agents drift in legacy systems?

A repository contains source code, but it doesn't automatically contain the system. An agent can search files and still miss what's actually approved: which library is considered canonical, which interface is stable, how a subsystem is deployed, or which dependencies the team avoids for good reasons. In older systems, that knowledge often lives in design documents, tickets, build scripts, and - most importantly - the accumulated experience of engineers who've maintained the software for years.

That gap creates a predictable failure mode. The agent solves the local "how do I code this?" problem while violating a wider system constraint. It may add a new helper because it can't find the established one, pick a familiar public package instead of an internal library, or create an interface that looks fine on its own but doesn't play nicely with downstream services.

Local plausibility is not system fit

AI-generated code can pass a narrow review and still be wrong for your organisation. A unit test can pass even if the implementation duplicates something you already have internally. A function can compile while using a pattern the team won't safely deploy. In regulated environments, the missing context may include security controls, audit requirements, or operational restrictions - not just style preferences.

So "the agent can see the codebase" isn't enough as a readiness check. Access tells you the model can retrieve files. It doesn't prove it can find the authoritative implementation, tie documentation to the current code, or separate "rules we still follow" from "rules we stopped using."

Repeatability matters for the same reason. If the same request produces materially different implementations, planning review and testing gets harder. Engineers then have to check not only whether it works, but whether the variation is acceptable under the team's conventions. That's manageable for a small script. It's far more consequential when changes cross systems multiple teams rely on.

Why a context layer can help - and where it can fail

A context layer can pull in relevant internal code and documentation for a task, giving the agent more than broad repository access. But the value depends on what it indexes, how it ranks results, and whether it stays current. If retrieval is poor, you get stale guidance - or the one interface the agent needs never shows up in the prompt. More context isn't automatically better context.

Teams also have to account for the work required to build and maintain the layer: access controls, documentation cleanup, indexing, evaluation, and ownership. A context system isn't a one-time switch. It becomes part of your engineering environment, and it needs a real process for keeping its knowledge aligned with the codebase.

So the question isn't "is context useful?" It's whether a specific context system helps agents choose approved patterns more reliably on your representative tasks - without adding enough operational overhead to wipe out the benefit.

How should you assess the ROI of AI coding agents?

Start with what actually lands in production, not the number of lines an agent generates or the number of prompts it answers. The business value comes from completed and accepted changes that would otherwise consume engineering capacity. If developers spend "saved time" fixing generated code, reviewing avoidable alternatives, or rebuilding missing context, then gross output is a misleading measure.

DesignVerse reported a 12-month client case separate from its benchmark. Without a context layer, the work involved nine developers and 9,600 hours. With one, it involved five developers and 4,000 hours - reported as a reduction of 5,600 hours (58%). They valued those hours at about $882,000 using a blended rate of $157.50, derived from a $1.5 million labour bill.

That estimate is better read as the value of freed capacity than as guaranteed cash savings. The company said no one lost a job; the time moved to backlog work. Their calculation also excluded platform, licensing, and token costs, along with the cost of building the context layer. At $120 per hour, the same 5,600 hours is about $672,000; at $200 per hour, about $1.12 million.

Separate capacity value from cash savings

If the team keeps headcount and uses saved time to deliver more work, the result might be faster delivery or reduced backlog - not a smaller payroll. That can still be valuable, but it should be reported honestly. Cash savings, avoided hiring, increased throughput, and improved quality are different outcomes. Bundling them into a single headline number tends to hide what you're actually getting.

Net value = value of accepted work or capacity released − agent and model costs − context-system costs − added review and rework.

Estimate each piece over the same period. Include implementation and ongoing maintenance costs, not just usage charges. Then compare AI-assisted work to a baseline: similar tasks done by engineers without the agent. Without that comparison, teams can mistake normal productivity swings for an AI effect.

Measure the work that absorbs hidden costs

Track time to accepted changes, rework hours, review time, defect rates, and how often the agent picks approved internal components. Also note task difficulty and whether the work crosses system boundaries. Averages can hide the places where the agent is genuinely useful - or where it consistently creates risk.

This matters more as companies expand coding-agent use. A 2026 Qodo report cited in the source found that 90% of US engineering leaders were confident reporting AI's impact to their board, while 45% could trace AI activity back to the code it produced. The gap points to a basic operational requirement: connect agent activity to reviewed and merged work before you claim a financial result.

How can engineering teams test coding agents safely?

Run a controlled evaluation on a small set of representative tasks before broad deployment. You don't need a giant benchmark to tell whether an agent helps, but you do need a fair comparison and enough detail to see what breaks. DesignVerse says its report includes a two-week test teams can run on their own code with any model. The underlying idea is simple: test against your constraints, not a vendor's ideal workflow.

Build a practical evaluation set

Pick tasks that look like your real engineering work - not just demos that are easy to finish. Include a mix of:

  • Small changes, such as tests, refactors or straightforward bug fixes.
  • Tasks that require finding and reusing an internal library or interface.
  • Changes that touch more than one service or subsystem.
  • Work with meaningful security, deployment or compliance constraints.

For each task, capture the expected internal components, acceptance criteria, time limit, and required tests. Use the same prompt, permissions, and review standard for each agent setup. Keep a human reviewer who knows the system; "passing a benchmark" shouldn't mean removing normal code review.

Score outcomes, not just generated code

Use a scorecard that checks whether the change builds and passes tests, whether it uses approved internal components, how much rework is needed, how long review takes, and whether the results hold up across runs. Treat security and policy violations as explicit failure conditions. For production systems, "it compiles" isn't partial success if it bypasses an approved control.

Also test the context layer itself. Verify it retrieves the right source of truth, whether document age shows up clearly, and whether access boundaries are enforced. If the system can't point to which internal guidance informed a suggestion, reviewers will struggle to debug and govern the outcome. Context retrieval should be transparent enough to support real troubleshooting.

Set a threshold before you scale

Decide up front what qualifies as a pilot or rollout. For example: require faster time to accepted changes without more defects or rework, and set a minimum reuse rate on tasks where reuse is expected. The exact threshold depends on risk. A low-risk internal tool can tolerate more experimentation than a banking or aviation environment.

Then slice the results by task type. If the agent helps on tests but keeps inventing interfaces across services, deploy it for the former and either tighten controls or limit it for the latter. You don't have to go all-or-nothing. Common safety controls include limiting permissions, requiring approval for dependency changes, and keeping agents away from high-impact files unless you have evidence they can operate safely.

Key takeaways: repository access is not the same as company context; vendor benchmark figures should be read alongside methodology and incentives; and ROI should account for accepted work, rework, review, implementation, and operating costs. Scale only when your own evaluation shows a durable advantage.

Conclusion

AI coding agents don't become reliable enterprise contributors just because they can read a repository. They need the right engineering and business context, and teams need a way to verify that the change fits the system they actually operate.

The DesignVerse findings raise a solid question about unmanaged agents, but the comparisons and ROI numbers should be treated as evidence to investigate - not guarantees you can import into your own business case. Run a controlled test on your code, account for costs outside the benchmark, and scale by task type. If an agent "saves time" only to spend it on repair, then the deployment isn't delivering the result you paid for.

Frequently Asked Questions

AI coding drift is when an agent produces code that departs from an organisation’s established components, interfaces or engineering rules. The output may be syntactically correct while duplicating functionality, choosing an unapproved dependency or creating extra review and repair work.
No. The report compared two agents in standard setups with a separate DesignVerse system that used its own model and a context layer. Because the models and systems differed, the results do not isolate context as the sole cause.
Not necessarily. DesignVerse valued 5,600 hours of released capacity using a blended labour rate. The company said the time was redirected to backlog work. The estimate excluded costs such as the context layer, licensing, platform and token usage.
Select representative tasks, define acceptance criteria and compare setups under the same prompts, permissions, time limits and review rules. Measure accepted-change time, rework, review effort, internal-component reuse and defects. Begin with a controlled pilot and expand only where results justify the cost and risk.

Related articles