Execution Feedback Against Chemical Hallucination

Language models that design molecules have a specific, costly failure mode: they propose structures that look perfectly valid on paper — every valence rule satisfied, every predicted binding score excellent — but that no chemist could actually assemble. The field increasingly calls these "chemical hallucinations," and the name is apt for the same reason it is apt in language: the model is fluent and confident about something that has no grounding in reality. At the same time, a separate line of work has shown that language models become dramatically better at writing code when a compiler or test harness tells them, deterministically, that they are wrong — the machine's judgment replaces the model's own. This proposal applies that second idea to the first problem: represent a candidate molecule together with its synthesis route as an executable program, run it against a chemistry simulator, and let the model debug the failures.

The scientific bet is about hallucination itself, not just chemistry. A model that judges its own output tends to rubber-stamp it; a deterministic external process does not. We will test this directly by comparing refinement loops in which the critic is a real execution oracle against loops in which the critic is another language model, and by scoring the failures with the standard hallucination taxonomy — input-conflicting, context-conflicting, and fact-conflicting errors — from the survey literature Siren's Song in the AI Ocean, which catalogs how generated text contradicts sources, the model's own earlier statements, or world knowledge. If the bet is right, this is also a case study in why execution feedback suppresses fabrication, with consequences well beyond molecules — the same dynamics matter wherever models make factual claims about a checkable world, from clinical decision support Xi Chen et al. to enterprise automation Anum Afzal et al..

Core Claim

Three claims, in decreasing order of confidence. First, a test-time loop in which a frozen LLM writes synthesis routes as code and debugs them against a deterministic oracle — a forward-reaction simulator plus retrosynthetic search over a purchasable-chemical inventory — closes most of the synthesizability gap without any training, because every accepted output has, by construction of the loop, an executable recipe. Second, external execution feedback suppresses fact-conflicting chemical hallucination where LLM self-critique does not, and self-critique may even amplify it, mirroring the finding that feeding model outputs back into model prompts magnifies flaws rather than repairing them Do Users Write More Insecure Code with AI Assistants?. Third, representing routes as code rather than as fixed synthesis trees lets the agent write and verify new reaction functions, escaping the template-library inelasticity that current synthesis-aware generators explicitly suffer from.

The central quantity is the gap between claimed and actual feasibility. Define the hallucination rate at turn $t$ as

$$h_t \;=\; \Pr\big[\,\text{execution}(r_t) \text{ fails} \,\big|\, \text{the model asserts } r_t \text{ is feasible}\,\big],$$

where $r_t$ is the route proposed at turn $t$. This isolates fabrication from mere failure: a route that fails and is acknowledged as untested is not a hallucination; a route the model vouches for that cannot run is.

Research Program

The artifact is a refinement loop with four parts. A coder model writes each candidate as a Python program whose functions are reaction templates applied to purchasable building blocks — drawing on the Enamine library of over 200,000 blocks used by A Genetic Algorithm for Navigating Synthesizable Molecular Spaces (SynGA), which evolves explicit synthesis trees and achieved a 1.000 validity rate on ChEMBL analog search, and the roughly 23 million commercial starting materials from eMolecules that Retro-R1: LLM-based Agentic Retrosynthesis plans against. An executor then runs the program through a neural forward-reaction predictor, in the spirit of Generating Molecules via Chemical Reactions (Molecule Chef), which builds molecules by predicting reactions over selected ingredients, and checks each retrosynthetic step by calling single-step models as tools, as Retro-R1 does. Failures return to the model as raw tracebacks, since Hollmann et al. showed that injected execution tracebacks let LLMs autonomously debug and recover from errors in automated machine-learning pipelines. Finally, an explicit rollback mechanism reverts to the last checkpoint in which every prior step still executed, imported essentially wholesale from MEIC, the RTL-debugging system of Fang et al., because its "new error trap" — patches that fix one bug while quietly introducing another — is exactly the risk when a route edit invalidates an upstream reaction.

The analytical contribution is the taxonomy mapping. Fact-conflicting hallucination becomes a route that the model asserts will run but that the forward simulator rejects (a claimed reaction that does not proceed); context-conflicting hallucination becomes a revised route that contradicts the model's own earlier statements, for instance about which reagents are purchasable; input-conflicting hallucination becomes a route that violates user-supplied constraints such as a reagent cost cap. We will build a log classifier that scores each turn of each loop on all three, so the dynamics of $h_t$ can be read per error type.

The most speculative component addresses template inelasticity. SynGA's own stated limitation is that template-based methods cannot propose transformations outside their pre-compiled reaction libraries. LearnAct, from Zhao et al., showed that agents which write, test, and debug their own reusable action functions improve across tasks; the chemical analog is an agent that writes new reaction-template functions, screens them with a precedent model trained on millions of historical literature reactions — the screening-filter approach established by Edward Kim — and only then admits them to its library.

