All posts

AI Engineering

Where Did Zero Go? Code Localization with ColGrep-Agent

When a bug report uses different words from the code, what should a small search agent find? An executable zero-value filtering example separates locating relevant code from fixing it.

Published and maintained by Sambro · Report a correction

6 min read ColGrepCoding agentsCode searchOpen source

What if the code never says “custom attributes”?

A customer reports that entering zero in a custom attribute makes the value disappear. The code calls this feature fields. Searching the customer's exact words may not lead directly to the relevant function. That is not a failure of literal search: it is a vocabulary gap between a description of behavior and its implementation.

LightOn introduced ColGrep-Agent on October 12, 2026, in an article by Maxence Lasbordes, Raphael Sourty, Aarush Sinha and Amélie Chatelain. Announcement: ColGrep-Agent — LightOn introduction

We did not run ColGrep-Agent or reproduce its benchmarks. Instead, this original Sambro Python example establishes a real, small bug and manually identified relevant code. No predicted model output is presented as an observed result.

Establish the expected behavior before searching

Our rule is explicit: discard only None, preserving zero, False and the empty string. The prepare_fields function below tests truthiness and loses all three values. render_fields merely formats whatever it receives. Fixing the renderer because the complaint mentions a missing display value would miss the cause.

The example runs with Python 3 and no packages, model download or API key. Download: code localization — demo.py

Tests: code localization — test_demo.py

An original educational example with separate filtering and display functions
def prepare_fields(values):
    return {key: value for key, value in values.items() if value}

def render_fields(values):
    return ", ".join(f"{key}={value}" for key, value in values.items())

sample = {"seats": 0, "active": False, "label": "", "missing": None}
print(prepare_fields(sample))  # {}

A code location and a correct patch are different outputs

A useful answer should identify the condition in prepare_fields and the call that passes its result to render_fields. Merely naming the file is insufficient. Returning unrelated lines, or the entire file, leaves the work of narrowing down the cause to the developer.

ColGrep is the semantic search tool; ColGrep-Agent-2B is the model; colgrep --agent runs the search-and-read loop. Its documented purpose is finding files and line ranges. Model card: ColGrep-Agent-2B — model card

A returned range is neither permission to edit nor proof of correctness. It might point to a namesake, a test helper, or unused code. Open the current checkout, inspect callers and actual inputs, and recheck old line numbers after repository changes.

If you compare the model, freeze the question first

To try the model yourself, save demo.py and its tests in a separate experiment folder and follow the official installation instructions for your system. The default Q8 model download is approximately 2.5 GB. The commands below are reader-run instructions, not a transcript of our model execution. Installation documentation: NextPlaid / ColGrep — source repository

Keep the answer's function name out of the question. Do specify the intended behavior. A disappearing zero alone does not distinguish a storage filter from a display rule. Preserving zero while excluding None provides the criterion for judging the location after retrieval.

Record the repository commit, question, model and CLI versions, raw output and elapsed time. In a file this small, reading it directly may be faster. This example is not a benchmark for ranking retrieval systems.

Commands for a separate example folder after official installation
colgrep init
colgrep --agent "Where are customer-defined attributes discarded when their value is zero, before being displayed? Only None should be excluded; zero, False, and empty strings must be preserved."

Token savings come with latency and uncertainty

In a separate Claude Code/Sonnet 5.5 search experiment with 52 questions across 13 repositories, the authors reported 34.3% fewer API tokens than their grep setup. Time rose from 13.0 to 21.6 seconds per question. Observed accuracy was 83.3% versus 80.8%; the difference's 95% interval was −10.9 to +5.1 percentage points. These are not our measurements, and they do not establish equivalent accuracy.

Do not turn that result into an end-to-end bug-fixing saving or a subscription discount. Reducing exploration and producing a correct patch are different objectives. Local computation and waiting time also belong in a cost assessment.

The paper supplies background on localization evaluation. Its experiments and the announcement's search-workflow experiment should not be combined as though their conditions were identical. Paper: Code localization research — arXiv 2610.05099

After finding the code, verify the rule

The example's corrected_fields changes the condition to if value is not None. That is not a universal normalization policy. A product that intentionally drops empty strings needs a different rule and different tests. This is a correction relative to our stated requirements.

The supplied tests check that the original function drops zero, False and the empty string; the corrected function preserves them while excluding None; and neither function mutates its input. We ran the example and all six tests and observed the output below. The deliberately buggy function remains available for comparison.

When you already know a symbol, exact search is a good starting point. When you know only the behavior, semantic search or a search agent may help narrow the candidates. Either way, the final decision belongs to the actual requirements and regression tests, not to a plausible-looking file location.

Run the example and its tests
python3 demo.py
# buggy: ''
# corrected: 'seats=0, active=False, label='
python3 -m unittest -v test_demo.py
# Ran 6 tests ... OK
Back to Sambro Blog