Mistral details AI-agent migration of 40,000 lines of Fortran code
Mistral says it helped a European energy operator migrate 40,000 lines of Fortran 77 to C++ using parity testing, documentation agents and structured human-reviewed workflows.
Quick answer
What did Mistral announce about using AI agents to modernize legacy code?
Mistral described a project with a European energy operator that migrated 40,000 lines of Fortran 77 from a physics-intensive reservoir simulator to C++. The company said it built a numerical parity harness, used agents to document the codebase, and settled on workflows combining coder, tester and reviewer agents with human checkpoints.
Key takeaways
- Mistral says it helped a European energy operator migrate 40,000 lines of Fortran 77 to C++ in a reservoir simulator with no test suite or centralized documentation.
- The company built a parity harness that compared final outputs and critical intermediate checkpoints between the Fortran and C++ codebases.
- Mistral used Vibe CLI to deploy more than 100 agents to document the Fortran program and create pull requests for review.
- After testing fully autonomous and more structured approaches, Mistral adopted a workflow combining coder, tester and reviewer agents with human intervention and review gates.
Mistral said it helped a European energy operator migrate 40,000 lines of Fortran 77 to C++ in a physics-intensive reservoir simulator. The company described the project in a post published Wednesday, saying the legacy code had no test suite or centralized documentation.
Building a numerical check
Mistral said it built a parity harness before beginning the migration. The harness was designed to establish numerical equality between the two codebases, checking both final results and critical intermediate points identified by the client’s reservoir engineers.
The company added Fortran subroutines to export program state, created a C++ test framework to load those checkpoints and supplied Skill.md files to guide agents. Mistral said agents used the setup to instrument the Fortran program, dump state snapshots and verify migrated C++ modules. In one example, a Fortran run exported a value for the RHOG variable, which was then used as a reference checkpoint in a C++ test.
Documenting the codebase
Mistral said documentation was scattered among old PDFs and comments in the Fortran source. It parsed the codebase with a custom parser to generate a caller-callee tree, which represents the program as linked subroutines.
Using Vibe CLI, the company spawned more than 100 agents to document the tree. Agents could retrieve relevant PDFs through document libraries and Mistral OCR. Starting with the tree’s leaves, each node spawned a subagent to document it and open a pull request to the original repository. A reviewer agent running on a cron schedule checked newly opened pull requests and scheduled fixes when needed.
Testing different agent setups
Mistral said its first approach assigned one autonomous agent to each Fortran subroutine for a week. The resulting code was functional, but the company said it retained global structures based on COMMON blocks and GOTO-driven control flow, resembling Fortran rewritten in C++ syntax.
In a second approach, a planner, coder, tester and code-quality reviewer worked together on each module. Mistral said code quality improved, but agents eventually stalled after encountering bugs.
The company then adopted a human-operated workflow using coder, tester and reviewer agents. Working with reservoir engineers, it identified independent modules of less than about 10,000 lines of Fortran, generated a target C++ architecture, reviewed it with an engineer, and broke approved designs into task queues. Each task followed a plan, implement, test and repeat cycle, with human review of pull requests before merging.
Mistral said the first sprint covered 40,000 of 300,000 lines. It noted that the codebase was self-contained and runnable, while migrations involving external systems, no runnable baseline or undocumented physics would present additional challenges.
Source: Mistral, “Modernizing complex legacy code with AI agents,” published September 9, 2026.
Frequently asked questions
- How much code was migrated?
- Mistral says the first sprint migrated 40,000 of the codebase’s 300,000 lines, from Fortran 77 to C++.
- What was the parity harness used for?
- It exported state from the Fortran codebase, loaded checkpoints into C++ tests and checked numerical equality of final results and selected intermediate points.
- How did agents document the legacy code?
- Mistral generated a caller-callee tree with a custom parser and used Vibe CLI to spawn more than 100 agents. The agents drew on relevant PDFs through document libraries and Mistral OCR, then opened pull requests.
- What workflow did Mistral ultimately use?
- A human operated a workflow of coder, tester and reviewer agents, migrating modules one at a time. Humans reviewed pull requests and intervened when agents became stuck.