Build references from links you provide
In research workflows, investigators often accumulate specific URLs to articles, preprints, or bibliographic records during literature exploration. In this detour exercise, you direct the agent to fetch metadata directly from curated links, format the records as BibTeX, and audit extraction integrity.
Before you start: A project directory and a list of target URLs representing papers you intend to cite (Setup).
Background
This exercise illustrates the web as an analytical input pathway (Inputs). You supply publication links (PubMed entries, DOI URLs, preprint repositories, or publisher landing pages), and the agent retrieves each resource to extract titles, authors, publication years, and persistent identifiers.
Web interfaces vary significantly in how easily they yield bibliographic metadata:
| URL structure | Expected retrieval behavior | Optimal technical pathway |
|---|---|---|
DOI links (doi.org/...) |
High reliability; official DOI resolvers support HTTP content negotiation | Request Accept: application/x-bibtex headers to retrieve authoritative BibTeX directly |
| PubMed records | High reliability via API; standard web interfaces may block automated requests | Query PubMed E-utilities using the parsed PMID |
| Preprint repositories (arXiv, bioRxiv) | High reliability; open metadata headers and Dublin Core tags | Parse HTML <meta> tags or query repository APIs |
| Commercial journal pages | Variable; commercial firewalls or anti-bot protections frequently block scrapers | Fall back to DOI content negotiation or manual abstract pasting |
When an automated HTTP request fails (e.g., due to an institutional paywall or bot detection), language models are prone to fabricating missing citation fields from memory. Explicitly prohibit guessing: when a page cannot be retrieved, instruct the agent to declare the failure, fall back to identifier lookups, or request that you paste the metadata manually.
General methodology
Direct the agent to resolve each link using official resolvers or metadata headers, mandating that the source channel be documented for every record:
Here are links to <N> target publications: <url1> <url2> ... For each link, retrieve official bibliographic metadata using DOI content negotiation, PubMed E-utilities, or publication metadata tags. Append verified BibTeX entries to references.bib, ensuring each entry includes an active DOI or PMID. If automated retrieval fails for any link, report the error explicitly; do not guess or fabricate missing fields from memory. Finally, provide a summary table listing each entry alongside the exact retrieval mechanism used.
Workshop example · Imaging: chest radiographs
Start from: any folder (an existing references.bib is optional) (how to restore)
Produces: entries added to references.bib
Prompt
Here are links to two papers: https://pubmed.ncbi.nlm.nih.gov/34350409/ https://doi.org/10.1177/08465371231220885 For each, retrieve the metadata from the page or from its DOI or PMID record, and add a BibTeX entry to references.bib with the DOI or PMID. If you cannot retrieve a link, say so and do not guess any field. Then list the source you used for each entry.
Links used. Two papers on deep learning for pneumothorax: PMID 34350409 (a multicenter external validation study, 2021) and DOI 10.1177/08465371231220885 (a diagnostic test accuracy meta-analysis, 2024).
What to expect. Publisher pages and the PubMed web page often refuse automated access or return a bot-check page. A good agent:
- reports which page it could not read directly,
- falls back to the PubMed programmatic interface for the PMID and to the DOI service's BibTeX for the DOI, and
- lists the source it used for each entry.
A poor agent writes both entries from memory. Your environment may behave differently; the principle is the same.
Check. Open one of the papers in a browser and compare the title, authors, and year with the entry. If you also have pubmed_refs.py from the previous step, run verify; it only checks entries that have a PMID.
Verification criteria
- Complete link accounting: Every provided URL is explicitly accounted for as successfully added or transparently reported as failed.
- Persistent identifier presence: All created BibTeX entries contain valid DOI or PMID attributes.
- Empirical source verification: Spot-check two or three entries against original article pages to confirm author lists and publication years match.
Common pitfalls
| Symptom | Underlying cause | Resolution |
|---|---|---|
| Extraction blocked by publisher website | Commercial anti-bot protections or institutional paywalls | Extract the DOI string from the URL and query the official dx.doi.org resolver directly |
| Fabricated author lists or journals | The agent encountered an extraction error and filled missing fields from pre-training memory | Explicitly mandate: "Never guess missing fields; report extraction failures immediately" |
| Duplicate entries in bibliography | Multiple URLs referenced the same underlying publication | Direct the agent to de-duplicate against existing DOI and PMID attributes prior to appending |
Concepts behind this
- Inputs. Language models process information as text. Selecting appropriate ingestion pathways and source formats preserves data structure and prevents extraction errors. Go deeper →
- Verification. Language models can be confidently incorrect. Require empirical evidence, verify mathematical invariants, and use clean-context peer review to audit findings. Go deeper →
- Tools. Turning interactive prompts into parameterized scripts creates deterministic, testable tools that run identically on every execution. Go deeper →
Builds on: Orient the agent in a folder