Reverse-Engineering Legacy Software with Long-Running AI Agents: A Complete Engineering Practice
Losing the source code of a legacy application once made modernization nearly impossible. This article walks through a real-world practice of using long-running AI coding agents to reverse-engineer and rebuild legacy software—illustrated by rewriting an early real-time strategy game. It covers phased planning and continuous autonomous execution, reverse-engineering private binary formats, handling magic constants, license compliance pitfalls, the agent's "reference" behavior around existing implementations, and practical risk-control strategies for putting this approach into production.
1. The Problem: When the Source Code Is Lost, Reconstruction Is the Only Way Out
Over the long lifecycle of software engineering, one special scenario keeps recurring: the source code of a classic piece of software (for example, an early real-time strategy game, an industrial control program, or an embedded system) has long been lost, leaving behind only the executable binaries and a large volume of proprietary data formats. If the team wants to run, maintain, or further develop the software on modern platforms, there is often only one path forward—reverse engineering and rebuilding it.
This type of task has three typical difficulties:
- Closed formats: Proprietary binary formats lack public documentation, and no mature parsing libraries are available;
- Complex behavior: Core logic (rendering, combat, physics, network synchronization) is tightly coupled and hard to untangle;
- Long cycles: A full rewrite can easily reach tens of thousands of lines of code, requiring enormous human effort.
In recent years, AI coding agents capable of long-duration autonomous execution have opened up new possibilities for this kind of task. This article uses “using an agent to reverse-engineer and rewrite an early real-time strategy game” as a practical thread, and distills a transferable engineering methodology from it.
2. Long-Running Agents: From “Conversation” to “Continuous Construction”
Traditional AI-assisted programming works in a question-and-answer interaction mode, whereas rebuilding legacy software requires the ability to execute continuously, autonomously, and in an interruptible, resumable fashion.
In practice, one workable approach is to have the agent first produce a phased plan spanning several weeks, then execute it almost non-stop, producing hundreds of code commits per day. Since commits arrive far faster than humans can review line by line, the focus of verification must shift from “reading every line of code” to “checking runnable results and automated tests”.
A simplified phased plan looks like this:
Phase 1 Pre-Alpha: Build the project skeleton and format parsing layerPhase 2 Alpha: Complete all UI and interactionsPhase 3 Beta: Implement core gameplay and logicPhase 4 Multiplayer: Network synchronization and battles
This “plan first, then execute continuously” model breaks an unwieldy mega-project into verifiable milestones, and it is the key prerequisite for making long-running agents work in practice.
3. Core Challenge #1: Reverse-Engineering Legacy Formats
Ancient software makes heavy use of hand-rolled proprietary formats, with almost no ready-made parsing libraries. Take video as an example: a certain old game used a proprietary encoding container, and only a handful of open-source implementations are publicly available. At this stage, the agent will burn substantial compute on reversing binaries and probing “magic constants” (fixed numeric values that lack semantic explanation).
The engineering recommendations are:
- Prefer mature solutions: If a stable parsing library exists, don’t hand-write a codec;
- Document magic constants separately: Collect the key constants obtained through reverse engineering into a single, well-commented record instead of scattering them across the codebase;
- Build format regression test cases: Compare input and output using real sample files to keep the rebuild from drifting.
4. Core Challenge #2: License Compliance Traps
This is the most easily overlooked step, yet it can be fatal. Whenever the agent pulls in an external implementation, license compatibility must be strictly reviewed:
- Strongly copyleft licenses (which require derivative works to be open-sourced under the same terms) can conflict with the project’s permissive license (which allows closed-source distribution);
- In static-linking scenarios, introducing certain weak-copyleft licenses also creates compliance risks;
- Therefore, the team must define the project’s license baseline up front, and have the agent perform a compatibility check before pulling in any dependency.
A pragmatic strategy: write the license constraints down as explicit engineering rules, serving as hard boundaries for the agent’s decisions, rather than trying to fix things after the fact.
5. A Noteworthy Phenomenon: The Agent’s “Reference” Behavior
In practice, you may observe an interesting and instructive phenomenon: if you directly ask the agent to “copy” a certain implementation, it may refuse out of compliance concerns; but if you mention in your requirements that “the industry already has such-and-such algorithm or implementation,” it will often proactively study that approach, then “recite” the key constants and algorithmic steps and produce its own implementation.
This tells us:
- Compliance boundaries can be steered through how requirements are phrased, rather than through hard confrontation;
- The agent’s behavior depends heavily on the wording of the context, which makes prompt design itself an engineering skill;
- But human review is still required at the end, to ensure the line between “referencing the approach” and “copying directly” remains clear and compliant.
6. Practical Recommendations and Risk Control
All things considered, rebuilding legacy software with agents is feasible, but it needs supporting engineering constraints:
- Verification first: Treat automated tests and runnable results as the only acceptance criteria;
- Small, frequent commits: High-frequency commits make rollback and problem isolation easier;
- Compliance up front: Bake license rules into the agent’s constraints; review every dependency it introduces;
- Document constants and formats: Capture reverse-engineering findings as documentation to reduce future maintenance costs;
- Human-machine collaboration: The agent handles construction at scale; humans handle architectural decisions and final compliance review.
7. Conclusion
Rebuilding legacy software whose source code is lost is shifting from “impossible” to “methodical”. The value of AI coding agents lies not in replacing engineers’ judgment, but in scaling up the long, repetitive, format-tedious construction work. What truly determines success or failure is a clear phased plan, strict compliance boundaries, and a quality system centered on automated verification. Master this methodology, and your team can turn the vision of “making a classic live again” into a sustainable engineering practice.
