Critics That Quote: Recovering Buried Context in Iterative Hardware Debugging

When a language model debugs code in a loop (write code, run the compiler or simulator, read the error, revise), its context fills up in a predictable order. The original specification sits at the very start. The latest code and error sit at the very end. Everything in between gets pushed into the middle: earlier failed attempts, constraints stated once, and simulator traces that already ruled out a fix. Language models read the middle of long contexts poorly. This proposal tests whether that positional blind spot is one reason debugging loops stall after a round or two and start repeating or undoing earlier fixes. It then tests a specific remedy, which we call quote-first critique. A small critic model, specialized to hardware description code, judges every proposed revision before it is accepted. Before giving its verdict, the critic must copy verbatim each specification clause and each prior failed attempt that bears on the change.

The idea is that rationale-first evaluation does two jobs at once. It produces reasoning, and it also physically moves buried middle-context text to the end of the context, where models attend best. If that is right, a critic that quotes before it judges should cut repeated failed edits and silent specification violations. It should do better than both an unguided loop and a critic that reasons freely. The claim is narrow and falsifiable, and a cheaper fix could beat it: simply restating the specification at the end of the prompt. The experiments are built to settle which one works.

Core Claim

In multi-turn debugging of Verilog, a hardware description language whose correctness is checked by simulation, we expect two failure modes to grow with how far a piece of information sits from both ends of the context. The first is the rate at which the model re-proposes an edit it already tried. The second is the rate at which it violates a specification clause not covered by the visible testbench. We further claim that an 8B critic, fine-tuned on Verilog diffs and trained to quote relevant clauses and past attempts before emitting a pairwise accept-or-rollback verdict, will reduce both failures. We predict it will beat restating the specification at the end, beat positional decoding fixes, and beat testbench-only rollback, all under a matched iteration budget. What is new is treating the evaluator's rationale as a mechanism for selectively re-surfacing context. It is not just a route to better scores. We test that mechanism directly by ablating the quotes while keeping the reasoning.

Where This Sits in Prior Work

The motivating evidence comes from three places. First, loops plateau. In CodeTransOcean, self-debugging lifted ChatGPT from 48.57% to 52.57% over three rounds and then stopped improving. Second, SlopCodeBench found structural erosion rising in 77% of agent trajectories. Third, MEIC describes models falling into "new error traps" during hardware debugging. None of these papers asks where in the context the ignored information sat.

Lost in the Middle supplies the positional phenomenon: GPT-3.5-Turbo drops from about 75% to about 53% when the answer document moves to the middle, and longer context windows do not help. Positional Contrastive Decoding explains part of the effect as next-token prediction over-weighting tokens near the generation point, and offers a training-free decoding correction. Both papers were evaluated on synthetic retrieval, not on agent histories. We reuse positional decoding as a competing baseline rather than as our method.

The evaluator side draws on two lines of work. AdaRubric shows that structured, dimension-by-dimension judging raises human correlation to r=0.79, and lets Llama-3.1-8B (r=0.68) beat unstructured GPT-4 (r=0.64). It does this as an offline judge generating preference pairs, and it does not study position. An Empirical Analysis of Uncertainty in LLM Evaluations shows that pairwise comparison gives more confident verdicts than single-answer scoring, and that token probabilities measure evaluator hesitation. We use both findings: the critic compares the candidate against the current best, and its verdict probability sets the rollback threshold. That is only possible because the critic is open-weight.

The closest system is MEIC. It pairs a Verilog debug agent with a scorer agent and a rollback rule, reaching 93% syntax and 78% functional fix rates on 178 RTL errors with a GPT-4 backbone. Our proposal differs in three ways. MEIC's scorer judges readability and quality without any structured rationale. It does not control or measure context position. And its scorer is a general model. We keep MEIC's rollback idea and replace the judge.

CodeTransOcean also constrains the design. Its reported "chain-of-thought paradox" is that step-by-step prompting of the generator made translation worse by fixating it line by line. We therefore put the rationale only in the critic, and we test generator-side reasoning as a separate arm.

Domain specialization is the enabling condition. AutoTriton and CHORUS show that compact models trained against execution outcomes can beat far larger general models on narrow hardware or kernel tasks (CHORUS-4B at 88.0% versus DeepSeek-R1 at 74.5% on CVDP-ECov). All such work specializes generators; none specializes a judge of intermediate debugging diffs.

Research Program

The work has three parts.

Position audit. We run a standard execute-and-revise loop with an open 8B code model and with a frontier model on RTLLM (benchmark paper; RTLLM: An Open-Source Benchmark for Design RTL Generation with Large Language Model) designs and on the 181 HDLBits-derived problems from VeriGen. We log every turn and measure two quantities as a function of the token position of the relevant item. The first is the repeat-attempt rate: how often a proposed diff is near-identical to a previously rejected diff. The second is the clause-violation rate: how often a revision breaks a specification clause, such as reset polarity or port widths, that the visible testbench does not check.

The observational trajectories are then followed by a controlled version. We hold the task fixed and move a single decisive item (a constraint, or a record that fix X failed) to the start, middle, or end of an otherwise identical history, padding with real prior turns. We then measure whether the next revision respects that item. If the middle dip does not appear here, the rest of the program loses its motivation, and we would report that.

