# Agent author's guide to the IHI tool kit This document is for the people building a tool-using LLM agent (Claude, GPT, Qwen or any other) whose loop that consumes the IHI OpenAPI server. The IHI side gives you data; the loop, the dialogue, and the front-end are yours. ## Stacks, staff, salon — three tiers, one collection The kit is a library with three tiers, and you choose your altitude: - **The STACKS** — the raw data tools on this API surface (`retrieve`, the `recall_*` family, `walk_thread`, `search_talks`, the catalog and graph lookups). You roam them yourself, one call at a time. This is the right tier for a quick lookup or when you want to steer every step. - **The STAFF** — the resident **librarian**: an agentic 235B harness that drives *every* tool in this kit behind verification gates (quotes and handles are checked against what was actually retrieved; fabrications are blocked), then hands back a **Collection Brief** — a short lede plus verified artifact cards with pull-quotes and reading-room doors, plus its investigation trace. Reach it with **`consult_librarian`** (POST `/v1/consult`). **When to consult vs. roam:** consult when a question is multi-step and you'd otherwise chain many stack calls, or when you need citable, *verified* quotes; roam the stacks for quick, single-hop facts. A consultation costs ~1–6 minutes (it is a real investigation, run synchronously); if the desk is empty you get a 503 and the stacks stay open. Pass `session` to continue a prior consultation. - **The SALON** — the human reading-room pages (served separately). That's where a person reads; the stacks and the staff are where an agent works. ## Read this first: data quality is under active remediation Most of the collection's *machine-derived* layers are being re-extracted and carry self-flagged defects. This changes how you must quote: - **The extraction layers are lossy.** The routes this concerns: `/v1/recall/keyword` rows, `/v1/recall/extras` shelves (conf-talks, conf-visual, thread-digests, ietf-drafts), the `summary` field of talk records (`/v1/talks/search`, `/v1/artifact`), and the people/affiliation fields of every non-`ih`/`ip` message corpus. These are 35B-derived and **UNDER REMEDIATION** — audit defect rates run **20–80%** on synthesized fields (`key_quotes`, `notable_claims`, `debate_summary`, titles, affiliations). Rows that come from these carry a `_schema_note` / `UNDER REMEDIATION` marker in the response — surface it. - **ALWAYS fetch the raw body before quoting.** A recall/retrieve/extras row is a *routing* result, not a source. Before you quote a message, name its subject, give a date, or assert an affiliation, pull the primary text with `fetch_message_body`, `recall_sources`, or `get_artifact` and quote *that*. A quote lifted from a summary field is a fabrication waiting to happen. - **`retrieve` fuses these same corpora** but may not stamp the remediation note on every row — treat any conf/-digest/-draft/non-core row as remediation-tier regardless, and verify against the raw artifact. ## Pace and identification - Send a `User-Agent` that names your agent and gives a way to reach its operator (an address or a URL). - One request per second from one address is the house pace. The edge sheds bursts with HTTP 429 and no `Retry-After` header; wait twenty seconds and resume. An address that keeps bursting is banned for a few hours. - Unrecognised callers share one rate pool per address. The curator can issue an `X-IHI-House` key to a named partner agent that exempts it. - `POST /v1/consult`, `POST /v1/feedback`, `GET /v1/feedback/inbox` and `PATCH /v1/feedback/{id}` answer 403 at the edge for everyone else, by design; the 403 is an HTML page, so check the status before parsing JSON. - `HEAD` is not implemented on the API routes (405). Probe with `GET` and `top=1` or `limit=1`. - Identifiers: a talk's `id` (16 hex characters) resolves at `/v1/artifact?handle=talk:` and `/v1/talks//deck-pages`; a `presentation_id` from `/v1/talks/search` is a different namespace (the presentations ledger) and does not resolve there; ids listed under `copies` are separate full records of the same talk held under other corpora. - Scores: `/v1/retrieve` puts authority rows (glossary, registry, RFC index) first with a fixed score of 10.0 and fused rows after with reciprocal-rank scores (about 0.01 to 0.1). Rank within the list; do not threshold across the two scales. A decade or year phrase in the query ("in the 1990s", "October 2021") sets a year band, reported back as `year_band_from_query`; pass `year_from`/`year_to` to override it. ## What's in the box - **`tools.json`** (served at `/agent-kit/tools.json`; source file `agent_tools.json`) — drop-in tool catalog in OpenAI-compatible function-calling shape. It maps researcher actions to IHI endpoints, with `retrieve` (the fused front door) and `consult_librarian` (delegation) at the top, then the specialist drills (`walk_thread`, `search_threads`, `search_talks`, the `recall_*` family, catalog and graph lookups), then the meta / gap tools last. **The `tools.json` catalog is authoritative for the exact tool set and count** — read it; do not trust a number quoted in prose. Pass its `tools` array to your model; dispatch to the `$endpoint` sidecar on each tool-call. These paths are relative to the IHI OpenAPI host. The public host `https://history.cooperate.social` serves the `/v1/*` data routes together with `/openapi.json`, `/docs`, `/redoc` and `/agent-kit/*` (checked 2026-10-19; an earlier edition of this guide said the schema and kit were not public, which is no longer true): - **`/openapi.json`** — full machine-readable OpenAPI 3.x spec, auto-generated from the FastAPI app. Use this if you want to generate a typed client (openapi-generator, oapi-codegen, etc.) rather than hand-rolling a dispatcher. - **`/docs`** — Swagger UI. Useful for humans exploring the surface before writing the loop. - **`/`** — server self-description. The first thing the agent should fetch on cold-start to discover route families. ## Picking your integration path Two paths, depending on how you want to wire the kit into your agent loop: ### Path A: the `tools.json` catalog (recommended for most cases) Simpler. Fetch the catalog from `/agent-kit/tools.json` (its source file is `agent_tools.json`). It is hand-curated for researcher workflow ergonomics — one tool per researcher action, not one per HTTP route. Each entry has the `function` shape Qwen / OpenAI / Claude (with translation) expect, plus a sidecar `$endpoint` field telling your dispatcher where to send the call. Your loop: ```python import json, httpx # IHI_API_BASE: the public IHI OpenAPI host. (A private replica serves the # same tree on an internal network; never hardcode an internal hostname into # a deployed agent loop.) IHI_API_BASE = "https://history.cooperate.social" catalog = httpx.get(IHI_API_BASE + "/agent-kit/tools.json").json() tools = [t for t in catalog["tools"]] # already in the right shape # In your chat loop, on a tool-call: def dispatch(name, arguments): spec = next(t for t in tools if t["function"]["name"] == name) ep = spec["$endpoint"] base = IHI_API_BASE if ep["method"] == "GET": path = ep["path"].format(**arguments) # path params return httpx.get(base + path, params=arguments).json() elif ep["method"] == "POST": return httpx.post(base + ep["path"], json=arguments).json() ``` ### Path B: generated client from `openapi.json` More machinery. Use openapi-python-client / openapi-generator to produce a typed SDK from `https://history.cooperate.social/openapi.json` (public since 2026-10). Then expose those functions as tools to your LLM. Useful if you want IDE autocomplete and strict typing in the loop's host language. ## System-prompt material A few facts your loop's system prompt should establish before tool-use begins: - **The IHI Catalog** is a record of the Internet's primary historical record: operational measurement datasets, mailing-list correspondence, oral histories, and contextual material that makes the technical record legible. - **Three record types**: Catalog Works, Catalog Authorities, Research Inquiries. Use `list_works` / `fetch_work`, `fetch_authority`, and `list_inquiries` / `fetch_inquiry` to retrieve. - **Retrieve first, then drill; delegate if you'd rather not drive.** `retrieve` is THE front door — one fused search (lexical + semantic + exact) over 4.8M artifacts. Open almost every question with it, then use the specialist tools to drill into what it surfaces. When a question is multi-step and you'd otherwise chain many calls — or you need *verified* quotes — hand the whole question to `consult_librarian` and get back a cited Collection Brief. Never guess a slug; resolve it from a search result. - **Body-author resolution discipline**: the Interesting-People mailing list (`ip` corpus) is a Farber-curated relay. The envelope `From:` address on those messages is the relay author (Farber), not the body author of the relayed content. When citing a witness from the IP list, use `fetch_message_body` to read the actual body and identify the body author. The same caution applies to Dewayne-Net, PRIVACY Forum, NNSquad, RISKS, and other operator-curated relays. The Catalog records this explicitly via the `body_author_note` field on each list_witnesses entry. - **Catalog gaps are first-class**: the `catalog_gaps` tool returns every cross-reference to a node that doesn't yet exist. The Catalog explicitly acknowledges what it is missing. An agent investigating a topic should feel free to surface gaps as part of its answer. - **Inquiries are dossiers, not finished essays**: an Inquiry has `established_facts`, `open_questions`, and `next_actions`. When the agent's research surfaces new evidence relevant to an open question, it should say so — the human curator will decide whether to update the dossier. ## The librarian's-memory recall primitive (`/v1/recall`) Beyond `search_catalog` (BM25/RAG over the curated Catalog), the OpenAPI surface exposes a unified recall over **both** the catalog (L3, ~2K chunks of curated Works/Authorities/Inquiries) **and** the corpus (L4: about 9.4 million preserved mailing-list messages in the inventory of 2026-10-09, of which about 2.1 million carry Phase-1 extraction). This is the shared external memory primitive described in the librarian's-hierarchical-memory architecture; it is meant to be called freely from agent contexts and to return sub-second results with verifiable source handles. **`POST /v1/recall`** — body: `{query, source: catalog|corpus|both, top, kind?, corpus?, year_from?, year_to?}`. Response: `{results, elapsed_ms, schema_version: "v1", cache_hit}`. Frozen schema at `/v1/recall/schema`. Per-query latency: corpus ≈ 140ms, catalog ≈ 13ms. **Source-fidelity rule (binding):** every result carries a verifiable handle. Corpus results carry `msg_id + corpus + ym (+ archive_url)`; catalog results carry `ark + url + doc_id`. When you propagate any recalled fact into durable output (essay, dossier section, message to a human), preserve the handle as a footnote. Paraphrase without source is a confabulation seed — the validator at the daemon and OpenAPI layers rejects results without source-fidelity fields. Don't drop them in your prompts either. **L3 → L4 drill-through:** `GET /v1/recall/sources?msg_id=...&corpus=...&ym=...` returns the raw mbox message bytes for any corpus hit; `GET /v1/recall/sources?doc_id=...&doc_kind=...` returns the raw Markdown source for any catalog hit. Use this **before** quoting a recalled fact in any durable output, so you can verify the language and context before footnoting it. **`GET /v1/recall/ping`** for health: model name, chunk counts, recent-100 p50 latency. **`GET /v1/recall/schema`** for the frozen JSON Schema (Draft 2020-12). ``` on_user_question(q): # 1. Recall against both layers hits = POST /v1/recall { query: q, source: "both", top: 10 } # 2. Drill to L4 for verification before quoting for h in hits.results[:3]: if h.index_source == "corpus": src = GET /v1/recall/sources?msg_id=...&corpus=...&ym=... else: src = GET /v1/recall/sources?doc_id=...&doc_kind=... verify_quote_against(src.raw) # 3. Render answer with footnotes preserved write_answer_with_footnotes(hits.results[:3]) ``` See `docs/playbooks/librarian-memory.md` for the deeper operational guidance — when to recall vs drill, cache hygiene, schema-version contracts across an agent population. ## Suggested first-call sequence for a new agent loop Pseudocode, not a binding pattern. **Every question opens with `retrieve`** (or, if you'd rather delegate the whole thing, `consult_librarian`): ``` on_user_question(q): # 0. If you don't want to drive the tools yourself, delegate: # brief = consult_librarian(question=q) # -> verified Collection Brief # Otherwise, drive it: # 1. THE FIRST MOVE — one fused search across every index hits = retrieve(query=q) # lexical + semantic + exact, RRF-fused # enumerate the concrete named entities the answer involves (IXes, # telcos, NOGs, people) and retrieve each literal name — the record # indexes names, not abstractions. # 2. Drill into what retrieve surfaced, with the specialist tools: for row in hits[:5]: if row.kind == "thread": walk_thread(msg_id=row.a_member_msg_id) if row.kind == "message": body = fetch_message_body(corpus, msg_id) # raw text before quoting if row.kind in ("work","authority","inquiry"): fetch_work(slug=row.slug) # 3. Exact-string gaps (Message-IDs, RFC#, draft slugs) -> recall_keyword # Roster questions ("did X present") -> search_talks # Community-produced artifacts (drafts, slides, papers) -> recall_extras # 4. Follow the cross-reference graph if a catalog node emerges neighbors = graph_neighbors(node_type="work", slug=...) # 5. If the draft answer cites something IHI doesn't hold yet, check # evidence_candidates (accession backlog). # 6. Compose answer + dossier-shaped notebook entry return answer, notebook_update ``` ## Notebook back-shape (advisory) When the loop writes the user's session into a notebook, the IHI side expects the eventual contributions (when the user authenticates and offers to give them back) to look like Inquiry dossiers — same shape as the existing `/v1/inquiries/{slug}` schema. Specifically: ```yaml title: "..." prompting_question: "..." prompting_author: "..." # the user, if authenticated prompting_date: "..." established_facts: - id: ef1 statement: "..." witnesses: [w1] confidence: high | medium | low last_verified: YYYY-MM-DD open_questions: - id: oq1 statement: "..." priority: P1 | P2 | P3 status: unresolved witnesses: - id: w1 type: work | authority | inquiry | message ref: quote: "..." archive_url: "..." ``` If the loop writes notebooks in this shape from the start, contribution back to the Catalog (when the user opts in) is a near-mechanical merge, not a re-authoring exercise. ## Term-disambiguation traps in operator-corpus searches The IHI corpora are operator-discourse, not LLM-discourse. Several tokens that read as obviously-AI in 2026 are heavily polysemous in 1990s–2010s network-operator traffic; treating their raw hit-counts as AI-content prevalence will mislead a longitudinal survey. Patron-confirmed traps: - **`LLM`** — almost always **LLMNR** (Link-Local Multicast Name Resolution, RFC 4795 / a DNS-side protocol) in pre-2022 hits. AI-sense `LLM` appears in volume only from late 2022. Filter by year or co-occurrence with `language model` / `transformer` / `prompt` to separate. - **`neural`** — the AusNOG poster domain `@neural.com.au` produces dozens of false hits 2007–2010 with zero AI content. Exclude `from:*@neural.com.au` (or filter by body co-occurrence) before charting "neural" frequency. - **`entropy`** — in operator traffic this is overwhelmingly **DNS message entropy / dns-0x20 source-port randomization** (Kaminsky-era hardening), not ML clustering or information theory. Pair with `cluster` / `embedding` / `loss` to disambiguate. Tokens that have so far behaved cleanly (operator-corpus signal maps to AI-content intent without heavy noise): `neural network`, `expert system`, `fuzzy logic`, `genetic algorithm`, `bayesian`. Multi-word tokens are generally safer than single-word ones; consider quoting and intersecting with an era-specific anchor (e.g. `"machine learning" AND nmlrg`) for RG-charter-era work. If you discover further traps during a survey, file them as `idea` feedback against `/agent-kit/guide.md` so the next surveyor inherits the disambiguation list. ## Corpus namespaces — the crosswalk (read before you pass a `corpus`) There are **three different corpus namespaces** in this kit and they do **not** interchange. The same real mailing list can be named differently depending on which tool family you hand it to: - **Message tools** — `recall_corpus`, `recall_keyword`, `fetch_message_body`, `find_witnesses_in_corpora` — take an **exact** name from `list_corpora` (~1600 of them). - **Thread / fused search** — `search_threads(by_corpus=…)` and `retrieve` — take **umbrella** names that auto-expand to decade shards. - **Extras shelves** — `recall_extras` — take one of a **fixed six-name enum**; these are a separate namespace from the message corpora entirely. | You want | Message tools (`list_corpora` name) | `search_threads` / `retrieve` `by_corpus` | `recall_extras` shelf | |---|---|---|---| | Internet-History list | `ih` | `ih` | — | | Interesting-People (Farber relay) | `ip` | `ip` | — | | **NANOG** | `nanog` **or** a decade shard `nanog-90s` / `-00s` / `-10s` / `-20s` | `nanog` (umbrella — auto-expands to the four shards) | — | | cisco-nsp | `cisco-nsp` (also `cisco-nsp-sanitized`) | `cisco-nsp` | — | | AusNOG | `ausnog` | `ausnog` | — | | SANOG | `sanog` | `sanog` | — | | AfNOG | `afnog` | `afnog` | — | | RIPE working groups | one corpus per WG: `ripe-anti-abuse-wg`, `ripe-routing-wg`, `ripe-dns-wg`, `ripe-address-policy-wg`, `ripe-ipv6-wg`, … | same WG name | — | | ARIN PPML | `arin-ppml` | `arin-ppml` | — | | com-priv | `com-priv` | `com-priv` | — | | tcp-ip list | `tcp-ip` | `tcp-ip` | — | | bind-users | `bind-users` | `bind-users` | — | | IETF WG / list mail | one corpus per list under the `ietf-*` prefix (1,300+ — use `list_corpora`) | the `ietf-*` name | — | | RFCs (standards texts) | — (not a message corpus) | `retrieve(kinds=["rfc"])` — **content-searchable**: `query="exterior gateway protocol"` surfaces the EGP-era RFCs by text, not just by number; lineage via `cited_rfc=[N]` + `graph_neighbors(node_type=rfc)` | `rfcs` | | Preserved documents (RIPE document series incl. ripe-001 Terms of Reference, MoUs, NCC quarterly reports, AFNIC decisions, administrative records) | — (some institutional MoUs also live as message-kind rows in the `ripe-pdf` corpus, subject = the doc filename/URL) | `retrieve(kinds=["document"])` — 3,308 preserved policy/institutional papers, distinct from conference `talk`s | — | | Internet-Drafts | — | — | `ietf-drafts` | | Conference talks / slides | — | — | `conf-talks` / `conf-visual` | | Synthesized thread digests | — | — | `thread-digests` | | BBN reports, oral histories, papers | — | — | `treasures-text` | **The `nanog` vs `nanog-90s` trap:** `list_corpora` lists BOTH the umbrella `nanog` and its four decade shards as real corpora. For a message tool, pass the granularity you actually want (`nanog-90s` for the 1990s only; `nanog` for the umbrella if you want everything). For `search_threads`/`retrieve`, pass the umbrella `nanog` and it expands for you. When in doubt, call `list_corpora` and copy the exact string — never guess a corpus name. ## The Librarian's Constitution — recommended practice for visiting agents The IHI corpus rewards a specific discipline. These are the rules the resident librarian works by; a visiting agent that follows them produces citations that survive scrutiny. Each rule ends with the failure it exists to prevent. - **Names are keys, not claims.** Your own knowledge may freely propose names, companies, and places *to search* — enumeration is free and is how you find a roster. But assert only what the record *returns*, with its handle. *Never assert an affiliation from memory (that is how a fabricated cofounder gets invented); never refuse to search a remembered name (that is how a real colleague is missed from a roster). The two failures are opposites; this one rule covers both.* - **Primary, or it didn't happen.** Before you quote a message, name its subject, give its date, or state anyone's affiliation, you must have fetched its verbatim body (`fetch_message_body` / `recall_sources` / `get_artifact`) *this* investigation. The enriched `Orgs:` / `People:` fields list entities *mentioned* in a message — never the sender's employer. *Reading "Orgs: MCI" as "the sender worked at MCI" is the misread that puts a wrong affiliation in a citation. Sender identity comes from the raw `From:` line alone.* - **A negative is the most expensive claim you can make.** Do not say "the collection lacks X" until you have (a) enumerated the named entities and keyword-searched EACH literal name with no corpus filter, (b) tried `recall_extras` on the conference shelves, and (c) spent real effort varying terms. Retry the bare token (the AS number, the hostname, the surname alone) before conceding. *An early "nothing in Rwanda" that a single surname search overturns is the one failure a patron will not forgive.* - **Quote integrity: verbatim, or nothing.** A quote is a string copied character-for-character from a fetched primary body, cited to its Message-ID. If you don't have one, say "I don't have a quotable primary source for this; the closest record is…" — never dress a paraphrase or a catalog blurb as a blockquote. *Formatting your own summary of the Morris-worm aftermath as if it were a period quote is fabrication, however faithful the paraphrase feels.* - **Walk the thread before you call it exhausted.** Once you hold ANY one message of a conversation, `walk_thread(msg_id)` returns the whole reconstructed thread — including **renamed sibling subjects** that keyword search cannot see. *Feinler's "30th Anniversary" message sat in the same thread as Braden's "cutover" — reachable only by walking, invisible to any subject search. Never declare a thread done without walking it.* - **Keyword craft: two or three plain tokens.** `recall_keyword` AND-matches plain tokens — no boolean operators, no quotes-within-quotes. Use surnames, not full names (`feinler`, not `Elizabeth J. Feinler`); use the record's own era vocabulary, not your paraphrase (`cutover` beats `survived`). If a query returns nothing, SHORTEN it before you vary it. *Long, natural-language keyword queries over-constrain into the void; the shelf indexes literal strings, not intentions.* - **When to just consult the librarian instead.** If a question is multi-step, needs several tools chained, or must come back with *verified* quotes and handles, don't hand-drive the stacks — call `consult_librarian(question=…)` and get a Collection Brief whose every quote and handle has already been checked against real retrievals. Drive the stacks yourself for quick, single-hop facts; delegate the hard, citation-graded questions. ## Updating the kit This kit is versioned alongside the OpenAPI spec. When the spec version bumps (visible at `/` — the server self-description — on your IHI OpenAPI host), re-fetch this directory and diff. Tools may be added; existing tool names and parameters are considered stable within a major version.