Coding agents now write related-work sections, literature reviews and grant background. The references they produce are wrong in more ways than "made up":

  • the DOI exists but belongs to a different paper;
  • the paper exists but the authors or year are wrong;
  • the paper was retracted years ago;
  • the DOI is a correction notice, cited as if it were the paper;
  • the cited preprint has since been published, with different numbers.

Asking the model to double-check does not help much: it checks against the same memory that produced the error. What works is code that asks the registries. This post walks through the checks we ended up with, the edge cases that broke our first versions, and the rule that matters most: a failed lookup is not proof that a paper is fake.

All the APIs below are free and need no key. The examples use only the Python standard library.

1. Ask Crossref about the DOI

Crossref registers most journal DOIs. GET https://api.crossref.org/works/{doi} returns the record: title, authors, year, and more.

import json, urllib.error, urllib.parse, urllib.request UA = {"User-Agent": "refcheck/0.1 (mailto:you@example.org)"} # Crossref asks for a contact def get_json(url): req = urllib.request.Request(url, headers=UA) try: with urllib.request.urlopen(req, timeout=20) as r: return r.status, json.load(r) except urllib.error.HTTPError as e: try: return e.code, json.load(e) except ValueError: return e.code, None def crossref(doi): status, data = get_json("https://api.crossref.org/works/" + urllib.parse.quote(doi)) return data["message"] if status == 200 else None 

2. A Crossref 404 proves nothing on its own

Our first version treated a Crossref 404 as "this DOI does not exist". That was wrong. Crossref is one of several registration agencies: datasets and software usually get DataCite DOIs (Zenodo, Figshare), and there are others such as mEDRA and JaLC.

The doi.org handle API answers across all of them. A registered DOI returns HTTP 200 with responseCode: 1; a DOI registered nowhere returns HTTP 404 with responseCode: 100.

def doi_exists_anywhere(doi): """True if some agency has the DOI, False if none does, None if we can't tell.""" status, data = get_json("https://doi.org/api/handles/" + urllib.parse.quote(doi)) code = (data or {}).get("responseCode") if (status, code) == (200, 1): return True if (status, code) == (404, 100): return False return None # timeout, 5xx, odd JSON: unknown, not "fake" 

Run against two DOIs:

10.5281/zenodo.24862986 Crossref: 404 doi.org: exists (a Zenodo record, DataCite) 10.1016/j.fake.2023.123456 Crossref: 404 doi.org: 404, responseCode 100 

