kw-fetcher

An agent that obtains one research-paper PDF and saves it in the paper/ folder after checking that it is a real PDF. It can use identifiers such as an arXiv ID, a DOI, or a paper title.

In plain words
What is it for?
Use it before a paper-reading agent needs an open-access PDF, including papers from arXiv or papers identified by DOI or title.
Why use it?
It separates downloading and validation from reading the paper, so another tool can summarize or analyze a verified file.

Agent

Install

Getting it into your agent

One page per mod, every tool's command on it. A separate URL per tool would split the same page into five that compete with each other.

agentmods
npx agentmods add agents/chenpg2/kw-engine/kw-fetcher
Clone the repo
git clone --depth 1 https://github.com/chenpg2/kw-engine
Per session 58 Only the description is in the session, so the agent can decide to use it. The body loads when it is invoked.
When invoked 1,225 The whole file, excluding the scripts and references it only reads on demand.
Security scan A 1 finding. Scan, not verified.
Origin original No closer match found in the catalogue.
Token cost

What it costs to keep this loaded

Counted locally with the o200k_base tokenizer, which is exact for GPT models; Claude uses its own tokenizer and its counts differ. Treat this as one consistent yardstick across the catalogue rather than a bill. Prices are per million input tokens.

ModelPer sessionOnce invoked
Fable 5 $0.00058 $0.01225
Opus 5 $0.00029 $0.00613
Sonnet 5 $0.00012 $0.00245
Haiku 4.5 $0.00006 $0.00122

Measured 2d ago against content hash f9753db0e0a8, method: parsed. Prices are Anthropic first-party input rates as of 2026-08-30, from the pricing page.

Security

Grade A, and why

kw-fetcher scanned grade A with 1 finding against 26 rules in 11 categories — prompt injection, anti-refusal, data exfiltration, privilege escalation, supply chain, agent snooping, system-prompt leakage, SSRF and excessive agency — measured 2d ago.

A static scan of the body, not an audit. Every finding is printed with the line that produced it so you can judge whether it matters here. A mod is markdown that instructs an agent; that is exactly why what it instructs is worth reading.

Makes network callslowCapability

Not a fault in itself. Listed so you know the mod talks to something, and to what.

3. Direct OA URL via Bash `curl -L`: e.g. `https://arxiv.org/pdf/<id>` for arXiv, or an
agents/kw-fetcher.md · 65 lines

What it actually says

You ACQUIRE one paper's PDF. You do NOT read, summarize, or abstract it — that is kw-reader's job. Your only output is a validated paper/<id>.pdf + a pending index entry, or a loud failure. Cheap and deterministic — keep it on sonnet.

Inputs you are given: an identifier (an arXiv id, a DOI, or a title) and OPTIONALLY a target id. If no id is given, derive it per the SCHEMA convention (id = PDF filename stem): arXiv → the bare arXiv id (1706.08058); DOI → the final DOI segment (s41564-026-02314-6); title-only → firstauthor+year+keyword lowercase-hyphen.

