PaperAnchor: Trust the Writing Agent, Recompute Its Numbers

Thanh-Huy Nguyen, Ulas BagciarXiv 2026

TL;DR

Coding agents can now read your repository, draft an entire research paper, and iteratively polish it against an AI peer reviewer—but nothing stops an accuracy of 81.8% in the logs from accidentally becoming 84.8% in the prose. PaperAnchor acts like a compiler for scientific claims: every time a writing agent types a number, an automatic hook recomputes it from raw data on the spot. By moving verification from the end of the pipeline right into the edit loop, it catches numerical slips the instant they happen, before anyone cites a phantom result.

What Problem Does This Paper Address?

Automated research pipelines increasingly pair a coding agent (the writer) with a simulated LLM peer-review system (the judge), revising drafts in a loop until review scores plateau. In these loops, numbers inevitably drift due to rounding slips, unit mix-ups, or accidental typos during rewrites.

Existing safeguards check numbers after the draft is finished, and they fall short in surprising ways. First, LLM reviewers might notice a contradiction in the text, yet barely penalize the numerical score—giving an optimization loop almost zero signal to fix the mistake. Second, post-hoc lookup registries (which match text numbers against pre-logged summary tables) struggle when revising agents compute fresh, valid analyses directly from raw files, flagging good work as unsupported while letting shifted numbers slip by if they happen to land near some other stored value in a massive repository.

Comparison between relying on an LLM reviewer versus recomputing numbers at edit time with PaperAnchor.

Software engineering solved this decades ago: you don't wait for a colleague's pull request review to catch a type error; the compiler catches it when you save the file. The authors ask whether scientific writing agents need the exact same thing—and where in the agent's workflow that check actually works.

Methods

The authors introduce PaperAnchor, a deterministic, zero-LLM-call check that runs inside an agent's editing harness (implemented for Claude Code, CLI, and git pre-commit hooks).

Whenever the agent adds or modifies a number in a $\text{\LaTeX}$ file, it appends an invisible macro tag (\src{key}) and writes a short Python function—a recipe—in paper/sources.py that computes the unrounded value directly from a read-only snapshot of the repository's raw data.

How PaperAnchor verifies a single edit using Python recipes and three deterministic rules.

For a number to pass, three rules must hold:

  1. The value follows: The recipe’s unrounded output must round to the printed number at its exact printed precision.
  2. Reads raw data: The recipe must open real, unmodified data files from the pre-session snapshot (prose notes like Markdown files are banned so agents can't write a note and cite themselves).
  3. No typed constants: Hardcoding the printed answer or calling rounding functions inside the recipe is forbidden.

Crucially, the authors test where this verdict should sit (placements): offered passively in the prompt as an optional Tool, triggered automatically after edits as Feedback, enforced as a blocking Gate that denies bad edits, or bound at build time (Generate mode, where \val{key} fills the number automatically).

Datasets

To evaluate checks where ground truth is strictly known, the authors built AnchorBench using materials posted after the models' training cutoffs (preventing memorization):

  • Reviewer Suite: 60 recent arXiv papers across ML, vision, and NLP, each tested in five versions (clean, 1 wrong number, 5 wrong numbers, 5 deleted numbers, and all tables/experiments stripped).
  • Writer Repositories: 10 public research repositories with raw experimental outputs, yielding 1,192 new or edited numbers across 40 agent-revised drafts.
  • Audited Sample: 300 randomly sampled agent-written numbers audited blind by two frontier models, plus a 122-number subset recomputed by hand by humans.
  • Placement Testbed: 24 tagged drafts (8 repositories $\times$ 3 seeds) seeded with 138 planted errors—mostly flattering errors (inflating the paper's own method by 6–13%) alongside neutral last-digit slips.

Key Insights and Ideas

  • LLM reviewers spot errors, then forgive them in the score: Reviewers frequently quote contradictory numbers right in their weakness summaries, yet barely dock the overall percentile score. Optimizing for reviewer scores will not protect numerical integrity.
  • Revising agents calculate, they don't just hallucinate: Under review pressure, agents rarely invent numbers out of thin air; about 96% of added numbers are genuine calculations from raw files. Errors are subtle human-like slips—rounding -3.05% to -3.0% or using a slightly wrong denominator.
  • Optional tools get ignored; automatic hooks work: Giving a Sonnet writer the exact same checker and rules in its prompt—leaving it up to the agent to run—left just as many errors behind as having no check at all. Running it automatically via an edit hook wiped them all out.
  • Nudging beats blocking: Simply telling the agent the right value right after an edit (Feedback) worked just as well as rejecting the edit outright (Gate), even when the agent was explicitly instructed by a "lead author note" not to weaken headline results!
Comparison of planted errors remaining across six check placements.

Key Results

  • Reviewer insensitivity: When 5 numbers were wrong, Claude Haiku, Sonnet, and Opus quoted at least one wrong number in 91%–98% of reviews, yet dropped their 0–100 scores by only 1.6 to 3.3 points—roughly the noise between two reviews of the identical clean paper.
  • Detection accuracy: On the human-verified sample (16 real errors), PaperAnchor's recomputation caught 14/16 errors (typically taking <1 second per paper), whereas a stored-value lookup gate caught only 3/16.
  • Placement outcomes: Across 24 papers (up to 6 planted errors each), No check left 3.08 errors/paper, an optional Tool left 2.96, and a random-denial placebo left 2.71. Automatic edit-time modes (Feedback, Gate, and Generate) all left 0.00 planted errors/paper.
  • Efficiency: Feedback cleared all errors in 8.7 turns/paper, whereas the blocking Gate needed 19.9 turns/paper due to edit retries.

Limitations and Future Work

PaperAnchor verifies that a recipe produces the printed number, not that the recipe matches the English prose. Its two misses in the human audit happened because the agent wrote a valid calculation for a slightly neighboring quantity (e.g., counting 14 total series variants when the sentence implied 12 distinct series). Comparing the recipe's text description (means string) against the sentence using a secondary model or periodic audit is a natural next step. Additionally, the placement experiments tested three Claude models inside a single harness on numbers with existing recipes, and adversarial pressure was simulated via a single prompt instruction rather than reinforcement learning rewards.

Summary updated

BibTeX
@misc{nguyen2026paperanchor,
  author = {Thanh-Huy Nguyen and Ulas Bagci},
  title = {{PaperAnchor: Trust the Writing Agent, Recompute Its Numbers}},
  year = {2026},
  eprint = {2611.39561},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/2611.39561},
}
Figure