Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 23 additions & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,29 @@ which ones in the PR.
for them: you should understand the change, you should have run the tests, and
you should be able to answer review questions about it.

## Contributing a recipe

A recipe is a short guide that helps an AI agent do one kind of job with Chatty,
text-fetch and LitKit, such as finding every published model of a system. Recipes
live in [`docs/recipes/`](docs/recipes/) and are described in
[ADR 0009](docs/adr/0009-chatty-recipes-job-library.md). To add one:

- **Copy [`docs/recipes/TEMPLATE.md`](docs/recipes/TEMPLATE.md)** to a new file
named after the job, and add a line for it to the table in
[`docs/recipes/SKILL.md`](docs/recipes/SKILL.md).
- **Show that the job needs the suite.** Name the capabilities it depends on.
A job that an agent can do as well without a corpus, such as summarizing one
paper, does not need a recipe.
- **Keep it short and general.** A recipe is guidance, not a script. Keep worked
examples out of the recipe; they belong with the demonstrations.
- **Test it.** Have an agent follow the recipe on a small public corpus, and say
in the PR what you asked and what it delivered.
- **Use only public documents** in examples. Never include confidential,
export-controlled or personal material.

Recipe pull requests follow the same rules as code: sign off your commits, and
see [Credit](#credit) for how contributors are listed.

## Credit

Everyone whose code is merged is listed in [`CONTRIBUTORS.md`](CONTRIBUTORS.md),
Expand Down
99 changes: 99 additions & 0 deletions docs/adr/0009-chatty-recipes-job-library.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,99 @@
# ADR 0009: Chatty Recipes, a Library of Agent Job Guides

- **Status:** Proposed
- **Date:** 2026-12-03
- **Affected Repositories:** `lanl/chatty` (`docs/recipes/`, `src/chatty/cli.py`, `pyproject.toml`, `CONTRIBUTING.md`), `lanl/litkit` (retrieval queries), `lanl/text-fetch` (reference resolution)

## Context

ADR 0006 made the suite usable by AI coding agents: JSON commands, named corpora, and the `chatty-corpus` skill, which teaches an agent *how* to call the tools. It does not tell an agent *what to do* for a user who arrives with a goal such as "I'm reviewing this grant" or "find every model of X".

Users who are not developers do not know what to tell a tool. The agent has to ask the right questions, choose a route through the suite, and know when the job is done. Writing that guidance once, per kind of job, makes common work easy and repeatable.

Many tasks people bring to an agent do not need this suite. A plain agent can summarize one paper or draft prose. The library must show what the suite adds: the work an agent cannot do with web search alone.

## Decision

### 1. One skill, `chatty-recipes`, plus a library of recipes

- A **recipe** is a short guide for one kind of job. The library lives in `docs/recipes/`, one Markdown file per recipe, with `TEMPLATE.md` for new ones.
- `docs/recipes/SKILL.md` defines the `chatty-recipes` skill. It is a menu: one line per recipe saying when to use it. The agent opens a recipe only when the user's goal matches it, so the library can grow without crowding the agent's context.
- Recipes refer to the `chatty-corpus` skill for command details instead of repeating them.

### 2. Recipes are guidelines, not scripts

A recipe tells the agent what to ask, which route usually works, what to deliver, and what goes wrong. The agent adapts it to the user. Every recipe has the same short sections:

| Section | Content |
|---|---|
| Job | One sentence: what the user wants |
| Needs the suite because | The suite capabilities the job depends on (section 3) |
| Ask the user | The few things the agent needs before starting |
| Route | The usual path through the suite |
| Deliverable | What the user gets |
| Done when | Checks the agent can run itself |
| Pitfalls | What usually goes wrong |
| Needs | Suite features the recipe relies on that are not yet released, if any |

Demos are not part of a recipe. A recipe stays generic; a worked demonstration lives in `docs/demos/`, which is created with the first demonstration.

### 3. A recipe must need the suite

A recipe is admitted when its job depends on at least one of these capabilities:

1. **Completeness:** exact search over every passage of a corpus, up to all of PMC OA, so the agent can count and can show that something is absent.
2. **Full text:** sections, tables and equations, not only abstracts.
3. **Citation graph:** corpora grown along references and citations, and passages that record which references they cite.
4. **Checkable citations:** a handle for every passage (`pmcid:PMC…#chunk:N`, `file:…#p:N`).
5. **Private and offline use:** local indexing and retrieval with no LLM endpoint, OCR, offline operation on air-gapped systems (LitKit's Charliecloud container today; a suite container is proposed in ADR 0005), and OSTI technical reports.
6. **Lasting, shared corpora:** named corpora that persist, can be attached read-only by a group, and can be rebuilt or updated from saved plans.

A few everyday recipes that use only some of these are welcome, to show the range of documents the suite handles, including manuals, policies and procedures.

### 4. Three featured recipes

The library starts with three recipes, each with a planned demonstration. Others can be added later under the rules above.

They rest on a foundation recipe, **`build-corpus`**, which builds a topic corpus on demand: it asks for the topic, seeds, date range, citation depth and size cap, previews the search before fetching, expands along citations and indexes a named corpus. The featured recipes use it when no suitable corpus exists, and two of their demonstrations start by building one.

- **`census`** finds every instance of something in a corpus, such as every model of a system or every reported value of a quantity, and tabulates it with a handle in every cell. Demonstration: every within-host viral dynamics model in PMC OA, sorted by virus and formalism, together with every reported estimate of the virion clearance rate constant *c*.
- **`reference-check`** checks a manuscript's reference list before submission: every reference exists, its bibliographic details are correct and verified against authoritative records, and it is relevant to the sentence that cites it. Fabricated or garbled references in a submitted paper or preprint now carry real consequences for authors. Demonstration: a draft preprint on a network simulator, checked against a corpus built on demand from its references and from papers on SBML, BioNetGen, PEtab and other simulators.
- **`for-and-against`** takes a claim and returns the evidence for it and against it as the literature stands, with a handle for each piece of evidence and the conditions under which it was obtained. Demonstration: the claim that follicular dendritic cells, or latently infected cells, are the key viral reservoir preventing a cure for HIV.

### 5. Recipes ship with Chatty

The recipes are installed with Chatty, like `chatty-corpus`, so an agent on an air-gapped machine has them. `chatty skill` gains a way to write the `chatty-recipes` skill folder (its `SKILL.md` and recipe files) to a path the user chooses.

### 6. Outside contributors can add recipes

`CONTRIBUTING.md` explains how to propose a recipe: copy the template, show that the job needs the suite, test the intake with an agent on a small public corpus, and sign off commits.

## Feature gaps found by the recipes

The table distinguishes commands available on `main` from work still needed for the recipes.

| Gap | Repository | Recipe and reason | Status |
|---|---|---|---|
| Batch screening: run a model from an OpenAI-compatible endpoint, such as an open-weight model on a GPU node, over a list of candidate papers with written criteria | `chatty` | `census`: screening tens of thousands of abstracts is the costly step. A batch command keeps it out of the agent's own loop and off a commercial model. | Open; to be decided in its own ADR |
| Export every match from exact and lexical search, not a capped top list | `chatty`, `litkit` | `census`: a census needs the full candidate list. Current commands return at most `--limit` results with no paging. | Open |
| Find the papers that cite a given paper, and every passage that cites it | `chatty`, `litkit` | `census`: finds papers that cite a field's foundational work without using its keywords. `for-and-against`: shows how later papers received a key result. | `chatty cited-by` is on `main` (#113, #125) |
| Show each passage's citations, resolved to the cited paper's identifiers and to its handle when that paper is in the corpus | `chatty`, `litkit` | `for-and-against`: tells a passage reporting its own result from one repeating another paper's, and lets the agent follow it. | `chatty refs` is on `main` (#113, #125). Adding citations to `retrieve` output is still open. |
| Find papers that share many references with a given list | `chatty`, `litkit` | `reference-check`: finds closely related papers the manuscript does not cite. | The overlap can be computed from `chatty corpus graph` on `main` (#113, #125). |
| Resolve a list of references against authoritative records (Crossref, PubMed, Europe PMC), reporting field-by-field differences and retraction status | `text-fetch` | `reference-check`: verifying bibliographic details is the core of the recipe. | Open |
| Build a topic corpus with one Chatty command | `chatty`, `text-fetch` | `build-corpus`: one budget across sources and citation expansion, with a preview. | `chatty corpus create --topic` is on `main` (#108, #125) |
| A LitKit release that includes the bibliography and citation-marker index | `litkit` | All three recipes: the index was merged after LitKit 0.4.0. | Open |
| A PMC OA index | infrastructure | `census`: the demonstration runs over all of PMC OA, built with LitKit's multi-node SLURM build (ADR 0005). | Open |

## Consequences

### Positive

- Users get guided through common jobs without knowing the suite's commands.
- Each recipe states what the suite adds, which keeps the library focused and makes the case for the suite in talks and documentation.
- Recipes expose missing features early, as the `census` recipe did.

### Trade-offs and follow-up work

- Recipes can drift from the CLI. Each recipe's commands should be checked in CI the way the `chatty-corpus` examples are.
- Recipe quality depends on review. The template and contribution rules keep recipes short and comparable.
- Gaps marked open become issues under lanl/chatty#65; the others are tracked by their pull requests.
1 change: 1 addition & 0 deletions docs/adr/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,3 +14,4 @@ Each ADR lists the affected repositories (`lanl/chatty`, `lanl/text-fetch`, `lan
| [0006](0006-agent-readiness-named-corpora-cli-and-executors.md) | AI-Agent Readiness, Named Corpora, Structured CLI, and Execution Backends | Proposed | `chatty`, `litkit`, `text-fetch` |
| [0007](0007-progressive-retrieval.md) | Progressive retrieval in the Chatty suite | Proposed | `chatty`, `litkit` |
| [0008](0008-corpus-modes.md) | Corpus modes and research guidance | Proposed | `chatty` |
| [0009](0009-chatty-recipes-job-library.md) | Chatty Recipes, a Library of Agent Job Guides | Proposed | `chatty`, `litkit`, `text-fetch` |
17 changes: 17 additions & 0 deletions docs/recipes/SKILL.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
---
name: chatty-recipes
description: Guides for common jobs done with Chatty, text-fetch and LitKit, such as finding every model or measurement of something in the literature. Use when a user describes a goal rather than a command. Each recipe says what to ask the user, which route usually works, and what to deliver.
---

# Chatty recipes

A recipe is a guide for one kind of job, not a script. Read the matching recipe, ask the user what it lists, then adapt the route to their goal. For command details, use the `chatty-corpus` skill (`chatty skill`).

| Recipe | Use when the user wants to… |
|---|---|
| [build-corpus](build-corpus.md) | build a topic corpus on demand. Other recipes use it when no suitable corpus exists |
| [census](census.md) | find every instance of something in the literature (every model of a system, every reported value of a quantity) and tabulate it |
| [reference-check](reference-check.md) | check a manuscript's references before submission: they exist, their details are correct, and they support the sentences that cite them |
| [for-and-against](for-and-against.md) | weigh a claim: gather the evidence for it and against it, as the literature stands |

If no recipe matches, work from the `chatty-corpus` skill directly.
29 changes: 29 additions & 0 deletions docs/recipes/TEMPLATE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
# Recipe name

**Job:** one sentence saying what the user wants.

**Needs the suite because:** which of its capabilities the job depends on (completeness, full text, citation graph, checkable citations, private and offline use, lasting shared corpora). See ADR 0009.

## Ask the user

- The few things you need before starting. Mark anything optional.

## Route

1. The usual path through the suite. Guidance, not a script.

## Deliverable

What the user gets.

## Done when

- Checks you can run yourself.

## Pitfalls

- What usually goes wrong.

## Needs

Suite features this recipe relies on that are not yet released. Delete this section when there are none.
36 changes: 36 additions & 0 deletions docs/recipes/build-corpus.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
# Build a corpus

**Job:** build a topic corpus on demand, for questions or for another recipe.

**Needs the suite because:** it requires searching literature sources with previews and caps, growing the corpus along citations, indexing locally, and keeping a named corpus that can be rebuilt or updated later.

## Ask the user

- The topic, in a sentence.
- Seed papers, if any.
- Date range.
- How far to follow citations: references, citing papers, or both.
- Size cap.
- Optional: favor reviews; authors to include; sources beyond Europe PMC (arXiv, bioRxiv, OSTI, local PDFs).

## Route

1. **Preview** each search with `--dry-run --json`, including the citation expansion options (`--expand`, `--expand-references`, `--expand-citations`) and `--max-expansion`. Expansion works on Europe PMC results only. Report the matches, a sample of titles, and what the caps cut. A preview with expansion saves its plan.
2. **Agree** the caps and expansion with the user before fetching.
3. **Fetch** exactly what was previewed: pass the saved plan to `--from-plan` with `--yes --json`. A search without expansion is fetched by repeating it without `--dry-run`, with `--yes --json`.
4. **Index** into a named corpus.

## Deliverable

A named corpus, and a short record of its sources, queries, caps and counts, so it can be rebuilt or updated later.

## Done when

- The corpus indexes cleanly.
- A few test questions return relevant passages.

## Pitfalls

- Broad queries that grow out of control after citation expansion.
- Author searches that pick up other people with the same name.
- Papers without open full text, which arrive as abstracts or not at all.
42 changes: 42 additions & 0 deletions docs/recipes/census.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
# Census

**Job:** find every instance of something in the literature, such as every model of a system or every reported value of a quantity, and tabulate it.

**Needs the suite because:** it requires completeness (exact search over every passage), full text and tables, the citation graph, and a checkable citation for every entry.

## Ask the user

- What to find, and where the scope ends.
- How to categorize the results.
- What to record for each entry.
- Which corpus: an existing one (such as a PMC OA index) or a new topic corpus.
- Optional: a known list (a review's table, papers the user knows are in scope) to measure recall.

## Route

1. **Gather candidates.** For a new corpus, follow [build-corpus](build-corpus.md), expanding along references. Then search with `--mode exact` and several phrasings, including notation and synonyms. Do not rely on the default hybrid mode: it searches only a shortlist of papers.
2. **Screen.** Sort candidates into real instances and papers that only mention one, first by title and abstract, then by full text for the survivors.
3. **Tabulate.** Fill each row from the paper's Methods, Results or tables. Give each cell a handle. Record whether a value was measured or estimated in the paper, or taken from another paper.
4. **Check recall** against the known list, if there is one.

## Deliverable

A table with a handle in every cell, sorted into the user's categories, and a short report: the corpus and search terms used, recall, exclusions with reasons, and blind spots.

## Done when

- Every row has a handle showing that the paper contains the instance.
- Recall is reported, or the report says why it could not be measured.

## Pitfalls

- Look-alike hits: the same word or symbol meaning something else.
- Duplicates: one model or value reported under different names, or repeated by later papers.
- Values copied from another paper counted as new ones.
- What the corpus cannot see: papers outside it, supplements, figures.

## Needs

- Batch screening with a model from an OpenAI-compatible endpoint (a future ADR).
- Export of every match from exact search, not only the top `--limit`.
- A "papers that cite X" query, and a LitKit release with the bibliography index.
42 changes: 42 additions & 0 deletions docs/recipes/for-and-against.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
# For and against

**Job:** the user gives a claim; return the evidence for it and against it, as the literature stands.

**Needs the suite because:** it requires full text (Results and Methods, not abstracts), searching a whole corpus rather than the first few web results, the citation graph (how later papers received a result), and a checkable citation for every piece of evidence.

## Ask the user

- The claim, in one sentence.
- Scope: which organisms, systems or conditions matter.
- Which corpus: an existing one, or a topic corpus built now (see [build-corpus](build-corpus.md)).
- Optional: key papers the user already knows.

## Route

1. **Search** the corpus for experiments that test the claim, using exact and hybrid search over Results and Methods, with several phrasings. Search explicitly for failures, null results and "in contrast" passages, not only for support.
2. **Follow reception:** if key papers are known, read every passage in the corpus that cites them, to see how later work confirmed, qualified or disputed them.
3. **Sort** each piece of evidence into supports, contradicts or qualifies, and record its method and conditions.

## Deliverable

- **The claim.**
- **Evidence for:** each piece with a handle, method and conditions.
- **Evidence against:** the same.
- **Verdict:** a short paragraph on where the evidence agrees, where it conflicts, and whether different conditions explain the conflicts.

## Done when

- Every piece of evidence has a handle.
- The report names the corpus and search terms, so the user knows what was not searched.

## Pitfalls

- Counting one result many times because many papers repeat it.
- Treating a mention as evidence: "X is thought to…" is not an experiment.
- A one-sided search that finds only support.
- A corpus too narrow to contain the counter-evidence.

## Needs

- Retrieval output that shows which references each passage cites.
- A query for every passage in the corpus that cites a given paper, and a LitKit release with the citation index.
Loading
Loading