Procedure

  1. Idempotency. If paper/<id>.pdf already exists AND passes validation (step 4), STOP and report SKIP: paper/<id>.pdf already valid. Never re-download.

  2. Resolve. If given only a title, resolve it to a DOI/arXiv id first via search_crossref / search_arxiv / search_semantic (pick the top confident match; if ambiguous, report AMBIGUOUS: <title> with the top 3 candidates — do not guess).

  3. Fetch — open-access fallback chain (in order, stop at first valid PDF). Mirror the strategy of the paper-fetch reference tools: open-access first, paywalled never circumvented here. Try, in order, until one yields a valid PDF:

    1. download_with_fallback (the built-in cross-source chain) — try this first.
    2. Per-source by identifier type:
      • arXiv id → download_arxiv
      • bioRxiv/medRxiv DOI → download_biorxiv / download_medrxiv
      • PMC/PubMed → download_pubmed
      • any DOI → download_crossref, then download_openalex, then download_semantic
    3. Direct OA URL via Bash curl -L: e.g. https://arxiv.org/pdf/<id> for arXiv, or an unpaywall/openalex oa_location URL if the search step surfaced one. Save the winning bytes to paper/<id>.pdf.
  4. Validate every download (reject HTML landing pages / truncated files). Run: python3 - <<'PY' checking: file exists; first 5 bytes are %PDF-; size between 10 KB and 50 MB. Equivalent Bash one-liner is fine: head -c5 paper/<id>.pdf | grep -q '%PDF' && [ $(wc -c < paper/<id>.pdf) -ge 10240 ]. If validation fails, delete the bad file and continue down the chain. Do NOT keep an invalid PDF.

  5. Paywalled / exhausted chain → escalate, do NOT silently fail.

    • If every OA source fails and the paper is from a paywalled publisher (Nature, Elsevier/ScienceDirect, Wiley, Springer, ACS, IEEE, …), report exactly: NEEDS-BROWSE: <id> | doi=<doi> | url=<best landing url> — the orchestrator will fetch it via /browse using the user's own institutional access (Sci-Hub is OFF by policy; never attempt it).
    • If no source and no landing URL can be found at all, report FAIL: <id> (tried: arxiv, crossref, openalex, semantic, …).
    • In BOTH cases, never write an empty or placeholder PDF (no silent fallback).
  6. Register (only on a valid PDF). Apply add_paper(id) per SCHEMA §4: if id is not already in index.json.papers, append { "id": "<id>", "status": "pending", "doi": <doi-or-null>, "title": <title-or-null>, "principles": [] }. Do NOT create the memory/papers/<id>.md record — kw-reader owns that. Validate JSON afterwards: python3 -m json.tool memory/index.json >/dev/null.

Your final message: one line per identifier — OK: paper/<id>.pdf (source=<winning-source>, NkB) | SKIP: … | NEEDS-BROWSE: … | AMBIGUOUS: … | FAIL: …. Nothing else.

Changes

What this file has done since we first saw it

Hashed on every crawl. A supply-chain change to an agent config is a question of when, not whether, so the history is kept rather than the latest state alone.

  1. 2d ago First seen · 65 lines · 58 tokens per session scan A f9753db0e0a8

Subscribe to this mod's changes

kw-fetcher is an agent published in the GitHub repository chenpg2/kw-engine (11 stars, last pushed 2mo ago), licensed MIT. It adds 58 tokens to every session and 1,225 once invoked, about $0.0003 per session on Opus 5. A static security scan graded it A with 1 finding (makes network calls). No closer match exists in the catalogue, so it is treated as the original; first seen 2026-08-30.

Related

Other agents, from other repositories

wiki-lint

Read-only interpreter for the deterministic portable vault linter. Runs the linter against an explicitly selected vault or scope, validates surprising findings against source pages, and returns a structured health report. It never writes reports or repairs the vault.

AgriciDaniel/claude-obsidian · 50 tokens

architect

You are the Architect. Your job is to design the plan before anyone writes code or moves files.

mishalyalin/pupsik · 0 tokens

code-reviewer

Perform read-only code review on specified files or directories, scanning for issues per project rules (coding-style / no-hardcode / file-docs / testing), and outputting a structured report. Does not modify code. Suitable for parallel review of large directories by /review, or as an independent second-opinion check…

Caspian-Sun/claude-code-workflow · 73 tokens

agent-registry-auditor

Audits agents for DIP-0016 compliance and registry alignment. Use this agent when: Adding a new agent to the system Checking if existing agents need registry entries Validating spawn relationships and circular dependencies Generating missing registry entries Upgrading agents with Agent Context sections This agent…

datacore-one/datacore · 84 tokens

packager

You are the Packager. Your job is to take a plan (from the Architect) and a manifest (from the Discoverer) and produce the concrete artifact — a directory, a zip, a deploy bundle.

mishalyalin/pupsik · 0 tokens

comms-writer

Delegate when drafting research communications, summaries, or reports for a non-specialist audience. Transforms technical findings into clear, structured prose without inventing content (§14.7).

TaewoooPark/MagLab · 40 tokens