The critic. We start from an open 8B code model and fine-tune it on Verilog. It is then trained to produce outputs in the form: quoted clauses, quoted prior attempts, reasoning, then a pairwise verdict. Training labels come from hidden verification rather than from the visible testbench the debugger sees. For each design, we build extended testbenches from random-stimulus comparison against reference implementations where these are available, and from hand-written checks otherwise. A candidate counts as truly better only if it improves on these hidden checks. Rationales are drafted by a teacher model and kept only when the teacher's verdict matches the hidden-test outcome. Quotes are verified by exact string match against the context, so the critic cannot paraphrase its way around the relocation mechanism.

At inference time, the critic's verdict probability decides whether to accept a candidate or roll back to the best state so far. When the critic rejects a candidate, its quoted material is passed back to the debugger as feedback.

Mechanism analysis. To separate relocation from reasoning, we train matched critic variants. One quotes verbatim. One refers to clauses only by index, keeping the same reasoning but moving no text. One reasons freely with no quoting requirement. One scores directly with no rationale at all. We also compare a general 8B model and a frontier model in the same critic role.

Baselines

The naive reference is an unguided loop: the debugger sees the full history and gets raw simulator output, with no critic and no rollback, run for the same number of turns. Its plateau shape is what we expect to improve on.

The strongest existing method is MEIC's design, a debug agent plus a scorer-driven rollback. MEIC reports a 78% functional fix rate and a 93% syntax fix rate on its 178-error RTLLM-derived set with GPT-4 MEIC. The same paper reports 66% functional fixes for its RAG/fine-tuning baseline and a 62% syntax fix rate for standalone GPT-4. We will reimplement the MEIC scaffold with the same debugger, simulator, and turn budget as our system, varying only the judge. If the 178-error set is unavailable, we will regenerate an error set with the same injection categories and report MEIC's numbers only as context, not as a head-to-head comparison.

For single-pass generation, the reference is RTLLM's self-planning result with GPT-4: 90% syntax success and 19/30 functional passes RTLLM. A loop that cannot beat this number is not worth its cost.

Three further baselines target the positional claim. The first is restate-at-end, where the full specification and a list of rejected diffs are appended after the latest error on every turn. The second is truncated history, where the debugger keeps only the specification, the current best code, and the latest error. The third is positional contrastive decoding applied to the debugger. The final baseline is testbench-only rollback, which accepts a revision whenever the visible testbench pass count does not drop.

All arms share the same debugger weights, simulator, maximum of eight turns, and wall-clock budget. The critic's extra tokens are counted against our system's budget. Beating the field means a higher hidden-test functional fix rate than the best of MEIC-style, restate-at-end, and testbench-only rollback, with non-overlapping bootstrap intervals over designs. It also requires a lower repeat-attempt rate. The index-only ablation isolates the key ingredient: if it matches verbatim quoting, relocation is not what matters.

Why not just…?

Why not just restate the specification at the end of the prompt? This is the most serious threat, because it attacks the positional problem directly and costs almost nothing. Our bet is that restating works for the specification but scales badly to history. The set of rejected attempts grows every turn, and appending all of it puts the same burial problem back one layer down. The critic, by contrast, quotes only the items relevant to the current diff. The controlled audit and the restate-at-end arm settle this directly. If restate-at-end matches the critic on both repeat-attempt and clause-violation rates, we will report that the effect is real but trivially fixable, and we will drop the critic claim.

Why not just roll back on testbench results? Execution is objective, and the loop already has a simulator. But visible testbenches are finite. A revision can pass them while breaking an untested clause, and slow drift of this kind is what SlopCodeBench documents: functional checkpoints still pass while structure erodes. We measure this gap explicitly as hidden-test failures among visibly passing revisions. If that gap is near zero on these benchmarks, the critic adds little, and testbench rollback wins on cost.

Why not just use a frontier model as the critic? Frontier judges are strong, but they are slower, their token probabilities are often inaccessible (which rules out calibrated rollback thresholds, as the uncertainty paper notes), and specialized compact models have beaten much larger ones on hardware tasks, as CHORUS and AutoTriton show. We still run a frontier model in the critic role. If it outperforms the specialized critic by a wide margin at acceptable cost, specialization is not the point, and we will say so.

Why not just have the debugger think step by step? CodeTransOcean reports that generator-side reasoning hurt translation through line-level fixation, while RTLLM's high-level planning helped. We include a generator-reasoning arm, both with and without the critic, to show whether the benefit comes from where the rationale sits or merely from whether one exists.

Decisive Experiments

Three results decide the proposal.

First, in the controlled audit on RTLLM and HDLBits tasks, the next-turn compliance rate for a decisive item placed mid-history must be measurably lower than for the same item placed at either end. The effect must appear for at least the open 8B debugger. Without this, the positional explanation fails.

Second, under matched budgets, the quote-first critic must beat restate-at-end, truncated history, positional contrastive decoding, testbench-only rollback, and the reimplemented MEIC scorer. It must win on hidden-test functional fix rate and on repeat-attempt rate. The index-only ablation must fall back toward free-form reasoning. If it does not, the mechanism we propose is wrong even if the system works.

Third, as a check on domain transfer rather than a headline result, we will run the same audit and critic recipe with a Python-trained critic on SlopCodeBench checkpoints and CodeTransOcean's DSR@K protocol. We ask two things: whether the middle-position effect predicts erosion there, and whether the critic lifts DSR past the 52.57% plateau at round three reported for ChatGPT. We have found no reported result on Lacuna for position-controlled debugging histories or for erosion metrics on RTL, so these numbers would be new rather than comparisons.