Every answer, sewn to its page.
AgentLex is retrieval for documents where a wrong page is a wrong answer. It cuts clinical notes, contracts and statutes, classical texts and archives the way their authors did, finds by word and by meaning, and checks every quotation and every claim against the page it cites.
It was doubled from 500 mg to 1000 mg twice daily after an A1c of 8.4% 1, because the lower dose had been tolerated without GI upset 1. A repeat A1c is due in three months 1.
Labs
A1c 8.4% on 03/02, up from 7.6% in November. Creatinine 0.9 mg/dL, stable.
Assessment and plan
Type 2 diabetes mellitus (E11.9), above goal. Metformin increased from 500 mg to 1000 mg BID; patient tolerated 500 mg without GI upset. Continue lisinopril 20 mg daily. Repeat A1c in three months.
Yes. The agreement defines Personal Data to include an online identifier 1, and its schedule lists IP addresses among the online identifiers the Processor handles 2.
1.7 “Personal Data” means any information relating to an identified or identifiable natural person, including an identifier such as a name, an identification number or an online identifier.
Schedule 2 › Categories of data
Account names and email addresses; online identifiers, including IP addresses and device identifiers; usage records kept for no more than 90 days.
The copy was read against its original 1, and collation was a condition of a copy being sound; the editor's note defines it as comparing letter by letter 1.
كان الكاتب يكتب الكتاب على الورق ثم يقابله بالأصل حتى يصح (١). وكانت المقابلة عندهم شرطا في صحة النسخة.
(١) المقابلة: عرض النسخة على أصلها حرفا حرفا.
From a stack of pages to an answer you can check.
Six steps, each one an endpoint you can call alone. Use the whole thread, or only the part your pipeline is missing.
Cut where the author cut
Clinical notes by section, with medication lists and lab tables kept whole. Contracts and codes by their hierarchy, each definition a passage of its own. Classical print with body and footnotes apart. Prose by headings. A table is never split mid-row.
Find by word and by meaning
Keyword and semantic search fused by rank, then reranked. Queries are expanded the way your documents are written: HTN becomes hypertension, § becomes section. Quoted phrases must match. Filter by document, passage kind, metadata and date.
Copy, never paraphrase
A fast reader copies out only the sentences that answer the question. Code then looks for each one on its page; anything it cannot find there is discarded before you ever see it.
Research, then write
The question is searched before the model speaks, so sources arrive at once. An agent then searches what the first pass missed and reads where a passage is cut short. The answer streams, written from those pages alone.
Check it twice
Every quotation is matched letter for letter against the page it cites. Every claim is judged against its own sources and labeled supported, partial, unsupported or uncited, so your interface can show which sentences stand on the page.
Keep identifiers close
Social Security numbers, record numbers, phone numbers, emails and names after labels are masked before text reaches an embedding or language model, or redacted before it is stored. They are never logged.
Built for libraries where the page is the proof.
Each kind of document has its own chunker, chosen automatically or by name, so a passage is a unit its readers would recognize.
Clinical records
One patient's notes across years: medication and lab passages found by name and section, identifiers masked before any model sees them.
Law and policy
Statutes, contracts and rulings where an answer is only as good as the clause it cites, read as enacted, with its place in the hierarchy attached.
Classical scholarship
Arabic print and critical editions: body and footnotes apart, a hadith kept with its chain, every quotation checked letter for letter.
Archives
Letters, minutes and oral histories, with speakers, dates and places as filters. Search a decade of correspondence and land on the line.
In use today at
- KhateebNotesresearch and khutbah preparation
- Noorani LMScourse library search
- KhateebNotes Enterpriselive khutbah, citations on screen
Measured, not described.
Every setting was chosen by a race on real questions, graded the same way for every variant. Run the same race on your own corpus with POST /evaluate.
The benchmark that ships with AgentLex
Three fictional corpora, 25 questions each, every answer a verbatim passage in a named document. scripts/bench.mjs reruns it on any build; the console loads the same corpora.4
| Corpus | Documents | Keyword | Hybrid | Hybrid + rerank | Found in top 10 |
|---|---|---|---|---|---|
| Clinical notes | 53 encounters, 10 patients | 0.80 | 0.83 | 0.89 | 25 of 25 |
| Legal texts | 12 contracts, codes and opinions | 0.74 | 0.73 | 0.95 | 25 of 25 |
| Archive | 32 letters, minutes and transcripts | 0.86 | 0.90 | 0.96 | 25 of 25 |
data/fixtures.A small API with the checks built in.
JSON over HTTP, two SDKs with no dependencies, and an event stream your interface can render as it arrives.
import { AgentLex } from "agentlex"; const agentlex = new AgentLex({ apiKey: process.env.AGENTLEX_KEY }); // Identifiers are masked before text reaches any model. const col = await agentlex.collections.create({ name: "Cardiology notes", settings: { mask_identifiers: true }, }); await agentlex.documents.add(col.id, { title: "Progress note", metadata: { patient: "MRN-SYN-0042", date: "2026-03-02" }, text: note, });
const hits = await agentlex.search(col.id, { query: '"metformin" dose change', filters: { metadata: { patient: "MRN-SYN-0042" }, kinds: ["medication", "plan"], date: { from: "2026-01-01" }, }, }); // Each hit: a page, its best passages with offsets, // and a citation id that never changes. hits.results[0].citation; // "AL-7C21E0B4"
const stream = await agentlex.research(col.id, { question, tier: "fast", stream: true, }); for await (const event of stream) { if (event.type === "delta") render(event.text); if (event.type === "claims") mark(event.counts); }
The research stream
NDJSON, one event per line, in this order.
- statussearching
- query"metformin" dose change · hybrid · 8
- sources11 pages, 4 documents
- deltaIt was doubled from 500 mg to…
- answer3 citations
- claims3 of 3 supported
- doneresult, verification, usage
Any text format
Text, Markdown, HTML, CSV, TSV, JSON records and printed pages with their numbers.
Your models, or ours
Embeddings from Jina, OpenAI or your own server; reranking from Jina, Cohere or Voyage; answers from Claude.
Read the reference
Every endpoint and field in the docs, plus an OpenAPI file.
Questions, answered.
Anything else, write to us.
What is AgentLex?
Who is it for?
Does my data train a model?
Which formats and languages?
Can it run in my own cloud?
How is a quotation verified?
What happens when the sources do not answer?
Built for records that carry names.
The safeguards HIPAA's Security Rule asks of software are built into AgentLex, each one tested, and we sign business associate agreements. Ask us for the control mapping or a BAA.
Bring a library. Ask it anything.
For a dedicated index in your own cloud, with your own models, talk to us. To see it work first, load a sample library in the console.