Repository navigation
knowledge.synthesize keeps only the citations of chunks it read, and abstains on an empty answer - #225
Merged
Conversation
zlareb1
force-pushed
the
feat/knowledge-synthesize-grounding
branch
3 times, most recently
from
November 3, 2026 19:04
8da6328 to
e6060d2
Compare
…abstains on an empty answer A [source#idx] tag the model wrote for a chunk the passes were not shown (past max_windows, a missing index, another document) is removed from the answer and listed in unsupported_citations; citations lists only the tags of chunks read. An answer the passes left empty abstains with abstain_reason=empty_answer. Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: zlareb1 <[email protected]>
…e, is checked like any other Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: zlareb1 <[email protected]>
…upported rather than an error Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: zlareb1 <[email protected]>
…ays as prose Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: zlareb1 <[email protected]>
Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: zlareb1 <[email protected]>
Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: zlareb1 <[email protected]>
… and a blank run scanned once Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: zlareb1 <[email protected]>
…ir innermost Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: zlareb1 <[email protected]>
Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: zlareb1 <[email protected]>
Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: zlareb1 <[email protected]>
…wer written empty Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: zlareb1 <[email protected]>
…e too; one item grammar Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: zlareb1 <[email protected]>
…ome in the order found Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: zlareb1 <[email protected]>
Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: zlareb1 <[email protected]>
… must be read Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: zlareb1 <[email protected]>
…ted once Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: zlareb1 <[email protected]>
Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: zlareb1 <[email protected]>
…alue means Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: zlareb1 <[email protected]>
Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: zlareb1 <[email protected]>
Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: zlareb1 <[email protected]>
zlareb1
force-pushed
the
feat/knowledge-synthesize-grounding
branch
from
November 3, 2026 19:35
e6060d2 to
3f56157
Compare
8 of 9 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Changelog category (leave one):
Changelog entry (one or two sentences a user of Loom can read without the diff; the release pull request collects these into the release notes):
knowledge.synthesizeremoves from its answer any citation of a chunk it did not read and lists it inunsupported_citations; an answer with no letter or digit, as written or once those citations are removed, abstains withabstain_reason="empty_answer".Why
knowledge.synthesizereturned every[source#idx]tag the model wrote ascitations, unchecked. A model can cite a part it was never shown: a chunk pastmax_windows(the answer then reads as if the truncated part was covered), an index that does not exist, or a document that was not named. A caller that follows such a citation reads text the answer did not come from. And an answer the passes returned empty came back withabstain: false.Design
source#idx/source#a-bitems separated by,or;(Window.citenames a window spanning documents as a comma list); a source holds no blank, comma, semicolon or bracket (of nested brackets the innermost is read). A bracket with anything else in it is prose and stays as written ([PR #42],[see doc#1]); a bracket shaped like a citation ([issue#42]) counts as one wherever it came from. The cost of the narrow shape is that a citation of a source with a blank, comma or semicolon is prose and left unchecked; one with a comma or semicolon ([doc://a?x=1,2#3]) is no longer listed incitations, and one with a blank never was.cites_what_was_read(tag, read)needs every item read (a tag that is not a list of items names nothing read):source#idxnames a chunk in the set of (source, idx) pairs the windows showed,source#a-bneedsa <= band both ends read. The read set is built from the windows actually sent, after themax_windowscut. Indexes are ASCII digits 0-9; one longer than nine digits names no chunk and is removed without being parsed. The answer is grounded by one pattern in a pass over its citations, repeated until a pass removes nothing, since a removal can close an outer bracket into a new citation (at most eight passes);citations(), which only the handler called, is gone.ground_citations(answer, read)returns the answer with the unsupported tags removed, the kept tags and the removed ones. The answer keeps its prose; only the bracketed tag goes.citations(kept, in the order found), newunsupported_citations(removed). An answer with no letter or digit, as written or once the unsupported tags are removed ("[doc#9]."leaves only.), abstains (empty_answer). A list is listed once whatever the blanks around its separators.server/memory/domain/corpus_synthesis.py, next to the window and prompt helpers; the handler builds the read set and grounds the answer before themax_answer_charscut, so removed citations take no room; when the cut halves a kept citation,citationsis read again from the returned text, so it lists only what the answer holds.Scope and risk
knowledge.synthesizeonly.memory.askroutes a summary-shaped question to it and reads its answer; that answer now carries no tag for an unread chunk. No storage, no prompt change.Compatibility, rollout and rollback
KnowledgeSynthesizeOutput.unsupported_citations(default[]);abstain_reasongains the valueempty_answer.citationsdrops unread citations (now inunsupported_citations) and brackets naming a source with a comma or semicolon, which are now prose (a source with a blank never matched), and an index written in non-ASCII digits ([doc#١]), which the old\dmatched; it now also lists a read citation padded with blanks ([ doc#1]) or a list with blanks around its separators ([doc#0, doc#1]), which the old pattern did not match.Tests
tests/unit/test_corpus_synthesis.py: which tags count as read (an index, a range, a range past what was read, a backwards range, another document, a two-document list); the answer with unread tags removed; bracketed prose (and a non-ASCII index) kept as prose; a;list checked part by part; a source holding#; a window spanning two documents keeping its citation; an answer of only unread tags abstaining; unread citations removed before themax_answer_charscut; the handler withmax_windowscutting the read set (a tag to a cut chunk and to a missing chunk both removed) and an empty answer abstaining. Withtest_ask_synthesize_route, the decision-extract tests that share the module,test_public_copyandtest_doc_links. The grammar cases are one parametrized test, one case per id.make format lint typecheck; SDK op tables and the operations reference regenerated.AI assistance in the code (leave one; writing this description with AI is fine):
AI-generated (an agent wrote most of the diff): Claude Code.
I can explain every line of this diff and how it interacts with the rest of Loom.
Checklist
make format-check,make lint,make typecheckandmake test-unitpass; the integration suite passes if server behaviour changed.docs/reference/configuration.mdand thedocs/reference/tables (python scripts/codegen/docs_reference.py), the reach manifest,schemas/schema.sql(make schema-dump) and the Codex plugin copies (python3 scripts/codegen/agent_plugin_sync.py).docs/describe the system as it now is, and this description names any operator steps and wire changes.tests/unit/test_public_copy.py).git commit -s), as CONTRIBUTING.md asks.🤖 Generated with Claude Code