The closest existing work is deliberately different. MECo, Coder as Editor: Code-driven Interpretable Molecular Editing, already generates molecules by writing executable RDKit code, but it is strictly single-turn with no feedback from any synthesis oracle — we make the oracle the whole point. Retro-R1, Retro-Expert, and RetrOrchestrator are trained agents that find routes for a given target molecule post hoc; they do not jointly generate and debug the molecule and route, and they do not study hallucination dynamics. None of them measures what happens when the critic is the model rather than the world.

Baselines

The do-nothing reference point is a one-shot LLM asked for a molecule plus a stated route, with no feedback of any kind; this establishes $h_0$, the base chemical hallucination rate. No reported result found on Lacuna for a one-shot LLM chemical hallucination rate, so we must measure it ourselves. The cheap competitor is best-of-$n$ with post-hoc filtering: sample $n$ molecules, keep those whose routes survive an independent retrosynthetic planner, discard the rest. The strongest existing method is SynGA, which by construction attaches an executable recipe to every output and reported a validity of 1.000 on ChEMBL analog search, with its Bayesian-optimization configuration SynGBO outperforming prior synthesis-aware and synthesis-agnostic models on the Practical Molecular Optimization (PMO) benchmark; no reported result found on Lacuna for a specific SynGBO PMO score, so we rerun it ourselves under a matched evaluation budget (equal number of objective-function evaluations, the standard PMO currency). For the code-driven comparison we run MECo with the same coder model, single-turn, no oracle. Two ablations isolate the proposal's key ingredients: swapping the deterministic oracle for an LLM critic in the MAGIS collaborative-review style of Tao et al. isolates external ground truth, and toggling rollback isolates the MEIC ingredient. All LLM systems share the same model, token budget, oracle-call budget, and tuning budget; beating a baseline means matching or exceeding it on the joint metric — objective score among outputs with executable recipes — at equal budget, not on validity alone, since several baselines already guarantee validity.

Why not just…?

Why not just filter one-shot outputs with a retrosynthetic planner? Honestly, on validity alone this may tie: SynGA already reaches 1.000 by construction, and a filter with enough samples can approach that. The decisive experiment is exactly this comparison on PMO at equal evaluation budget. If best-of-$n$ matches the loop's joint objective score, the proposal's value narrows to the hallucination-dynamics finding and out-of-library novelty, and we will say so plainly. What the filter structurally cannot do is repair near-optimal candidates — rejection discards the model's best-scoring molecules precisely when they fail — or produce transformations outside the planner's templates.

Why not just generate directly in reaction space, or fine-tune with a synthesizability reward? Molecule Chef and SynGA guarantee validity by construction, and reward-based training is a real threat: Retro-R1 trains with reinforcement learning, TANGO (from Philippe Schwaller et al.) provides a differentiable synthesizability reward. But template libraries are inelastic by SynGA's own account, trained policies are tied to one reward and one inventory, and both lines omit physical dynamics. Our loop is orthogonal: it works with frozen models, composes with any scoring function, and we will run a Retro-R1-style trained planner both as an oracle and as a baseline to check that the loop is not merely rediscovering what training provides.

Why not just put the oracle's output in the prompt once? Yan et al. found that compiler feedback yields rapid fixes in the first one or two iterations and then plateaus sharply. If our loop plateaus by turn two, the single-turn-with-oracle ablation will expose it, and the burden shifts to rollback and action-space expansion. That ablation is in the plan precisely because this alternative is live.

Proposed Experiments

Experiment one reproduces SynGA's ChEMBL analog-search setting: metric is route-executable validity plus similarity to the target. SynGA reported validity 1.000 there, so the question is not whether the loop can hit 1.000 — it must, by construction — but at what oracle-call cost, with what similarity, and from a frozen model rather than an evolutionary search. Experiment two runs PMO against SynGBO under matched evaluation budgets, reporting the objective score conditional on a valid route, which is where rejection-based methods should bleed. Experiment three is the scientific core: $h_t$ curves for oracle-feedback, LLM-self-critique, and no-feedback loops, with residual errors classified by taxonomy. The predictions are concrete — self-critique flat or rising per the model-close-loop evidence, oracle feedback falling and then plateauing per Yan et al., rollback cutting the per-edit regression rate — and each is falsifiable on its own. Experiment four audits novelty: the fraction of accepted routes using agent-written, precedent-verified reaction functions outside the initial library, with a sample validated by human chemists.

The decisive check is experiment three. If execution feedback does not beat self-critique on $h_t$, the central claim about hallucination fails — and the negative result would still be, to our knowledge, the first controlled measurement of external ground truth as a fabrication control in a scientific domain, which is worth publishing either way.