“If you follow only one source on AI in newsrooms, make it this one.”
Building a reliable archive chat
AI For Newsroom
A reusable architecture and implementation guide for newsrooms, document libraries, and other searchable collections.
An archive chat has two jobs. It must understand what the user wants across turns, and it must retrieve evidence that can support the requested answer. Give the language model responsibility for interpreting ambiguous language and explaining evidence. Give the database responsibility for exact matches, counts, chronology, metadata, and access. This division keeps the conversation flexible and the underlying results reproducible.
Current question + recent turns
Validated query plan
SQL
facts
Search
+ evidence
Direct lookup
+ document text
Templates or cited synthesis
Answer, scope, sources, and continuation
1. Decide what the archive can promise
| User asks | Operation and expected result |
|---|---|
| “What are the 10 newest articles?” | Query metadata and sort by publication time with a stable article ID tie-breaker. Apply the requested limit. |
| “List everything published last month about X.” | Apply the publication window and an explicit match rule. Return a pageable inventory and, if requested, a CSV from the same query. |
| “Do we have anything on X?” | Resolve the entity or phrase, search all eligible text, and return a scoped yes or a scoped zero. Include a few article examples for a positive result. |
| “How many articles mention X in 2024 vs 2025?” | Count distinct article IDs in each period using the same predicate. State the match rule. |
| “How many did this author write?” or “Who wrote the most?” | Query verified byline metadata. State how coauthored pieces are counted. Report partial coverage when historical bylines are missing. |
| “Is this article indexed?” or “Open article 12345.” | Resolve an exact identifier and check the requested state under the caller’s permissions. Article identity, searchable text, and available embeddings are separate facts. |
| “Summarize article 12345.” | Resolve the article first and synthesize from its authorized text. |
| “What did we publish on 23 November?” | Query the publication window. Add a synthesis step only if the user asks for a digest. |
| “What happened on 23 November?” | Retrieve passages that describe the event date. Later publications can provide relevant evidence. |
| “What did we write about X, and what themes recur?” | Retrieve and rank passages, then synthesize selected coverage with citations. If the user also asks for a count, compute it separately using an explicit predicate. |
An exhaustive answer needs a defined set. “Articles containing this phrase,” “articles tagged housing,” and “articles with verified mentions of this person” are reproducible sets. “Everything relevant to housing” needs an editorial definition before it can support an exact total. Offer selected coverage or ask the user how to define the set when that choice matters.
The same rule applies to other metadata requests. Issue completeness needs a list of expected article IDs. A republish relationship needs canonical metadata or comparably strong evidence. A similar title or identical fingerprint can support a narrower statement about the records.
2. Plan the request before searching
Start with deterministic handling of common and unambiguous requests. Add a model fallback for phrasing the rules cannot classify reliably. Constrain its output to a small schema and validate it on the server. Keep SQL, authorization, allowable fields, sort directions, result limits, and date calculations in trusted application code.
A practical plan contains:
- Operation such as count, exists, list, lookup, compare, export, or synthesize.
- Subject and match rule such as a quoted phrase, a resolved entity with approved variants, a metadata identifier, or a thematic query.
- Constraints such as document type, section, publication window, explicit free or paid selection, ordering, and limit.
- References such as prior filters or stable IDs of articles shown in the preceding answer.
- Presentation such as the reply language and requested format. Keep reply language independent of the archive language.
Carry a compact previous request and the IDs of recently displayed sources. Resolve “And about the capital?” by changing the subject while preserving the prior existence operation. Resolve “What about last year?” by replacing the time window. Resolve “Tell me more about the second one” to a displayed article ID, then check access again. Apply previous filters when the reader refers back. Let a standalone request start fresh.
Retain the original wording alongside the resolved subject. Translate useful search terms into the collection’s language while preserving names, identifiers, and quoted phrases. Convert relative dates in the archive’s editorial timezone using an injected clock and a half-open window from local midnight to the next local midnight. Test daylight saving transitions and month boundaries. When ambiguity would materially change a count or the identity of a source, ask one specific question.
3. Make the structured path reliable
Use stable article IDs as the unit of inventory. Keep metadata at the article level and searchable passages linked to their article and revision. Share one predicate across chat, counts, lists, and exports so figures and rows agree. Count article IDs once, even when several passages match. For complete lists, use keyset pagination with a timestamp and stable ID. Bind the cursor to the query and scope, define how undated entries are handled, and use a consistent snapshot for counts returned with a page or for a complete export.
Search the whole eligible article for mentions. A title-and-lead predicate can miss the only mention in the body. For names, normalize case and diacritics, match on word boundaries, and look for coherent name forms. Use a curated or corpus-backed vocabulary to propose spelling corrections and inflections. Require supporting matches before treating a candidate variant as the same entity. A shared first name alone cannot establish a match. For literal quotes, define how punctuation, accents, and whitespace behave, escape search metacharacters, and test phrases split across chunks.
Use explicit grouped queries for period comparisons and top authors. Track metadata coverage so a sparse byline or tag index produces a qualified answer. On an existence request, a small page of verified examples often suffices. Compute a total when the user asks for it or when it is needed for the interface.
Keep structured execution independent of the answer-generation provider and embedding service. A failed database request should become an unavailable result. A completed query with zero verified matches should describe the searched scope and predicate.
4. Build synthesis from relevant evidence
- Retrieve complementary signals. Combine lexical name and phrase matching with semantic passage retrieval for thematic requests. Apply hard filters in each retrieval path. Rank for the actual task. Use publication time as the primary ordering for chronological requests and as a relevance tie-breaker where appropriate.
- Check relevance before generation. A full candidate list or a long excerpt can still provide no evidence for the question. For a query about a named person or place, require a relevant passage or a verified entity match. Keep related suggestions separate from the evidence cited by the answer.
- Assemble context and citations together. Each evidence passage should have a stable reference to its source article. Use the same mapping when building the prompt and rendering links. Keep source text as data inside the model context. In a date digest or mixed count-and-summary request, start with the structured inventory and select evidence from it.
- Ask for short, grounded answers. Lead with the answer, preserve the source’s names, dates, and qualifiers, and cite factual claims. Let the amount of evidence determine the length. Validate that citation IDs resolve to the passages actually supplied. Review claim support separately on labeled samples. Checked links alone cannot verify that a sentence follows from the text.
- Render the outcome directly. Use a localized label such as “Selected coverage” for thematic summaries. Use a specific no-match, clarification, incomplete-coverage, or unavailable message when appropriate. If generation fails after retrieval succeeds, show verified article links and explain that the summary is unavailable.
Prefer a strong evaluation set before choosing a larger model or adding a reranker. Measure interpretation with fixed retrieval, retrieval with fixed plans, and generation with fixed evidence. That makes it possible to find which change actually improved the answer.
5. Apply permissions consistently
Derive the role from the authenticated server session. Apply its capabilities in SQL before retrieving text for ranking, hydration, generation, counts, exports, or follow-ups. Validate every user-supplied source ID under the current session. Use the same capabilities for the UI gate and the API. A reader who can search paid articles needs access to the chat surface that displays them. For a subscription archive, administrators, newsroom staff, and paying subscribers might search both free and subscriber-only articles. Regular and anonymous users would search the free archive.
Partition caches by the effective access scope and query. Invalidate indexed results across instances after an unpublish, edit, or permission change. Avoid leaking restricted catalog counts or identifiers through comparisons, suggestions, logs, or exports. Include a role-matrix test for every new retrieval path.
6. Operate the index as a live copy of the source
Use the CMS, repository, or catalog as the source of truth. Persist searchable text and metadata before generating embeddings. That keeps new records visible in exact and lexical search during embedding outages. Track each stage so “present in the catalog,” “searchable,” and “embeddings ready” can be reported separately.
Use authenticated update and withdrawal events for fast delivery, plus a scheduled reconciliation that can recover missed events and stale revisions. Make writes idempotent. Use source timestamps or revision IDs to prevent late work from restoring an old revision. Process removals under the same consistency rules as updates. Recheck cache validity after the index commits the change.
Measure publish-to-search lag, publish-to-embedding lag, missing or stale IDs against a known catalog checkpoint, and long-running failures. Show the most recent write time for what it is. A recent write alone cannot establish full coverage of an issue or date range. Keep operational reports available to authorized staff. Start with the database and search infrastructure already in place. Add a dedicated search engine, queue, or reranker when latency, recall, or recovery data justifies it.
7. Build the release gate around real questions
| Check | Evidence required before rollout |
|---|---|
| Conversation understanding | A follow-up preserves or changes the intended operation, topic, date, and filters. An ordinal reference resolves to the displayed article. |
| Structured correctness | Counts, ordering, pagination, and CSV rows agree with a known fixture. Include equal timestamps, undated articles, repeated mentions, special characters, and date boundaries. |
| Access | Positive and negative tests for every role. Cover a cached result, a follow-up with an old source ID, and a record whose permissions changed. |
| Relevant retrieval | Known-positive articles appear within the candidate limit. Named queries include body-only matches and exclude misleading name collisions. Weak results produce a scoped uncertainty response. |
| Grounding | Citation references resolve and reviewed claims are supported by the corresponding passage. Test contradictory articles, date distinctions, and unsupported questions. |
| Recovery | SQL results still work during an embedding or generation outage. A changed record becomes searchable, and a withdrawn record disappears from search and cache. |
| Performance | Record planning, SQL, retrieval, and generation latency along with p95 end-to-end latency and cost. Compare the same questions on a representative archive snapshot. |
Keep a small set of incident regressions, then expand with editor-labeled requests and real usage patterns. Record the requested operation, resolved filters, outcome, retrieval mode, evidence IDs, and stage timings. Avoid copying restricted passages or drafts into general telemetry. Run destructive fixtures against a disposable database and verify real catalog behavior with separate read-only checks.
Lessons from an archive chat implementation
“Most recent” needed a chronological query. A follow-up about a misspelled city needed conversation context and entity resolution. An existence check for a person missed articles because it searched only the title and lead. Searching the full text with verified name variants recovered matching articles. Those cases became regression tests for routing, entity matching, and access.
The project also showed where to qualify results. A source link can be valid while a generated claim still needs review. Older articles can lack useful CMS metadata. A complete issue needs an expected roster, and a working branch still needs a staged rollout. Carry those distinctions into every archive you build.