Repository navigation
The assistant cites document passages by source and section, and the qualification measures it - #260
Merged
Merged
Conversation
…, and the LibreChat qualification measures it The assistant primer and the knowledge.search and knowledge.get descriptions on the assistant toolset name the citation a document answer carries (source_uri, the hit's section breadcrumb, the revision knowledge.get returns) and tell the model that a hit is the nearest passage, not an answer, since knowledge.search has no abstain signal. The qualification harness gains a namespace of documents written through the text path (Markdown, plain text, SQL, TOML, and a document with two revisions), labeled document questions and two unanswerable ones. It measures the rank of the labeled section among the direct path's knowledge.search hits, checks each document citation an answer writes against the seeded server with no model (live document, existing section, live revision, cited text states the labeled value), and reports abstention. The existing cases and their scoring are unchanged; rescore --citations checks a saved run's citations again. Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: zlareb1 <[email protected]>
… one The assistant primer and the harness's agent instruction ask for a document's revision only when a tool returned it, since a knowledge.search hit carries none; the instruction gives filled-in examples instead of a template. The document abstention phrases apply to document cases only, so the memory cases score as on main, and the summary line for memory keys leaves the document rows out. The fixture documents carry no format field the server never received. The citation parser accepts a heading with a comma, and a test pins that a source_uri without a slash is no citation. Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: zlareb1 <[email protected]>
Drops the sentences about a future locator field, says what the document abstention phrases and the scorer token are read by, calls is_document_case where the op was compared again, puts the memory summary loop under a plain if, pins only that a section citation is read through knowledge.outline, and says the document cases need a server on text-embedding-3-large seeded afresh. Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: zlareb1 <[email protected]>
…ommands retry_after reads `detail.retry_after_s` when the detail is an object (the rate limiter's and the admission slots' body) and waits one second for any other 429 body: a detail string, a plain-text answer, or a hint that is no number. The README gives the document cases their own seed, setup and run on a text-embedding-3-large server, written to a results file of their own that git ignores. Tests cover rescore --citations on a saved document row and the order seed writes a document's revisions in. 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]>
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.
Related: #160
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):
On the
assistantMCP toolset, the model is told to cite a document answer bysource_uriand section breadcrumb, with the revision whenknowledge.getreturned one, and to say a fact is not in the documents when noknowledge.searchhit states it. The LibreChat qualification harness now asks questions over documents and reports recall@k of the labeled section, citation validity and abstention.Why
The assistant toolset already listed
knowledge.search,knowledge.getandknowledge.list, but nothing measured whether a document answer was cited correctly or whether the model abstained when the documents did not hold the fact. Its instructions also asked for a document'sdoc_idoringested_atrather than its revision. This change makes the citation contract explicit (source and section; a revision only when a tool returned one, which on main means aknowledge.get) and extends the existing qualification set with document questions, so the answers can be scored against labels.Scope and risk
server/transport/mcp_primer.py,server/transport/mcp_descriptions.py): the assistant primer asks for a document'ssource_uriand section, and itsrevisiononly whenloom_knowledge_getreturned one (a search hit carries none on main). The assistant'sknowledge.searchdescription says a hit is the nearest passage, not an answer, and that the revision comes fromloom_knowledge_get.knowledge.getasks for therevisionin place ofdoc_id/ingested_at. Only text changed: no op, field or roster entry. The default listing is unchanged.knowledge.search/get/list(andknowledge.inspect), which it already lists.knowledge.outlinewould add about 230 listing tokens to every model call (the assistant listing is about 9,700). In the run, every cited section came from a hit, and outline does not return the revision, which is the part that was missing.knowledge.synthesizeis left out because it is a paid LLM call. The assistant does no document parsing; it calls onlyknowledge.*ops.integrations/librechat/qualification/): a third namespace,acme-library(orgacme), with its own viewer person and five documents written throughknowledge.upsert: a Markdown runbook with nested headings, a plain-text contract, a SQL table definition, a TOML file, and a policy written twice. All five reach the server as plain text: the harness sends no format, and no case runs through extraction. Seven labeled questions, each with its answer pattern and source section, plus two unanswerable questions. The agent instruction gives filled-in citation examples and says to name a revision only with a number a tool returned. Existing cases and fixture tenants are unchanged, and memory-case scoring is identical to main: the extra abstention phrases ("does not specify/state", "not in the documents") are read for document cases only. The general summary line leaves document rows out; they get their own lines.check_doc_citations): it parses[source_uri § A > B, revision N](a heading may hold a comma; asource_urimust hold a/) and checks each citation against the seeded server with the scorer's viewer token and no model. The document must be live in the person's namespace. A named section must be one of its headings (knowledge.outline, parents included). A named revision must be the live one (knowledge.get). The cited text (the section with its subsections, or the whole document) must match one of the labeled values. Rate-limited scorer reads are retried; any other failure stops the run instead of marking the answer wrong.knowledge.searchwith the question and the case'stop_k. The model's own search results stay in LibreChat and are not scored.server/operations/reach_manifest.pyis regenerated: the harness now callsknowledge.searchandknowledge.outlinefromintegrations/.Compatibility, rollout and rollback
Tests
tests/unit/test_librechat_integration.py):source_urireads as a memory key.revision unknown, a heading with a comma, and[1]or asource_uriwithout/as no citation.rescore --citationson a saved document row merges its memory and document citations;seedwrites the revised document after every first write, so its second revision is live.detail.retry_after_s, a detail with no hint, a string detail, a plain-text body).tests/unit/test_mcp_assistant_toolset.pychecks that the primer's newrevisionfield is served.test_librechat_integration.py, the MCP listing and toolset tests,test_package_contracts.py,test_op_reach_census.py,test_public_copy.py,test_doc_links.py,test_tunable_constants.pyandtest_agent_instructions.py. Also ranmake format,make lint(exit 0) andmake typecheck. The full unit suite passes.text-embedding-3-large,LOOM_LLM_PROVIDER=fakeand workers off, and LibreChat v0.8.8 fromintegrations/librechat/docker-compose.yml, withclaude-haiku-4-5-20251001. Only the document cases ran (qualify.py run --only <doc case ids>), on a fresh seed and a fresh LibreChat.knowledge.search, no model)These are from the second run, after the revision wording changed. The first run used the template
[source_uri § section, revision N]and a primer that always asked for the revision. There, 7 of 8 citations were valid; the invalid one was a made-uprevision 0. 5 of 8 citations ended inrevision Norrevision unknown. Unanswerable questions took 5 calls each, with a p95 of 11.3 s, and the run cost $0.388. Total provider spend over both runs was about $0.68. The memory cases were not run again; their scoring is unchanged and their published numbers stand. The corpus has five documents, so 7/7 at rank 1 shows the breadcrumbs reach the hits; it says nothing about retrieval at scale.Findings, for follow-ups:
knowledge.searchhit carries no revision. In the second run no citation named one (the model calledknowledge.getonly on the unanswerable questions), so this PR delivers source and section citations, not revision citations. A per-hit revision and locator is the follow-up; the citation check already verifies a named revision against the live one.knowledge.searchhas no abstain signal, so abstention comes only from the model.# commentline is a Markdown heading, so the TOML file's sections are its comments. A SQL or TOML file added as text gets no line or key locator.knowledge.ingestneeds the extractor service, blob storage and the ingestion worker, and on main its hits carry the same breadcrumb as the text path.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. The eval was run against a local server and LibreChat, and each citation the checker marked invalid was checked by hand against the saved answers.
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).main; no merged migration is edited.hooks/,lib/,bin/,skills/,.mcp.json, the Codexplugin-defaults.json) bumps both plugin manifests' version, and no other open PR uses that version.npm --prefix frontend run build) and its tests pass, iffrontend/changed.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