Skip to content
MISRAJAI
What we believe

We understand deeply. We build from the source. And we run with confidence.

Research

How We Built a Coding Agent at Misraj That Learns What to Read Before It Fixes

A research paper from the Misraj AI team in Khobar "Let the Fixer Decide: Training a Code Localizer from the Fixer's Likelihood" arXiv: 2611.12164 · November 2026

How We Built a Coding Agent at Misraj That Learns What to Read Before It Fixes

Watch an experienced engineer fix a bug in a large codebase. They won't open the broken file and start typing. First they'll read the function that calls it, then the class it inherits from, then the test that fails. They might read ten files, then change just two lines.

This simple habit, reading far more than you edit, is what the Misraj AI team set out to teach a small AI agent. The result is a new research paper proposing a different way to train coding agents, built entirely in Khobar, with its data, code and models released to everyone.

The problem: an agent looking for the wrong thing

Coding agents are AI programs that receive a description of a problem in a code repository, search through it, write a fix, test it and submit it. Many of them work in two stages:

Localization: Where is the problem? Which parts of the code are worth reading?

Fixing: Read those parts, then write the edit.

When open models are trained for the first stage, they are usually told: "Learn to predict the files that were edited in the correct solution." That sounds reasonable, but it teaches the agent to answer a different question. The correct solution tells you where the change happened, not what the fixer needed to see to get there.

The idea: ask the fixer itself

Picture a researcher and a library assistant. The assistant fetches the books; the researcher writes the paper. The traditional approach trains the assistant to fetch the books that were quoted in the final paper. But the researcher may have needed other books to understand the context, even without quoting a single word from them.

Misraj AI's proposal: let the researcher judge what the assistant brought. Which set of books made writing the right paper easier? Then train the assistant on that.

That is exactly what the method the team calls Fixer-Guided Localization (FGL) does:

The localizer proposes. For each problem, the search agent suggests several different answers: different sets of code locations.

The fixer scores. The agent that writes the fix reads each set and asks: if I start from this code, how likely am I to write the correct fix, the one proven by the tests?

The localizer learns. The sets that made the correct fix more likely get a higher weight, and the localizer is trained on them.


Why this matters technically

The usual way to teach an agent "from the outcome" is reinforcement learning: the agent tries a fix, the tests run in an isolated environment, and the agent is rewarded or penalized. That takes thousands of runs and heavy infrastructure.

Misraj AI's method cuts all of that out. No tests run during training, and there is no reinforcement-learning loop. Scoring any proposal takes a single read by the fixer, followed by ordinary fine-tuning of the kind most teams can run. The idea is borrowed from search and retrieval systems, where whoever fetches the information is trained on what helps whoever uses it, and the team carried it over to code repair.

How Misraj built the system

Two agents in one small model

The system is built on Gemma 4 E4B, the smallest model in Google's Gemma 4 family, which runs on relatively modest hardware. From this single model the team created two agents, each with its own lightweight "specialization layer" (a LoRA adapter) added on top of the model without changing it:

The fixer: the main agent. It runs commands, reads and edits files, and submits the fix. One of its tools is calling the localizer.

The localizer: a helper agent that opens a fresh session, explores the repository in at most 15 steps, and returns a list of up to 8 locations, each giving the file, the function and the lines, and whether the location is to be edited or only read.


Clean data before any training

The team writes in the paper that data was the most expensive part of the project. The way it was built explains why the results can be trusted:

About 10,000 real software problems were collected from four well-known datasets in the field, and checked automatically to confirm that the tests fail before the fix and pass after it.

A large "teacher" model, Kimi K3, was run inside the competition's own environment, with eight minutes per attempt and no internet access. Out of 3,068 attempts, it solved 1,629 problems, and only fixes that passed the tests in a fresh environment were kept.

The teacher's "memory" was cleaned. The team found that the large model sometimes "remembered" the real fix from the internet: it cited commit references, some of them invented, and wrote the fix before reading the code. The small model will not have that memory, and training it on such text teaches it to assert rather than reason. So 3,233 passages of this kind were identified and rewritten, without touching any actual tool output.

Nothing was invented. When each attempt was split into a lesson for the localizer and a lesson for the fixer, every read request was answered with code the teacher had actually seen, matched character for character.

Why we built this agent at Misraj