Only the second one is "not registered anywhere". For the first, fetch the record from the DataCite API (https://api.datacite.org/dois/{doi}) and carry on.

Two smaller traps: a DOI may legally end in /, which most normalizers strip, so look up both forms before declaring it unregistered; and old SICI-style DOIs full of <>;: punctuation are often damaged by text extraction, so a miss on one of those should stay "unconfirmed".

3. Does the DOI belong to the cited paper?

A DOI that resolves proves that some work exists. It does not prove it is the work in the reference. Agents often attach a real DOI to the wrong paper, so compare titles and the first author.

We use token Jaccard similarity on normalized titles, with connective stopwords removed:

import re STOPWORDS = set("a an the of in on to for and or by with at as is vs from".split()) def title_similarity(a, b): def toks(s): s = re.sub(r"['’]s\b", "", s.lower()) # "Alzheimer's" == "Alzheimer" s = re.sub(r"[^a-z0-9 ]", " ", s) return {w for w in s.split() if w not in STOPWORDS} ta, tb = toks(a), toks(b) return len(ta & tb) / len(ta | tb) if ta and tb else 0.0 

The lesson here was about short tokens. An early version dropped tokens of two characters or fewer to reduce noise. Then "... lesion detection in CT" matched "... lesion detection in MR", and "hepatitis B" matched "hepatitis C". Short tokens are often exactly what tells two titles apart, so they stay:

title_similarity("Deep learning for lesion detection in CT", "Deep learning for lesion detection in MR") -> 0.67 

We accept a title-search hit as the cited work only at 0.8 or above, and even then only if the authors can be compared and agree, and the year is within one of the cited year. For a DOI that resolved, the test is looser in one direction: at least half of the cited title's words must appear in the record's title. That tolerates a citation that drops the subtitle without letting a short, related title match a longer one.

4. Retractions, corrections and notices

Crossref records carry update relationships, and since Crossref took over the Retraction Watch database, retractions show up here too:

  • updated-by: this work was later retracted, corrected, or got an expression of concern;
  • update-to: this DOI is a notice (a retraction or erratum) for another work, so citing it as a paper is an error;
  • relation.is-preprint-of: this preprint has a published version.
UPDATE_FLAGS = { "retraction": "retracted", "withdrawal": "retracted", "removal": "retracted", "partial_retraction": "partly_retracted", "expression_of_concern": "expression_of_concern", "correction": "corrected", "erratum": "corrected", "corrigendum": "corrected", } def update_flags(msg): flags = [] for u in msg.get("updated-by") or []: kind = re.sub(r"[\s-]+", "_", (u.get("type") or "").lower()) if kind in UPDATE_FLAGS: flags.append((UPDATE_FLAGS[kind], u.get("DOI"), u.get("source"))) for u in msg.get("update-to") or []: flags.append(("this DOI is itself a notice", u.get("DOI"), u.get("type"))) for r in (msg.get("relation") or {}).get("is-preprint-of") or []: flags.append(("preprint_published", r.get("id"), None)) return flags 

For the 1998 Wakefield paper in The Lancet (10.1016/S0140-6736(97)11096-0) this returns:

('corrected', '10.1016/s0140-6736(04)15715-2', 'retraction-watch') ('retracted', '10.1016/s0140-6736(10)60175-4', 'retraction-watch') 

Its Crossref title also starts with RETRACTED:, which is worth checking as a fallback for records whose update metadata is missing.

For biomedical papers, PubMed's E-utilities give a second opinion: a record of type "Retracted Publication", or a RetractionIn comment link. For arXiv IDs, the arXiv API returns the record (and asks for three seconds between requests).

5. Four verdicts, and "unconfirmed" is not "fake"

Every reference ends in one of four verdicts:

Verdict Meaning
confirmed A registry record matches the reference.
mismatch The work exists, but its authors, title, year or identifier disagree.
unconfirmed Nothing confirmed or refuted it.
identifier_not_registered The DOI, PMID or arXiv ID exists in no registry, and no title search found the work.

Flags such as retracted or preprint_published sit on top of the verdict.

The important one is unconfirmed. Books, theses, reports, standards and web pages are often in no registry at all, and APIs time out. If a tool calls those "fabricated", people learn to ignore it. So a network error, a 5xx, or a title search with no confident hit always lands in unconfirmed, together with what was looked up. Only an identifier that the handle registry says does not exist, and that no title search could find, is reported as not registered.

6. Is the quote really in the source?

A reference can be real and still not say what the sentence citing it claims. To check that, the agent reads the cited paper and records a quote and a page for each claim. A script then confirms that the quote is in the text.

Plain substring search fails here, because text extracted from PDFs is dirty: a two-column layout bleeds reference-list text into the middle of a sentence, line numbers land inside it, and hyphenation splits words. So the match is graded instead:

  • EXACT: the normalized quote is a contiguous substring;
  • INTERLEAVED: every quote token appears in order, with a bounded number of foreign tokens in between;
  • PARTIAL: most tokens appear in order (at least 80%), consistent with extraction damage; a person should look;
  • ABSENT: not even a partial ordered run.

The bound is what makes this work. An unbounded "tokens in order" match is meaningless, because the words of almost any short sentence appear in order somewhere in a long paper. The difference is the shape: a real extraction artifact interrupts a sentence once or twice, possibly with a dozen tokens (a bled reference line), while a spurious match interrupts at almost every word. So we allow at most 25 foreign tokens at any one join and at most 4 interrupted joins.

Two details we had to fix later: Chinese, Japanese and Korean text needs one token per character, because those scripts don't put spaces between words. And INTERLEAVED tolerates inserted tokens, so a quote that drops a "not" can still match. Any quote that turns on a negation gets reread by a person.

7. Where the model fits

Put together, the model does the parts it is good at: reading the manuscript, finding which sentence cites what, reading the cited paper and choosing a quote. The scripts do the parts it should not do from memory: whether a DOI exists, whose it is, whether it was retracted, whether the quote is really there. The agent's instructions say this outright: never mark a reference confirmed yourself, and never call one fabricated.

We packaged these checks as an agent skill for Claude Code, Codex and other agents that read the Agent Skills format. The full script handles BibTeX, LaTeX, Word, PDF and plain reference lists, writes a corrected .bib with only the disagreeing fields changed, and caches answers so reruns are cheap. It is standard-library Python, Apache-2.0 (parts adapted from MIT-licensed code, credited in the repo), in Researchzy/Researchzy-academic-skills (plugins/researchzy-manuscript/skills/researchzy-reference-check). If you only need the ideas, the snippets above are enough to start.

This article was written with the help of AI. The code was run and the API answers above were checked against the live services on 6 December 2026.