Verbatim Recall
Status: ✅ shipped (2026-10-24, 435287eed; the history-window dedupe 6a6b90ae8, 2026-10-25), behind the
Verbatim Recall setting — account default and per story, default off. The acceptance pass below is still
partial: unchecked boxes are not yet verified live. Two shapes, both behind settings so writers can test which one
helps their stories; the default is off. On an existing database the lines summarized before this ships
become quotable gradually: the backfill that indexes them is bounded to about a minute per Database boot
and continues on the next one, and a line it has not reached yet is simply not found. Until that
backfill is recorded done, quote search runs without its full-text index: the boot that finishes the
backfill builds it. Grows out of
Memories and the research in
docs-internal/architecture/chat-engine/MEMORY_AND_SUMMARIES_RESEARCH.md (§5 M8).
Overview
A memory is a summary of a scene. It is the right unit to find a past moment by, and the wrong unit to quote it from: "what exactly did she say when we parted" wants the line, not the paragraph that mentions a parting. Verbatim recall pulls the stored message in. A quote never travels alone. Every quote is injected with the summary of the scene it comes from, because a raw line out of context is noise the model has to guess a frame for — and the frame is already one join away: every summarized message carries the id of the summary that covers it.
The messages worth quoting are the ones that have slid out of the verbatim history window, and by the summarizer's "no gap" rule a summary covers every one of them. So verbatim recall only ever searches summarized messages, live and selected versions only. The converse does not hold on web: the history read keeps the newest messages whether or not a summary covers them, so a summarized line can still be inside the window. A quote never repeats a line the model already sees: both shapes leave out exactly the rows this turn's history read returns (Max Context Messages of them), before they pick, so a line inside the window takes no slot from one outside it. One caveat: with Dynamic Context on and a tight model window, the fit can send fewer rows than the read returned. A summarized line it drops that way is not quoted on that turn either; it becomes quotable once newer messages push it out of the read.
The two shapes
| Shape | Setting value | How it ranks | What it adds |
|---|---|---|---|
| Drill-down | drilldown |
Today's memory recall ranks the scenes (few candidates, scene-coherent, already scored). For each recalled memory, the best-matching message inside that scene is fetched. | Up to Quotes per memory lines under each recalled memory. |
| Message-first | messages |
Full-text search over the conversation's summarized messages. Each hit brings its scene summary. | Up to Max verbatim messages lines. A hit whose scene is already a recalled memory attaches to it (under Quotes per memory) instead of repeating the summary. The rest group one item per scene, carrying that scene's matching lines: the summary + lines when the scene is a memory the ranking did not surface; the lines alone, marked, when the scene is still active (its summary sits in the summaries block). |
| Both | both |
Both of the above. | Both; a line is never injected twice. |
Drill-down is the conservative one: it cannot surface a scene the memory ranking did not. Message-first can, at the price of more false hits (ten times the candidates, surface-word matches), each dragging a summary in with it. That trade-off is the reason both ship: the owner wants writers to try them.
What the model sees
[Sep 1 - Sep 2, 2026]
Elara and the party parted at the harbour; she left her locket.
Quoted lines are single moments picked for this turn, not the only times these words came up.
> them: "Then remember this," Elara said, pressing the locket into your hand. "When the bells ring, I am already gone."
("bells ring" also comes up in a few other scenes.)
Verbatim, from a scene in the summaries above:
Quoted lines are single moments picked for this turn, not the only times these words came up.
> them: Grimjaw slammed the map down. "The drowned city is a grave, not a treasury."
The quote is labelled you (the writer's message) or them (the reply), cut to Quote max
characters around the first matching word (with an ellipsis on each side that was cut, so the line
that matched is always in it), and sits under its scene. Ordering is the memory ranking as today;
message-first pairs follow the recalled memories.
A quote is a sample, and the model is told so. The search picks the few lines that best match this turn: up to Quotes per memory (at most 3) under each recalled memory in Drill-down, and up to Max verbatim messages in Message-first, which can all come from one scene. So a phrase the story uses again and again reaches the model only a few times, often once. Read bare, the model took that one line as the only time the words were said (a reply once insisted a character had said a phrase only once, when the story had used it many times). So the quoted lines of each recalled scene come under one plain sentence: "Quoted lines are single moments picked for this turn, not the only times these words came up." Every scene that brings a quote carries it, directly above its lines, so the sentence always travels with the quotes it is about, and a scene reads the same whatever else the turn recalls. A scene with no quote carries none, and with verbatim recall off the memory section is unchanged, byte for byte. Each copy costs about 27 tokens, charged in the budget with the scene it sits in, so a section that quotes from five scenes spends about 135 tokens on it. The sentence gives no count on purpose: the search matches any word of the recent messages, so how many lines matched says nothing about how often a phrase was used. The Hybrid director's looked-up quotes carry the same sentence above each run of them. Those lookups don't depend on the Verbatim recall setting, so they carry it with verbatim recall off too: a looked-up quote is a sample all the same.
A quote whose wording recurs says how often (owner, 2026-12-04: "It's already searching the conversation when I have 'both' set. So how about just giving a summary of the findings"). Where the turn searches messages (Message-first or Both), each quoted line can carry one more line directly under it: ("bells ring" also comes up in a few other scenes.) The phrase is two words the search matched, standing side by side in the quoted line (a word shorter than three letters, like the "ll" of a contraction, never makes one). Another scene counts when one of its lines has the same two words side by side, punctuation between them ignored and English word endings folded ("bells rang" also finds "bell. Rang"): it is not an exact-phrase match. Of a line's phrases it names the one used in the most other scenes, counting scenes, not lines. The count is said in steps, so the text only changes when the story really moves: "1 other scene", "a few other scenes" (2 to 4), "several other scenes" (5 to 9), "10 or more other scenes". A line says nothing when its words come up nowhere else, when the count could not be made in time (the quotes still go), or when the phrase is in more than half of the story's scenes (a name or a stock phrase is everywhere, and saying so tells the model nothing). Drill-down alone is unchanged and makes no count. The line is charged in the budget with the scene it sits in, at most about 26 tokens a line. The Hybrid director's looked-up quotes carry no such line. The same count also helps choose the lines: Message-first looks at twice Max verbatim messages lines, lifts each one's match score by how widely its wording recurs (by half again at most, growing slowly with the number of other scenes), and keeps Max verbatim messages of them, so a line whose words run through the story can edge out a slightly better match that comes up once. Without a count the best matches are kept as before; lines under a recalled memory (Drill-down) keep their order. The count is one more search over the story, and its cost grows with the story and with how many phrases the turn's lines bring: on a 30,000-message story about 0.1 s for a handful of phrases, and up to half a second when many lines with common wording are counted. A turn already waits seconds for the model, and a count that takes longer than 2 seconds is dropped (the quotes still go). F424 is the index that would cut it.
Settings
All in the Memory group, account default under Settings → Context, per-conversation override under the chat's Context settings. Web chat only.
| Setting | Default | Range | What it does |
|---|---|---|---|
| Verbatim recall | Off | Off / Drill-down / Message-first / Both | Which shape runs. Off changes nothing about today's recall. |
| Quotes per memory | 1 | 1–3 | Drill-down: lines fetched inside each recalled scene. |
| Max verbatim messages | 3 | 1–10 | Message-first: how many matching lines to look for. |
| Quote max characters | 1000 | 200–3000 | A longer message is cut to a window around the match, with ellipses. |
Budget
A quote is charged with the summary it travels with: a recalled memory and its lines are sized and admitted as one item, before the cut, so the cut falls exactly as it does today with the top-ranked item always admitted. A candidate the cut dropped never comes back through message-first ("truncate, never repack").
- By count mode: a memory with its lines is one entry; message-first scenes have their own count, Max verbatim messages — otherwise a story with ten matching memories could never surface a missed scene, which is the shape's one purpose.
- By token budget (and both): everything shares the allowance; message-first scenes come after the memories and take what is left.
The Context Budget bar. The bar's memory figure prices the lines the story's own settings can quote
(ContextBudgetEstimates.RecalledMemory, shipped 2026-11-09 after the owner's report: a story quoting three
3,000-character lines per memory sent 56k against a 38k estimate). It is an upper bound by the section's own
caps: Quotes per memory under each of the first twenty memories Max memories admits (drill-down), plus
Max verbatim messages (message-first), each line at most Quote max characters and never longer than the
longest summarized message, never more lines than the story has summarized messages, and a scene label's
allowance per message-first line. In By count mode the corpus of memories already holds every scene a
message-first line brings, so the lines are added to it; under a token bound the lines share the allowance,
and the figure is max(budget, the largest memory with its lines), capped by the corpus plus the lines. The
drawer draws the lines as their own faded segment, Verbatim lines (up to N), out of the memory figure
(memoryVerbatimTokens, a share of memoryTokens, never added on top). Off, the figure is what it was.
Mechanics
- Search:
fn_search_message_quotes(p_query, p_conversation_id, p_summary_ids, p_per_summary, p_limit, p_fts_threshold, p_quote_max_chars, p_exclude_newest, p_with_pairs)(database/v1/functions/16d_search_message_quotes.sql). With summary ids it is the drill-down; without, message-first. Full-text overto_tsvector('english', content), ranked byts_rank_cd, the same threshold as memory FTS (FTS Score Threshold). - The recurrence line (F423b): where the turn searches messages, both searches pass
p_with_pairs, and each line comes back withquote_pairs(up to 3 two-word phrases of matched words side by side in the quote as cut, lowercased, at most 40 characters) andvia_simple. Onefn_count_quote_phrase_scenes(conversation, phrases, via_simple)call (database/v1/functions/16f_count_quote_phrase_scenes.sql, a 2 s bound, its own failure path) counts each phrase's distinct scenes among the quotable lines and the story's scene count; the provider keeps, per line, the phrase in the most other scenes, past the over-half guard (WebMemoryRetrieval.WithRecurrence). The line is built once (QuoteRecurrenceLine) for the render and the charge, and the context budget charges its longest form per line (RetrievalItemOverhead.RecurrenceLineMaxChars). The turn's record keeps it as the quote'srecurs. Step 2, the boost: the message-first search asks for2 × Max verbatim messages; the rows the turn's read already sends, the lines drill-down already quotes, and the hits whose recalled memory drill-down already filled to Quotes per memory are dropped first; then only the hits that could still be kept are counted (the firstMax verbatim messages, and below them a hit with1.5 × rankabove theMax verbatim messages-th rank: the others can't reach the keep, so leaving them out of the count changes nothing), plus the drilled lines that are shown; with a count, each hit scoresrank × min(1.5, 1 + 0.25·ln(1 + other scenes))(0 other scenes for a line past the over-half guard), the hits are ordered by that score (selection and item order alike;Rankitself is untouched) andMax verbatim messagesare kept. Without a count, the firstMax verbatim messagesin the search's order: the step-1 result up to Max verbatim messages 5 (16d's phase-1 keep,GREATEST(limit × 5, 50), is the same for both limits there); from 6 up the doubled limit widens that pool, so the top lines can differ a little. Drill-down lines keep their order. - The history it leaves out:
p_exclude_newestis the turn's history read count (PromptLegAssembler.HistoryReadCount, the one definition the read itself uses; not Message Scan Depth). The function restates that read in ahistory_readCTE —WebMessageRepository.GetRecentHistoryAsync's predicates and order, noweb_summary_idfilter — and drops its rows in the cheap phase, before the candidate limit. 0 (the default, so a host built before it still resolves mid-deploy) excludes nothing. When M8c (MEMORY_DELIVERY_PLAN.md) takes summarized rows out of the read, the CTE changes with it and then excludes nothing. - The query is the memory scan window, cut to its newest 2,000 characters — the current message is the end of it.
- Index and column:
web_messages.content_tsv, a stored tsvector that only a summarized row carries. A trigger on insert and oncontent/web_summary_idupdates sets it when a summary covers the row, recomputes it when a summarized row's content changes, and clears it when the row loses its summary; a row no summary covers yet (every new message) stays NULL, so a turn's insert computes nothing and the history reads of those rows carry nothing new.idx_web_messages_content_tsvis a partial GIN over summarized, live, selected-version rows, builtCONCURRENTLY(162_web_messages_content_fts.sql). Stored rather than an expression index because ranking recomputesto_tsvectorper candidate otherwise: measured 36.7 s over 40k messages, the 2026-07-02 incident shape. - Backfill of the rows summarized before the trigger existed: id-range batches that commit one by one,
bounded per Database boot (stops after 60 s, continues where it stopped on the next boot; progress in
web_messages_content_tsv_backfill), passing over rows a live transaction holds and returning for them in another pass; done is recorded indata_heals, after which a boot does no scan at all. Partial coverage is accepted while it runs: a summarized line with no tsvector yet is not found by quote search, and the feature defaults to off. Deploy cost: up to about a minute of backfill per boot until done, plus the one concurrent index build on the boot that finishes it (a fresh database: its first). The index waits for the backfill on purpose — maintaining it made the backfill about 3× slower and stretched a batch past the budget — so until then quote search runs on the stored vectors without it. - Ranking is two-phase (cheap
ts_rankkeeps the top candidates,ts_rank_cdscores those), as memory FTS does. Measured on 40k summarized messages in one conversation: see the verification table in the research doc's M8 entry. - Provider:
WebMemoryContentProviderfetches quotes before the budget cut so the pair is sized as one item;MemoryCharsand the renderer stay in lockstep. Drill-down asks inside at most the top 20 candidates. Verbatim search is full-text only and runs even when Full-Text Search is off for memories. - Repository:
IMemorySearchRepository.SearchQuotesAsync→MessageQuoteResult(message id, role, quote, truncation flag, rank, and the summary's id, level, content and period).
Non-Goals
- Message embeddings. Verbatim search is full-text only in this slice; the vector leg arrives with a message-embedding table if hit rates say so.
- Discord. The Discord memory provider is untouched; the settings are web-scoped.
- Quotes from rollups. A rollup links no messages; only L1-origin memories have lines behind them, and the chapter redesign (research §4 S3) is what makes every level quotable.
- Multilingual full-text. Same
englishconfiguration as every other search in the product.
Acceptance Criteria
The feature is not done until every box below is verified ✅ against the running product.
User use cases — satisfiable + accessible (verify by driving the UI, not the code):
- As a writer, I can switch Verbatim recall between Off / Drill-down / Message-first / Both from the chat's Context settings, and set it as my account default under Settings → Context, with the three numeric settings beside it — without insider knowledge.
- As a writer with Drill-down on, a reply that recalls a past scene can quote the exact line from it, visible in the prompt preview under that memory.
- As a writer with Message-first on, asking about an exact past line surfaces it with its scene even when the scene itself was not a top-ranked memory.
Behavior:
-
offleaves the memory section byte-identical to today's recall: no quote search runs for it, the rendered section is unchanged. (The Hybrid director's lookups are not governed by this setting.) (Live 2026-10-25: off and the default gave byte-identical prompts with no quote search in the probe log; either on-mode's prompt with its quote lines removed was byte-identical to off.) - Drill-down fetches at most Quotes per memory lines per recalled memory, from that memory's own messages only, best FTS rank first.
- Message-first fetches at most Max verbatim messages lines across the conversation; a hit whose summary is a recalled memory attaches to it under Quotes per memory (no repeated summary); the rest group one item per scene: a level ≥ 1 scene renders its lines under the "scene summarized above" marker, a level-0 scene not recalled renders summary + lines.
- A candidate memory the budget cut dropped never reappears as a message-first item.
- In By count mode, message-first scenes are admitted up to Max verbatim messages even when the memory count is saturated.
- Message-first on a story of 40,000 summarized messages answers in well under the 30 s search timeout (measured; the function is two-phase on a stored tsvector).
- A line is never injected twice in
both. - Every recalled scene that carries a quote carries the sample sentence exactly once, directly above its first quoted line, in every shape (Drill-down, Message-first, Both); a scene with no quote carries none, and with verbatim off the memory section is byte-identical. The Hybrid director's looked-up quotes carry it once above each run of quote lines, whatever the Verbatim recall setting (those lookups don't read it).
- Each copy of the sample sentence is charged in the budget with the scene it sits in, and the context budget's memory figure counts one per scene that can carry a quote.
- With Message-first or Both, a quoted line whose two-word phrase comes up in other scenes of the story carries one line directly under it saying so: ("phrase" also comes up in a few other scenes.), in steps: "1 other scene", "a few" (2 to 4), "several" (5 to 9), "10 or more". The same two words side by side count wherever they stand, punctuation between them ignored; a word under three letters never makes a phrase. Of the line's phrases it names the one in the most other scenes.
- No such line when the phrase comes up in no other scene, when the phrase is in more than half of the story's scenes, or when the count fails or runs out of time; in every one of those cases the quotes themselves still go, and a failed count does not mark the reply's prompt as incomplete.
- With Drill-down alone, the quotes and the memory section are exactly as before: no recurrence line and no count is made. The Hybrid director's looked-up quotes never carry one.
- The recurrence line is charged in the budget with the scene it sits in, and the context budget's memory figure counts one at its longest for each line a turn that searches messages can quote.
- Message-first still sends at most Max verbatim messages lines, but picks them from twice as many matches, preferring a line whose wording recurs across the story over a slightly better match that comes up once (a phrase in more than half of the scenes lifts nothing). A line the history already shows, a line Drill-down already quotes, and a line whose recalled memory Drill-down already filled take no place. When the count fails, the best matches are kept as before.
- A quote longer than Quote max characters is cut to a window around the match, with ellipses (the matching line is always in it), and the cut is reflected in the budget accounting.
- Only summarized, non-deleted, selected-version, non-refusal messages of this conversation can be quoted.
- No line this turn's history read returns is quoted, in either shape, and a match inside the window takes no slot from one outside it: the rows left out are the read's own (its count, predicates and order). (Live 2026-10-25, mock LLM, set per conversation through the settings route, Max Context Messages 5: one scene straddled the window. On the first turn, message-first's three hits all came from outside the window, although the in-window rows matched just as well and were newer. That scene's one line was its out-of-window row; its three in-window rows, the boundary row among them, were not quoted. Drill-down and message-first agree on regenerations. A regeneration's read includes the reply being replaced, so the exclusion moves by one row with it. Off and the default give byte-identical prompts, run no quote search, and equal either shape's prompt with its quote lines removed.)
- With Dynamic Context on, a summarized line the fit drops from this turn's window is neither in the history nor quoted on that turn (the accepted cost of one count on both sides). (Live 2026-10-25: a 2,000-token budget dropped the oldest of four history rows, a summarized line, and no quote carried it.)
- The query is cut to its newest 2,000 characters: a keyword at the end of a long scan window still hits. (Live 2026-10-25: keywords at the end of a scan window over 15,000 characters still drove the quote hits.)
Invariants that must stay true (carve-outs):
- Memories off (or Summaries off by the cascade) → no quote search, as today.
-
By countmode: a memory plus its quotes is one entry;By token budget: the pair's full rendered size is charged and the top-ranked item is always admitted. - Discord memory recall is unchanged.
- A fresh database and an existing one both end the replay with a valid
idx_web_messages_content_tsv; a row that gains a summary later gainscontent_tsv, a row with no summary carries none, and a row that loses its summary loses it. - The backfill never holds a boot longer than its budget: a replay leaves what it did not reach NULL,
the next replay continues from where it stopped, and once
data_healsrecords it done a replay scans nothing. Every summarized row carriescontent_tsvonce it is done. - A replay over a current schema takes no lock a turn's insert waits on.
Edges:
- Empty or stopword-only scan window → no quotes, no error.
- A memory with no matching lines renders exactly as today.
- Another conversation's messages never appear.
- A failed quote search degrades to today's recall and logs once; it never fails the turn.