The immediate reason was Google's Kaggle competition "Gemma 4 Developer Agent," which fixes the model, the tools and the runtime environment for every participant and asks them to build a coding agent and document it in a research paper. Working with a limited budget, the team chose the smallest model available.

The deeper reason is a question that occupies everyone building AI agents: can a small agent learn from another agent without massive infrastructure? Large models are capable, but they are expensive and usually run on external servers. Small models can run inside the organization, on its own hardware and under its own control. Every step that makes small models smarter is a step toward AI that is closer, cheaper and more independent.

What the team found

Result one: the same benefit with less code

Before full training, the team tested the idea on 1,016 problems, giving the fixer the teacher's chosen locations once and the locations chosen by FGL once.


Measure

Teacher's choice

FGL's choice

First edit landed at the actual bug location

42.4%

43.1%

Size of code shown to the fixer

2,731 tokens

1,980 tokens (27.5% less)

Context-window overflows

146

82 (44% fewer)


Source: Table 3 of the paper.

The fixer reached the bug about as often, with more than a quarter less code. And on 83% of the problems, the fixer preferred a set other than the one the teacher chose, evidence that what an agent needs to read really does differ from what seems obvious.


Result two: smarter behavior, and honest numbers

On 78 real problems, with eight minutes per problem, the agent's behavior changed clearly. The untrained model rushed: it took about 11 steps, submitted a guess within two and a half minutes, and 61 of its 78 attempts ended in a wrong fix. The trained agents explored about three times more, and their wrong fixes dropped to just 9–14. The localizer trained with FGL also reduced the cases where the agent got stuck looking for files that don't exist, from 54 to 43, compared with a matched version trained without the method.

But the team stated plainly what was not achieved: the number of problems solved did not rise by a statistically significant margin. The reason is that once the agent learned to explore more carefully, it started running out of time before finishing. It had learned the pace of a teacher working on fast servers, while it runs on much slower hardware. In other words, the bottleneck was no longer "what to read" but time and edit quality.

This candor is not a weakness of the research. It is what makes it useful to everyone who comes next: a clear map of what worked, what didn't, and why.

The intended benefit: where this work leads

Smaller agents that run inside the organization. The method needs neither reinforcement learning nor thousands of test runs, so it is within reach of teams with moderate budgets. That opens the door to coding agents trained on small models that can run on an organization's own servers, without sending code to external services.

A principle that goes beyond code. The idea of "train whoever fetches the information on what helps whoever uses it" applies to any system that searches and then answers: an assistant that searches a government agency's documents and then answers a citizen, or a system that extracts data from documents and then makes a decision. The right question is not "did we find the right document?" but "did what we found help us reach the right answer?"

An open foundation for developers. Misraj AI has released 1,629 test-verified attempts, the data-building code, the training code and all the trained models. Any researcher or developer can reproduce the experiment or build on it with a larger model. The team notes in the paper that larger models, further training rounds and improving the fixer itself are the subject of a follow-up paper.

From Khobar to the global stage

According to the Digital Government Authority, Saudi Arabia topped the United Nations E-Government Development Index in 2026. That achievement did not come out of nowhere: Saudi Vision 2030 made digital transformation and building national capability in technology a core pillar, not a side project.

But leadership in digital services raises the next question: who builds the technology behind those services? The next phase is not limited to using AI; it extends to contributing to how AI is made: understanding how models learn, how they can be trained efficiently, and how they can run inside a local environment under their owners' control.

"Let the Fixer Decide" is a small part of that picture. A Saudi team in Khobar poses an original research question in training AI agents, answers it with a rigorous method, and publishes the full results, including what did not work, on global research platforms. It extends Misraj AI's work on Arabic models such as Kuwain, Mutarjim and Baseer, but this time on a fundamental question for all of AI: how do we make small models learn intelligently, at lower cost?


Links

The paper on arXiv: https://arxiv.org/abs/2611.12164

The paper's page on Hugging Face: https://huggingface.co/papers/2611.12164

Training code: https://github.com/misraj-ai/locfix

Data-building and validation code: https://github.com/khalil-Hennara/codeagent-validate

Trained models: https://huggingface.co/Hennara/locfix-e4b-runs_p

Research team: Khalil Hennara, Muhammad Hreden, Zeina Aldallal, Sara Chrouf, Safwan AlModhayan  Misraj AI, Khobar, Saudi Arabia.

Get started

Let's talk about what you're trying to build.

Every good solution starts with a clear question. Ask us, and our team is with you from question to solution.