From d9b523b17e3dd00362c83d2a6baae2e9246e67d1 Mon Sep 17 00:00:00 2001 From: zlareb1 Date: Tue, 10 Nov 2026 20:47:30 +0000 Subject: [PATCH 01/41] The assistant qualification set covers every Loom use case, with help cases scored by the server's citation rule Each case names its use case; help cases list the values the answer must state and the pages holding them. qualify.py checks a help citation as the server does, accepts an earlier version of a memory key, scores unknown_names, and reports per use case. The LibreChat page carries the before and after table. Co-Authored-By: Claude Opus 5.5 Signed-off-by: zlareb1 --- docs/features/integrations/librechat.md | 67 +++ docs/features/memory/retention-and-erasure.md | 4 +- .../librechat/qualification/cases.json | 539 +++++++++++++++++- .../librechat/qualification/qualify.py | 143 ++++- server/operations/reach_manifest.py | 7 +- tests/unit/test_librechat_integration.py | 9 +- 6 files changed, 736 insertions(+), 33 deletions(-) diff --git a/docs/features/integrations/librechat.md b/docs/features/integrations/librechat.md index 0bd229a08a..96df31d1dc 100644 --- a/docs/features/integrations/librechat.md +++ b/docs/features/integrations/librechat.md @@ -212,6 +212,73 @@ breadcrumbs reach the hits, not that retrieval holds up at scale. No citation na revision: the hits of the measured build carry none, and the model read `knowledge.get` only on the two unanswerable questions. +### Use cases + +The case set holds at least one question per use case of Loom: what a namespace holds and +how it is used (the data tools), and how Loom works and how to do something in it (the +help tools, which read the documentation the server ships). Each help case labels the +values its answer must state and the pages that hold them. Its answer is scored correct +when it states them, names no op or setting the server neither serves nor documents +(`unknown_names` on the answer's `loom.citations` event), and, for a case with no answer +in the docs, says so. A help citation is valid when its page is in the server's +documentation (`help.get`) and its section is one of the page's own, by the rule the +server's own check uses. The cases go through Loom's assistant route +(`qualify.py setup-bridge`), so each answer also carries the question's asker line and +the bridge's own citation check. + +**Before** is the same help questions on the build before the documentation reached the +assistant: an agent with no help tools. It answered 10 of 26 by its own knowledge and +cited none. **After** is the current agent definition. + +| Use case | Cases | Before: answered with a citation | After: correct | After: citations valid | +| --------------------------------- | ----- | -------------------------------- | -------------- | ---------------------- | +| U1 Look up a stored fact | 7 | 0 of 1 | 7 of 7 | 7 of 7 | +| U2 What a document says | 10 | 0 of 1 | 9 of 10 | 9 of 10 | +| U3 What the namespace holds | 3 | - | 3 of 3 | 3 of 3 | +| U4 Usage counts and trends | 3 | - | 3 of 3 | 3 of 3 | +| U5 Cost and spend | 1 | 0 of 1 | 1 of 1 | 1 of 1 | +| U6 Write memory better | 4 | 0 of 1 | 4 of 4 | 2 of 4 | +| U7 History of a fact | 2 | 0 of 1 | 2 of 2 | 2 of 2 | +| U8 Entity graph | 1 | 0 of 1 | 1 of 1 | 1 of 1 | +| U9 Code index | 1 | 0 of 1 | 1 of 1 | 1 of 1 | +| U10 Conflicts and refusal | 1 | 0 of 1 | 1 of 1 | 1 of 1 | +| U11 Sharing and collections | 1 | 0 of 1 | 1 of 1 | 1 of 1 | +| U12 My role and who can change it | 1 | 0 of 1 | 1 of 1 | 1 of 1 | +| U13 Connect a coding agent | 1 | 0 of 1 | 1 of 1 | 1 of 1 | +| U14 Tokens | 1 | 0 of 1 | 1 of 1 | 1 of 1 | +| U15 Models and keys | 1 | 0 of 1 | 1 of 1 | 0 of 1 | +| U16 Health problems | 1 | 0 of 1 | 1 of 1 | 1 of 1 | +| U17 Why search returned this | 1 | 0 of 1 | 1 of 1 | 1 of 1 | +| U18 Runs | 1 | 0 of 1 | 1 of 1 | 1 of 1 | +| U19 Tasks between agents | 1 | 0 of 1 | 1 of 1 | 1 of 1 | +| U20 Tracker | 1 | 0 of 1 | 1 of 1 | 1 of 1 | +| U21 Retention and erasure | 1 | 0 of 1 | 1 of 1 | 1 of 1 | +| U22 Extraction from transcripts | 1 | 0 of 1 | 1 of 1 | 1 of 1 | +| U23 Working memory | 1 | 0 of 1 | 1 of 1 | 1 of 1 | +| U24 Integrations | 2 | 0 of 1 | 2 of 2 | 2 of 2 | +| U25 What a setting does | 1 | 0 of 1 | 1 of 1 | 1 of 1 | +| U26 Getting started | 1 | 0 of 1 | 1 of 1 | 1 of 1 | +| U27 Operating a deployment | 1 | 0 of 1 | 1 of 1 | 1 of 1 | +| U28 Refusals and abstentions | 5 | 0 of 1 | 5 of 5 | 5 of 5 | +| All | 56 | 0 of 26 | 55 of 56 | 52 of 56 | + +Measured on v0.8.8 with `claude-haiku-4-5`, on a server running fake embeddings and a fake +LLM for Loom's own model jobs. A full run of the 56 cases costs about $3 at list price +counting every prompt token, a mean of $0.053 per answer. The after columns are from a +full run, with the 14 cases the last instruction change touches (the memory and document +cases and three others) from a run after that change. The misses: + +- `doc-cache-entries` answers a question the namespace's documents leave open from Loom's + own settings instead of abstaining: the question and a Loom setting share their words. +- Two recommendation answers cite `mentor.guide`, Loom's writing guide, as a docs page, + which the check marks unverified: the guide has no citation form. +- One answer names a section the page does not have. + +Answers vary from run to run at this model. Across the runs that led here, a question +about the person's own rate limit or webhook retries was answered from Loom's docs in some +runs and from the namespace in others; asking for the memory, document and help searches +together in the first step reduced it. + ## The deployed assistant Loom can also run LibreChat itself, headless, with one agent it seeds: the shape the diff --git a/docs/features/memory/retention-and-erasure.md b/docs/features/memory/retention-and-erasure.md index e499d68da8..eb616405d5 100644 --- a/docs/features/memory/retention-and-erasure.md +++ b/docs/features/memory/retention-and-erasure.md @@ -103,7 +103,9 @@ wins. ## Erasure `erasure.request` erases one scope everywhere Loom keeps it, and returns once it can show -nothing in scope is left. +nothing in scope is left. To erase everything one user id holds across the org, an org +admin requests the `user_id` scope; `memory.clear` is not erasure: it tombstones one +agent's or user's memories in one namespace, and the rows stay in history. | `scope_type` | `scope_value` | Who may request it | | ---------------- | --------------------------------------------------------------------------- | -------------------------------------------- | diff --git a/integrations/librechat/qualification/cases.json b/integrations/librechat/qualification/cases.json index 2c6ca539e6..a2cf607de6 100644 --- a/integrations/librechat/qualification/cases.json +++ b/integrations/librechat/qualification/cases.json @@ -12,7 +12,8 @@ "query": "On which day of the week are production deploys frozen?", "top_k": 1 } - } + }, + "use_case": "U1 look up a stored fact" }, { "id": "memory-db-version", @@ -27,7 +28,8 @@ "query": "Which PostgreSQL version does the orders database run?", "top_k": 1 } - } + }, + "use_case": "U1 look up a stored fact" }, { "id": "memory-oncall", @@ -42,7 +44,8 @@ "query": "How often does the payments on-call rotation hand over, and on which day?", "top_k": 1 } - } + }, + "use_case": "U1 look up a stored fact" }, { "id": "memory-webhook-retries", @@ -57,7 +60,8 @@ "query": "How many times is a webhook delivery retried at most?", "top_k": 1 } - } + }, + "use_case": "U1 look up a stored fact" }, { "id": "memory-backups", @@ -72,7 +76,8 @@ "query": "How long are database backups kept?", "top_k": 1 } - } + }, + "use_case": "U1 look up a stored fact" }, { "id": "memory-revised-rate-limit", @@ -88,7 +93,8 @@ "top_k": 1 } }, - "forbid": ["\\b300\\b"] + "forbid": ["\\b300\\b"], + "use_case": "U1 look up a stored fact" }, { "id": "inventory-count", @@ -101,7 +107,8 @@ "args": {}, "path": ["sections", 0, "count"], "equals": 10 - } + }, + "use_case": "U3 what the namespace holds" }, { "id": "inventory-top-agent", @@ -117,7 +124,8 @@ "name": "handbook-bot", "rows": 7 } - } + }, + "use_case": "U3 what the namespace holds" }, { "id": "inspect-agent", @@ -133,7 +141,8 @@ }, "path": ["own", "live_rows"], "equals": 3 - } + }, + "use_case": "U3 what the namespace holds" }, { "id": "tune-drafts", @@ -148,7 +157,8 @@ "count": true, "equals": 0 }, - "forbid": ["\\b([1-9]\\d*|one|two|three|four|five)\\s+(tuning\\s+)?(proposals?|drafts?)\\b"] + "forbid": ["\\b([1-9]\\d*|one|two|three|four|five)\\s+(tuning\\s+)?(proposals?|drafts?)\\b"], + "use_case": "U6 write memory better" }, { "id": "cross-tenant", @@ -164,7 +174,8 @@ "query": "Project Nightjar launch", "top_k": 1 } - } + }, + "use_case": "U28 refusals and abstentions" }, { "id": "revoked-token", @@ -178,7 +189,8 @@ "query": "On which day of the week are production deploys frozen?", "top_k": 1 } - } + }, + "use_case": "U28 refusals and abstentions" }, { "id": "abstain-wifi", @@ -191,7 +203,8 @@ "query": "What is the office Wi-Fi password?", "top_k": 1 } - } + }, + "use_case": "U28 refusals and abstentions" }, { "id": "abstain-cfo", @@ -204,7 +217,8 @@ "query": "Who is the chief financial officer?", "top_k": 1 } - } + }, + "use_case": "U28 refusals and abstentions" }, { "id": "doc-release-reviews", @@ -222,7 +236,8 @@ "query": "How many approving reviews does a release need before it joins the release train?", "top_k": 5 } - } + }, + "use_case": "U2 what a document says" }, { "id": "doc-migration-rollback", @@ -240,7 +255,8 @@ "query": "How is a bad database schema migration handled: is it rolled back?", "top_k": 5 } - } + }, + "use_case": "U2 what a document says" }, { "id": "doc-canary", @@ -258,7 +274,8 @@ "query": "What share of production traffic does a canary receive, and for how long?", "top_k": 5 } - } + }, + "use_case": "U2 what a document says" }, { "id": "doc-contract-notice", @@ -276,7 +293,8 @@ "query": "How much notice stops the hosting agreement from renewing?", "top_k": 5 } - } + }, + "use_case": "U2 what a document says" }, { "id": "doc-orders-ttl", @@ -294,7 +312,8 @@ "query": "How long are rows kept in the orders table?", "top_k": 5 } - } + }, + "use_case": "U2 what a document says" }, { "id": "doc-cache-entries", @@ -312,7 +331,8 @@ "query": "What is the maximum number of entries in the session cache?", "top_k": 5 } - } + }, + "use_case": "U2 what a document says" }, { "id": "doc-revised-ack", @@ -331,7 +351,8 @@ "top_k": 5 } }, - "forbid": ["\\b(15|fifteen)\\s*min"] + "forbid": ["\\b(15|fifteen)\\s*min"], + "use_case": "U2 what a document says" }, { "id": "abstain-doc-credit", @@ -344,7 +365,8 @@ "query": "What service credit does Acme get when the hosting provider misses its uptime guarantee?", "top_k": 5 } - } + }, + "use_case": "U2 what a document says" }, { "id": "abstain-doc-phone", @@ -357,7 +379,8 @@ "query": "What is the hosting provider's escalation phone number?", "top_k": 5 } - } + }, + "use_case": "U2 what a document says" }, { "id": "analysis-per-agent", @@ -372,7 +395,8 @@ }, "path": ["rows"], "equals": [["handbook-bot", 7], ["ops-bot", 3]] - } + }, + "use_case": "U4 usage counts and trends" }, { "id": "analysis-per-scope", @@ -387,7 +411,8 @@ }, "path": ["rows"], "equals": [["infra", 4], ["policy", 3], ["team", 2], ["runbook", 1]] - } + }, + "use_case": "U4 usage counts and trends" }, { "id": "analysis-other-tenants", @@ -405,7 +430,8 @@ }, "path": ["rows"], "equals": [["acme", "acme-handbook", 10]] - } + }, + "use_case": "U4 usage counts and trends" }, { "id": "recommend-key-shape", @@ -417,7 +443,8 @@ "op": "namespace.audit", "args": {}, "findings": ["hash_keys", "double_encoded_values"] - } + }, + "use_case": "U6 write memory better" }, { "id": "recommend-runbook-plane", @@ -434,6 +461,464 @@ }, "path": ["value"], "min_chars": 2048 + }, + "use_case": "U6 write memory better" + }, + { + "id": "help-ask-vs-search", + "kind": "help", + "use_case": "U1 look up a stored fact", + "person": "alice", + "question": "What is the difference between memory.search and memory.ask?", + "expect": ["memory\\.ask", "(answer|synthes)"], + "cite_help": ["features/memory/search-and-ask.md", "features/unified-search.md"], + "baseline": { + "op": "help.search", + "args": { + "query": "What is the difference between memory.search and memory.ask?", + "limit": 5 + } + } + }, + { + "id": "help-upload-file", + "kind": "help", + "use_case": "U2 what a document says", + "person": "alice", + "question": "How do I add a PDF file to Loom as a document?", + "expect": ["knowledge\\.(upload|ingest)"], + "cite_help": ["features/knowledge.md", "reference/operations/knowledge.md"], + "baseline": { + "op": "help.search", + "args": { + "query": "How do I add a PDF file to Loom as a document?", + "limit": 5 + } + } + }, + { + "id": "help-cost-cap", + "kind": "help", + "use_case": "U5 cost and spend", + "person": "alice", + "question": "What is the default daily spend cap of a namespace, and what does Loom skip once it is spent?", + "expect": ["(\\$\\s?1(\\.0+)?\\b|\\b1(\\.0)? ?(USD|dollar)|\\b1\\.0\\b)", "(synthes|extract|skip)"], + "cite_help": ["features/observability/cost-and-usage.md"], + "baseline": { + "op": "help.search", + "args": { + "query": "What is the default daily spend cap of a namespace, and what does Loom skip once it is spent?", + "limit": 5 + } + } + }, + { + "id": "help-key-shape", + "kind": "help", + "use_case": "U6 write memory better", + "person": "alice", + "question": "What shape should a memory key have?", + "expect": ["scope", "kind"], + "cite_help": ["features/memory/writing.md", "concepts/memory.md"], + "baseline": { + "op": "help.search", + "args": { + "query": "What shape should a memory key have?", + "limit": 5 + } + } + }, + { + "id": "help-history", + "kind": "help", + "use_case": "U7 history of a fact", + "person": "alice", + "question": "How do I see every earlier version of a memory?", + "expect": ["memory[._]history"], + "cite_help": ["features/memory/history-and-provenance.md", "concepts/memory.md"], + "baseline": { + "op": "help.search", + "args": { + "query": "How do I see every earlier version of a memory?", + "limit": 5 + } + } + }, + { + "id": "help-graph", + "kind": "help", + "use_case": "U8 entity graph", + "person": "alice", + "question": "How do entities get into Loom's entity graph?", + "expect": ["entit", "(extract|memory\\.set)"], + "cite_help": ["features/entity-graph.md"], + "baseline": { + "op": "help.search", + "args": { + "query": "How do entities get into Loom's entity graph?", + "limit": 5 + } + } + }, + { + "id": "help-add-repo", + "kind": "help", + "use_case": "U9 code index", + "person": "alice", + "question": "How do I add a repository to Loom's code index?", + "expect": ["add (a )?repositor"], + "cite_help": ["features/code-index/repositories.md", "features/code-index/overview.md"], + "baseline": { + "op": "help.search", + "args": { + "query": "How do I add a repository to Loom's code index?", + "limit": 5 + } + } + }, + { + "id": "help-conflict", + "kind": "help", + "use_case": "U10 conflicts and refusal", + "person": "alice", + "question": "What happens when I write a memory that conflicts with one already stored?", + "expect": ["conflict", "(review|conflicts\\.resolve|resolve)"], + "cite_help": ["features/memory/conflicts-and-refusal.md", "concepts/memory.md"], + "baseline": { + "op": "help.search", + "args": { + "query": "What happens when I write a memory that conflicts with one already stored?", + "limit": 5 + } + } + }, + { + "id": "help-collection", + "kind": "help", + "use_case": "U11 sharing and collections", + "person": "alice", + "question": "What is a collection in Loom, and how is one shared?", + "expect": ["col-", "grant"], + "cite_help": [ + "concepts/identities-and-namespaces.md", + "architecture/sharing.md", + "features/namespaces-and-sharing.md" + ], + "baseline": { + "op": "help.search", + "args": { + "query": "What is a collection in Loom, and how is one shared?", + "limit": 5 + } + } + }, + { + "id": "help-my-role", + "kind": "help", + "use_case": "U12 my role and who can change it", + "person": "alice", + "question": "Can I write memories in this namespace? If not, how would I get that?", + "expect": ["viewer", "(admin|grant)"], + "cite_help": [ + "concepts/identities-and-namespaces.md", + "guides/tokens-and-grants.md", + "features/namespaces-and-sharing.md" + ], + "baseline": { + "op": "help.search", + "args": { + "query": "Can I write memories in this namespace? If not, how would I get that?", + "limit": 5 + } + }, + "forbid": ["\\byou (can|may) write\\b", "\\byou are (a |an )?(writer|admin)\\b"] + }, + { + "id": "help-claude-code", + "kind": "help", + "use_case": "U13 connect a coding agent", + "person": "alice", + "question": "How do I connect Claude Code to Loom?", + "expect": ["claude plugin (marketplace add|install)"], + "cite_help": ["getting-started/connect-a-coding-agent.md", "features/integrations/claude-code.md"], + "baseline": { + "op": "help.search", + "args": { + "query": "How do I connect Claude Code to Loom?", + "limit": 5 + } + } + }, + { + "id": "help-revoke-token", + "kind": "help", + "use_case": "U14 tokens", + "person": "alice", + "question": "How do I revoke a Loom token?", + "expect": ["revoke-token"], + "cite_help": ["guides/tokens-and-grants.md", "reference/cli.md"], + "baseline": { + "op": "help.search", + "args": { + "query": "How do I revoke a Loom token?", + "limit": 5 + } + } + }, + { + "id": "help-models-keys", + "kind": "help", + "use_case": "U15 models and keys", + "person": "alice", + "question": "Where do I configure the LLM that Loom uses, and its API key?", + "expect": ["(LOOM_LLM_(MODEL|PROVIDER)|Models (&|and) keys)"], + "cite_help": ["getting-started/models-and-keys.md", "reference/configuration.md"], + "baseline": { + "op": "help.search", + "args": { + "query": "Where do I configure the LLM that Loom uses, and its API key?", + "limit": 5 + } + } + }, + { + "id": "help-health-assistant", + "kind": "help", + "use_case": "U16 health problems", + "person": "alice", + "question": "What does the health problem assistant_service_failing mean?", + "expect": ["LibreChat"], + "cite_help": ["features/integrations/librechat.md", "architecture/assistant.md"], + "baseline": { + "op": "help.search", + "args": { + "query": "What does the health problem assistant_service_failing mean?", + "limit": 5 + } + } + }, + { + "id": "help-why-ranked", + "kind": "help", + "use_case": "U17 why search returned this", + "person": "alice", + "question": "How can I see why a search ranked a memory where it did?", + "expect": ["(explain|score_components|search_trace|Recall)"], + "cite_help": ["concepts/retrieval-and-ranking.md", "guides/debugging.md", "features/memory/search-and-ask.md"], + "baseline": { + "op": "help.search", + "args": { + "query": "How can I see why a search ranked a memory where it did?", + "limit": 5 + } + } + }, + { + "id": "help-runs", + "kind": "help", + "use_case": "U18 runs", + "person": "alice", + "question": "What is a run in Loom, and how does an agent start one?", + "expect": ["run\\.begin"], + "cite_help": ["features/runs.md", "reference/operations/run.md"], + "baseline": { + "op": "help.search", + "args": { + "query": "What is a run in Loom, and how does an agent start one?", + "limit": 5 + } + } + }, + { + "id": "help-tasks", + "kind": "help", + "use_case": "U19 tasks between agents", + "person": "alice", + "question": "How does one agent hand work to another agent in Loom?", + "expect": ["(task|inbox)"], + "cite_help": ["features/tasks-and-decisions.md"], + "baseline": { + "op": "help.search", + "args": { + "query": "How does one agent hand work to another agent in Loom?", + "limit": 5 + } + } + }, + { + "id": "help-tracker", + "kind": "help", + "use_case": "U20 tracker", + "person": "alice", + "question": "Does Loom copy our issue tracker's data into its own database?", + "expect": ["(never copies|reads it live|live|does not copy|doesn't copy)"], + "cite_help": ["features/tracker/overview.md"], + "baseline": { + "op": "help.search", + "args": { + "query": "Does Loom copy our issue tracker's data into its own database?", + "limit": 5 + } + } + }, + { + "id": "help-erase-user", + "kind": "help", + "use_case": "U21 retention and erasure", + "person": "alice", + "question": "Who may erase every memory of one user id across the org?", + "expect": ["org admin"], + "cite_help": ["features/memory/retention-and-erasure.md"], + "baseline": { + "op": "help.search", + "args": { + "query": "Who may erase every memory of one user id across the org?", + "limit": 5 + } + } + }, + { + "id": "help-extraction", + "kind": "help", + "use_case": "U22 extraction from transcripts", + "person": "alice", + "question": "How do I have Loom extract memories from a conversation transcript?", + "expect": ["memory\\.set_from_messages"], + "cite_help": ["features/memory/extraction.md", "guides/extraction-pipeline.md"], + "baseline": { + "op": "help.search", + "args": { + "query": "How do I have Loom extract memories from a conversation transcript?", + "limit": 5 + } + } + }, + { + "id": "help-working-memory", + "kind": "help", + "use_case": "U23 working memory", + "person": "alice", + "question": "What is working memory in Loom, and does it expire?", + "expect": ["(no TTL|surviv|do(es)? not expire|never expire|n.t expire)"], + "cite_help": ["features/memory/working-memory-and-profiles.md"], + "baseline": { + "op": "help.search", + "args": { + "query": "What is working memory in Loom, and does it expire?", + "limit": 5 + } + } + }, + { + "id": "help-langfuse", + "kind": "help", + "use_case": "U24 integrations", + "person": "alice", + "question": "Which settings send Loom's traces to Langfuse?", + "expect": ["LOOM_LANGFUSE_URL", "LOOM_LANGFUSE_ADMIN_TOKEN"], + "cite_help": ["features/integrations/langfuse.md"], + "baseline": { + "op": "help.search", + "args": { + "query": "Which settings send Loom's traces to Langfuse?", + "limit": 5 + } + } + }, + { + "id": "help-setting", + "kind": "help", + "use_case": "U25 what a setting does", + "person": "alice", + "question": "What does LOOM_ASSISTANT_MODEL set?", + "expect": ["(assistant|agent)", "model"], + "cite_help": ["reference/configuration.md", "architecture/assistant.md"], + "baseline": { + "op": "help.search", + "args": { + "query": "What does LOOM_ASSISTANT_MODEL set?", + "limit": 5 + } + } + }, + { + "id": "help-quickstart", + "kind": "help", + "use_case": "U26 getting started", + "person": "alice", + "question": "Does Loom's quickstart need an API key?", + "expect": ["\\bno\\b"], + "cite_help": ["getting-started/quickstart.md"], + "baseline": { + "op": "help.search", + "args": { + "query": "Does Loom's quickstart need an API key?", + "limit": 5 + } + } + }, + { + "id": "help-upgrade", + "kind": "help", + "use_case": "U27 operating a deployment", + "person": "alice", + "question": "How do I upgrade a Loom deployment to a new release?", + "expect": ["migrate"], + "cite_help": ["operations/upgrades.md"], + "baseline": { + "op": "help.search", + "args": { + "query": "How do I upgrade a Loom deployment to a new release?", + "limit": 5 + } + } + }, + { + "id": "help-undocumented", + "kind": "help_abstain", + "use_case": "U28 refusals and abstentions", + "person": "alice", + "question": "Which Loom setting changes the colour theme of the dashboard?", + "expect": [], + "cite_help": [], + "baseline": { + "op": "help.search", + "args": { + "query": "Which Loom setting changes the colour theme of the dashboard?", + "limit": 5 + } + }, + "forbid": ["LOOM_[A-Z_]*THEME"] + }, + { + "id": "data-connected-agents", + "kind": "inventory", + "use_case": "U24 integrations", + "person": "alice", + "question": "Which agents have written to this namespace?", + "expect": ["handbook-bot", "ops-bot"], + "baseline": { + "op": "namespace.inventory", + "args": {}, + "path": ["populations"], + "count": true, + "equals": 4 + } + }, + { + "id": "data-history", + "kind": "memory", + "use_case": "U7 history of a fact", + "person": "alice", + "question": "Has the default public API rate limit changed over time? What was it before?", + "expect": ["300", "600"], + "cite": "policy/api/rate-limit", + "baseline": { + "op": "memory.search", + "args": { + "query": "default public API rate limit", + "top_k": 1 + } } } ] diff --git a/integrations/librechat/qualification/qualify.py b/integrations/librechat/qualification/qualify.py index 3bec14191f..2a32beb8ee 100644 --- a/integrations/librechat/qualification/qualify.py +++ b/integrations/librechat/qualification/qualify.py @@ -398,6 +398,9 @@ def ask_assistant(st: dict[str, Any], person: str, question: str) -> dict[str, A text: list[str] = [] usage: dict[str, Any] = {} error = "" + checked: list[dict[str, Any]] = [] + unknown: list[str] = [] + support = "" with httpx.stream("POST", url, json=body, headers=headers, timeout=180) as r: if r.status_code != 200: error = f"HTTP {r.status_code}: {r.read().decode()[:300]}" @@ -406,6 +409,12 @@ def ask_assistant(st: dict[str, Any], person: str, question: str) -> dict[str, A if not line.startswith("data: ") or line == "data: [DONE]": continue chunk = json.loads(line[6:]) + if chunk.get("object") == "loom.citations": + # The bridge's own check of the answer's citations, and its names. + checked = chunk.get("citations") or [] + unknown = chunk.get("unknown_names") or [] + support = str(chunk.get("support") or "") + continue if chunk.get("error"): error = json.dumps(chunk["error"])[:300] usage = chunk.get("usage") or usage @@ -426,6 +435,9 @@ def ask_assistant(st: dict[str, Any], person: str, question: str) -> dict[str, A "first_text_s": first_text, "prompt_tokens": usage.get("prompt_tokens", 0), "completion_tokens": usage.get("completion_tokens", 0), + "server_citations": checked, + "unknown_names": unknown, + "support": support, } @@ -482,7 +494,28 @@ def check_citations( cited: list[str] = [] invalid: list[str] = [] current: dict[str, int | None] = {} # each key's current version, read once - found = list(KEY_RE.finditer(text)) + versions: dict[str, set[int]] = {} # each key's every version, read when one is cited + + def history(key: str) -> set[int]: + if key not in versions: + body = { + "org": person["org"], + "namespace": ns, + "memory_key": key, + "agent": writers.get(key, "-"), + } + code, out, _ = loom_call(st["loom_url"], scorer, "memory.history", body) + rows = (out.get("rows") or []) if code == 200 else [] + versions[key] = {int(r["version"]) for r in rows if r.get("version")} + return versions[key] + + # A help citation's page path (`features/memory/writing.md`) is no memory key. An + # answer through Loom's assistant cites a memory as `[memory:@v]`, so a + # key-shaped example it quotes from the docs (`scope/kind/id`) is no citation either. + keyed = HELP_CITE_RE.sub("", text) + if st.get("bridge"): + keyed = " ".join(m[0] for m in re.finditer(r"\[memory:[^\]]+\]", keyed)) + found = list(KEY_RE.finditer(keyed)) for i, m in enumerate(found): key = m.group(0) if key not in current: @@ -501,10 +534,14 @@ def check_citations( if current[key] is None: continue # Every mention is checked: a version belongs to the key before it, up to the next key. - end = min(m.end() + 80, found[i + 1].start() if i + 1 < len(found) else len(text)) + end = min(m.end() + 80, found[i + 1].start() if i + 1 < len(found) else len(keyed)) # A bare version, or the deployed agent's `[memory:@v]`. - near = re.search(r"(?:\b|@v)(\d{16,20})\b", text[m.end() : end]) + near = re.search(r"(?:\b|@v)(\d{16,20})\b", keyed[m.end() : end]) if near and int(near.group(1)) != current[key]: + # An earlier version is a valid citation of what the key once held (an answer + # about its history); a version the key never had is not. + if int(near.group(1)) in history(key): + continue stale = f"{key}@{near.group(1)}" if stale not in invalid: invalid.append(stale) @@ -527,6 +564,64 @@ def parse_doc_citations(text: str) -> list[dict[str, Any]]: return out +# A help citation as the instructions ask for it: `[help: § B>]`, the section +# optional. +HELP_CITE_RE = re.compile(r"\[help:(?P[^\]§\s]+?)(?:\s*§\s*(?P
[^\]]+?))?\s*\]") +# How an answer says the documentation does not cover a question. +HELP_ABSTAIN_PATTERNS = ( + r"\bnot (documented|covered|described|mentioned|in (loom's|the) documentation)\b", + r"\b(documentation|docs) (does|do) ?n[o']t (cover|describe|mention|say)\b", + r"\bno (documented|such) (setting|option|feature)\b", + r"\b(could ?n[o']t|did ?n[o']t|can ?not) find\b", +) + + +def is_help_case(case: dict[str, Any]) -> bool: + """A question about Loom itself: its direct path is help.search.""" + return case["baseline"]["op"] == "help.search" + + +def check_help_citations( + st: dict[str, Any], person: dict[str, Any], case: dict[str, Any], text: str +) -> tuple[list[str], list[str], bool]: + """Every help citation the answer writes, those that are not valid, and whether one + of the case's labeled pages is among the valid ones. Valid: the page is in the + server's documentation and a named section is one of its own (help.get with the + scorer's token, no model).""" + scorer = st["tokens"][f"scorer:{person['namespace']}"] + cited: list[str] = [] + invalid: list[str] = [] + pages = set(case.get("cite_help") or []) + expected = False + for m in HELP_CITE_RE.finditer(text): + name = m.group(0)[1:-1] + if name in cited: + continue + cited.append(name) + path = m["path"].removeprefix("docs/") + page = scorer_read(st, scorer, "help.get", {"path": path}) + if not page.get("found"): + invalid.append(f"{name}: no such page") + continue + section = m["section"] or "" + if section and not names_section( + section_key(section), [section_key(e["section"]) for e in page.get("sections", [])] + ): + invalid.append(f"{name}: no such section") + continue + expected = expected or path in pages + return cited, invalid, expected + + +def names_section(cited: tuple[str, ...], sections: list[tuple[str, ...]]) -> bool: + """Whether a cited breadcrumb names one of a page's sections, as the server's check reads + it (`server.help.domain.index.find_section`): equal to one, equal to one without the + page title, or a tail only one section of the page has.""" + if cited in sections or any(s[1:] == cited for s in sections): + return True + return sum(s[-len(cited) :] == cited for s in sections) == 1 + + def section_key(section: str) -> tuple[str, ...]: """A breadcrumb compared case- and spacing-blind: `A > B` and `a >b` are one section.""" return tuple(" ".join(p.split()).casefold() for p in section.split(">") if p.strip()) @@ -624,6 +719,9 @@ def score(case: dict[str, Any], text: str) -> dict[str, Any]: ) if kind == "abstain": correct = abstained + elif kind == "help_abstain": + abstained = matches(HELP_ABSTAIN_PATTERNS, text) + correct = abstained elif kind == "refusal": correct = matches(REFUSAL_PATTERNS, text) else: @@ -677,6 +775,13 @@ def native_score(case: dict[str, Any], code: int, out: dict[str, Any]) -> dict[s correct = correct and case["kind"] != "refusal" elif spec["op"] == "knowledge.search": return native_document_score(case, out) + elif spec["op"] == "help.search": + # The direct path finds the page; it writes no answer, so only that is scored. + pages = [h["path"] for h in out.get("hits") or []] + text = json.dumps(pages) + wanted = set(case.get("cite_help") or []) + correct = bool(wanted & set(pages)) if wanted else not pages + cited = pages[:1] elif "findings" in spec: # A recommendation's direct path: the audit names each labeled finding on rows. found = {f["code"] for f in out.get("findings", []) if f.get("count")} @@ -758,10 +863,13 @@ def cmd_run(args: argparse.Namespace) -> None: calls = loom_calls(args.ch_url, case["person"], t0, t1) text = got["answer"] or got["error"] result = score(case, text) + # An answer that names an op or setting the build neither serves nor documents. + result["correct"] = result["correct"] and not got.get("unknown_names") rows.append( { "id": case["id"], "kind": case["kind"], + "use_case": case.get("use_case", ""), "documents": is_document_case(case), "librechat": { **got, @@ -800,6 +908,13 @@ def answer_citations( doc_cited, doc_invalid, doc_expected = check_doc_citations(st, person, case, text) cited, invalid = cited + doc_cited, invalid + doc_invalid expected = doc_expected if case.get("cite_doc") else None + if HELP_CITE_RE.search(text): + help_cited, help_invalid, help_expected = check_help_citations(st, person, case, text) + cited, invalid = cited + help_cited, invalid + help_invalid + if case.get("cite_help"): + expected = help_expected + elif case.get("cite_help"): + expected = False return {"cited": cited, "invalid_citations": invalid, "cited_expected": expected} @@ -978,6 +1093,7 @@ def report(rows: list[dict[str, Any]], model: str) -> str: f"tool calls {sum(g['tool_calls'] for g in got)}" ) lines.extend(document_report(cases)) + lines.extend(use_case_report(cases)) price_in, price_out = PRICE_PER_MTOK.get(model, (float("nan"), float("nan"))) costs = [ ( @@ -1000,6 +1116,27 @@ def report(rows: list[dict[str, Any]], model: str) -> str: return "\n".join(lines) +def use_case_report(cases: list[dict[str, Any]]) -> list[str]: + """Per use case (cases.json `use_case`): the answers through LibreChat that are + correct and cite validly, out of its cases.""" + by: dict[str, list[dict[str, Any]]] = {} + for r in cases: + by.setdefault(r.get("use_case") or "-", []).append(r) + lines = [ + "\n| use case | correct | citations valid | unknown names |", + "| --- | --- | --- | --- |", + ] + for name in sorted(by): + got = [r["librechat"] for r in by[name]] + valid = sum(not g["invalid_citations"] for g in got) + unknown = sorted({n for g in got for n in g.get("unknown_names") or []}) + lines.append( + f"| {name} | {sum(g['correct'] for g in got)}/{len(got)} | {valid}/{len(got)} " + f"| {', '.join(unknown) or '-'} |" + ) + return lines + + def document_report(cases: list[dict[str, Any]]) -> list[str]: """The document cases on their own: recall of the labeled section among the direct path's hits, citation validity, the labeled section cited, and abstention.""" diff --git a/server/operations/reach_manifest.py b/server/operations/reach_manifest.py index a1af5c7aeb..9681046813 100644 --- a/server/operations/reach_manifest.py +++ b/server/operations/reach_manifest.py @@ -249,7 +249,11 @@ "sdk_method", "dashboard", ), - "help.get": ("dashboard",), + "help.get": ( + "plugin_hook", + "dashboard", + ), + "help.search": ("plugin_hook",), "inbox.list": ("dashboard",), "inbox.policy_list": ("dashboard",), "inbox.policy_set": ("dashboard",), @@ -410,6 +414,7 @@ "memory.health": ("dashboard",), "memory.history": ( "sdk_method", + "plugin_hook", "dashboard", ), "memory.import_curated": ("dashboard",), diff --git a/tests/unit/test_librechat_integration.py b/tests/unit/test_librechat_integration.py index 6fb340e98a..e1890ef820 100644 --- a/tests/unit/test_librechat_integration.py +++ b/tests/unit/test_librechat_integration.py @@ -178,9 +178,14 @@ def test_native_score_compares_counts_as_numbers(): def test_check_citations_flags_unknown_keys_and_stale_versions(monkeypatch): q = _qualify() rows = {"policy/deploy/freeze": 1793745407448901606} + # An earlier version of a key is a valid citation of what it once held. + history = {"policy/deploy/freeze": [1793745407448901606, 1793745400000000000]} def fake_call(base, token, op, body): - assert op == "memory.get" and token == "viewer-token" + assert op in ("memory.get", "memory.history") and token == "viewer-token" + if op == "memory.history": + versions = history.get(body["memory_key"], []) + return 200, {"rows": [{"version": v} for v in versions]}, 0.0 version = rows.get(body["memory_key"]) return 200, {"found": version is not None, "version": version}, 0.0 @@ -202,6 +207,8 @@ def fake_call(base, token, op, body): ["policy/deploy/freeze"], ["policy/deploy/freeze@1793745407000000000"], ) + earlier = "Before: `policy/deploy/freeze` (version 1793745400000000000)." + assert q.check_citations(st, person, earlier) == (["policy/deploy/freeze"], []) unknown = "See policy/deploy/thaw." assert q.check_citations(st, person, unknown) == ( ["policy/deploy/thaw"], From 3c6db564817d7543950111e1660ef7920db5edda Mon Sep 17 00:00:00 2001 From: zlareb1 Date: Wed, 11 Nov 2026 00:05:28 +0000 Subject: [PATCH 02/41] The harness checks a help section by the server's exact rule and leaves the unscored direct path out of its totals A help breadcrumb keeps its case, as the server's section_path does. The summary counts a help abstention with the abstentions; the direct path of a question the docs leave open is not scored. Use cases are listed in number order, with the guide's labels. Tests cover the help citation check, the memory-citation filters, help abstention and unknown-name scoring, and the report. Co-Authored-By: Claude Opus 5.5 Signed-off-by: zlareb1 --- .../librechat/qualification/cases.json | 112 ++++++------ .../librechat/qualification/qualify.py | 68 +++++-- tests/unit/test_librechat_integration.py | 170 ++++++++++++++++++ 3 files changed, 278 insertions(+), 72 deletions(-) diff --git a/integrations/librechat/qualification/cases.json b/integrations/librechat/qualification/cases.json index a2cf607de6..940d38a18f 100644 --- a/integrations/librechat/qualification/cases.json +++ b/integrations/librechat/qualification/cases.json @@ -13,7 +13,7 @@ "top_k": 1 } }, - "use_case": "U1 look up a stored fact" + "use_case": "U1 Look up a stored fact" }, { "id": "memory-db-version", @@ -29,7 +29,7 @@ "top_k": 1 } }, - "use_case": "U1 look up a stored fact" + "use_case": "U1 Look up a stored fact" }, { "id": "memory-oncall", @@ -45,7 +45,7 @@ "top_k": 1 } }, - "use_case": "U1 look up a stored fact" + "use_case": "U1 Look up a stored fact" }, { "id": "memory-webhook-retries", @@ -61,7 +61,7 @@ "top_k": 1 } }, - "use_case": "U1 look up a stored fact" + "use_case": "U1 Look up a stored fact" }, { "id": "memory-backups", @@ -77,7 +77,7 @@ "top_k": 1 } }, - "use_case": "U1 look up a stored fact" + "use_case": "U1 Look up a stored fact" }, { "id": "memory-revised-rate-limit", @@ -94,7 +94,7 @@ } }, "forbid": ["\\b300\\b"], - "use_case": "U1 look up a stored fact" + "use_case": "U1 Look up a stored fact" }, { "id": "inventory-count", @@ -108,7 +108,7 @@ "path": ["sections", 0, "count"], "equals": 10 }, - "use_case": "U3 what the namespace holds" + "use_case": "U3 What the namespace holds" }, { "id": "inventory-top-agent", @@ -125,7 +125,7 @@ "rows": 7 } }, - "use_case": "U3 what the namespace holds" + "use_case": "U3 What the namespace holds" }, { "id": "inspect-agent", @@ -142,7 +142,7 @@ "path": ["own", "live_rows"], "equals": 3 }, - "use_case": "U3 what the namespace holds" + "use_case": "U3 What the namespace holds" }, { "id": "tune-drafts", @@ -158,7 +158,7 @@ "equals": 0 }, "forbid": ["\\b([1-9]\\d*|one|two|three|four|five)\\s+(tuning\\s+)?(proposals?|drafts?)\\b"], - "use_case": "U6 write memory better" + "use_case": "U6 Write memory better" }, { "id": "cross-tenant", @@ -175,7 +175,7 @@ "top_k": 1 } }, - "use_case": "U28 refusals and abstentions" + "use_case": "U28 Refusals and abstentions" }, { "id": "revoked-token", @@ -190,7 +190,7 @@ "top_k": 1 } }, - "use_case": "U28 refusals and abstentions" + "use_case": "U28 Refusals and abstentions" }, { "id": "abstain-wifi", @@ -204,7 +204,7 @@ "top_k": 1 } }, - "use_case": "U28 refusals and abstentions" + "use_case": "U28 Refusals and abstentions" }, { "id": "abstain-cfo", @@ -218,7 +218,7 @@ "top_k": 1 } }, - "use_case": "U28 refusals and abstentions" + "use_case": "U28 Refusals and abstentions" }, { "id": "doc-release-reviews", @@ -237,7 +237,7 @@ "top_k": 5 } }, - "use_case": "U2 what a document says" + "use_case": "U2 What a document says" }, { "id": "doc-migration-rollback", @@ -256,7 +256,7 @@ "top_k": 5 } }, - "use_case": "U2 what a document says" + "use_case": "U2 What a document says" }, { "id": "doc-canary", @@ -275,7 +275,7 @@ "top_k": 5 } }, - "use_case": "U2 what a document says" + "use_case": "U2 What a document says" }, { "id": "doc-contract-notice", @@ -294,7 +294,7 @@ "top_k": 5 } }, - "use_case": "U2 what a document says" + "use_case": "U2 What a document says" }, { "id": "doc-orders-ttl", @@ -313,7 +313,7 @@ "top_k": 5 } }, - "use_case": "U2 what a document says" + "use_case": "U2 What a document says" }, { "id": "doc-cache-entries", @@ -332,7 +332,7 @@ "top_k": 5 } }, - "use_case": "U2 what a document says" + "use_case": "U2 What a document says" }, { "id": "doc-revised-ack", @@ -352,7 +352,7 @@ } }, "forbid": ["\\b(15|fifteen)\\s*min"], - "use_case": "U2 what a document says" + "use_case": "U2 What a document says" }, { "id": "abstain-doc-credit", @@ -366,7 +366,7 @@ "top_k": 5 } }, - "use_case": "U2 what a document says" + "use_case": "U2 What a document says" }, { "id": "abstain-doc-phone", @@ -380,7 +380,7 @@ "top_k": 5 } }, - "use_case": "U2 what a document says" + "use_case": "U2 What a document says" }, { "id": "analysis-per-agent", @@ -396,7 +396,7 @@ "path": ["rows"], "equals": [["handbook-bot", 7], ["ops-bot", 3]] }, - "use_case": "U4 usage counts and trends" + "use_case": "U4 Usage counts and trends" }, { "id": "analysis-per-scope", @@ -412,7 +412,7 @@ "path": ["rows"], "equals": [["infra", 4], ["policy", 3], ["team", 2], ["runbook", 1]] }, - "use_case": "U4 usage counts and trends" + "use_case": "U4 Usage counts and trends" }, { "id": "analysis-other-tenants", @@ -431,7 +431,7 @@ "path": ["rows"], "equals": [["acme", "acme-handbook", 10]] }, - "use_case": "U4 usage counts and trends" + "use_case": "U4 Usage counts and trends" }, { "id": "recommend-key-shape", @@ -444,7 +444,7 @@ "args": {}, "findings": ["hash_keys", "double_encoded_values"] }, - "use_case": "U6 write memory better" + "use_case": "U6 Write memory better" }, { "id": "recommend-runbook-plane", @@ -462,12 +462,12 @@ "path": ["value"], "min_chars": 2048 }, - "use_case": "U6 write memory better" + "use_case": "U6 Write memory better" }, { "id": "help-ask-vs-search", "kind": "help", - "use_case": "U1 look up a stored fact", + "use_case": "U1 Look up a stored fact", "person": "alice", "question": "What is the difference between memory.search and memory.ask?", "expect": ["memory\\.ask", "(answer|synthes)"], @@ -483,7 +483,7 @@ { "id": "help-upload-file", "kind": "help", - "use_case": "U2 what a document says", + "use_case": "U2 What a document says", "person": "alice", "question": "How do I add a PDF file to Loom as a document?", "expect": ["knowledge\\.(upload|ingest)"], @@ -499,7 +499,7 @@ { "id": "help-cost-cap", "kind": "help", - "use_case": "U5 cost and spend", + "use_case": "U5 Cost and spend", "person": "alice", "question": "What is the default daily spend cap of a namespace, and what does Loom skip once it is spent?", "expect": ["(\\$\\s?1(\\.0+)?\\b|\\b1(\\.0)? ?(USD|dollar)|\\b1\\.0\\b)", "(synthes|extract|skip)"], @@ -515,7 +515,7 @@ { "id": "help-key-shape", "kind": "help", - "use_case": "U6 write memory better", + "use_case": "U6 Write memory better", "person": "alice", "question": "What shape should a memory key have?", "expect": ["scope", "kind"], @@ -531,7 +531,7 @@ { "id": "help-history", "kind": "help", - "use_case": "U7 history of a fact", + "use_case": "U7 History of a fact", "person": "alice", "question": "How do I see every earlier version of a memory?", "expect": ["memory[._]history"], @@ -547,7 +547,7 @@ { "id": "help-graph", "kind": "help", - "use_case": "U8 entity graph", + "use_case": "U8 Entity graph", "person": "alice", "question": "How do entities get into Loom's entity graph?", "expect": ["entit", "(extract|memory\\.set)"], @@ -563,7 +563,7 @@ { "id": "help-add-repo", "kind": "help", - "use_case": "U9 code index", + "use_case": "U9 Code index", "person": "alice", "question": "How do I add a repository to Loom's code index?", "expect": ["add (a )?repositor"], @@ -579,7 +579,7 @@ { "id": "help-conflict", "kind": "help", - "use_case": "U10 conflicts and refusal", + "use_case": "U10 Conflicts and refusal", "person": "alice", "question": "What happens when I write a memory that conflicts with one already stored?", "expect": ["conflict", "(review|conflicts\\.resolve|resolve)"], @@ -595,7 +595,7 @@ { "id": "help-collection", "kind": "help", - "use_case": "U11 sharing and collections", + "use_case": "U11 Sharing and collections", "person": "alice", "question": "What is a collection in Loom, and how is one shared?", "expect": ["col-", "grant"], @@ -615,7 +615,7 @@ { "id": "help-my-role", "kind": "help", - "use_case": "U12 my role and who can change it", + "use_case": "U12 My role and who can change it", "person": "alice", "question": "Can I write memories in this namespace? If not, how would I get that?", "expect": ["viewer", "(admin|grant)"], @@ -636,7 +636,7 @@ { "id": "help-claude-code", "kind": "help", - "use_case": "U13 connect a coding agent", + "use_case": "U13 Connect a coding agent", "person": "alice", "question": "How do I connect Claude Code to Loom?", "expect": ["claude plugin (marketplace add|install)"], @@ -652,7 +652,7 @@ { "id": "help-revoke-token", "kind": "help", - "use_case": "U14 tokens", + "use_case": "U14 Tokens", "person": "alice", "question": "How do I revoke a Loom token?", "expect": ["revoke-token"], @@ -668,7 +668,7 @@ { "id": "help-models-keys", "kind": "help", - "use_case": "U15 models and keys", + "use_case": "U15 Models and keys", "person": "alice", "question": "Where do I configure the LLM that Loom uses, and its API key?", "expect": ["(LOOM_LLM_(MODEL|PROVIDER)|Models (&|and) keys)"], @@ -684,7 +684,7 @@ { "id": "help-health-assistant", "kind": "help", - "use_case": "U16 health problems", + "use_case": "U16 Health problems", "person": "alice", "question": "What does the health problem assistant_service_failing mean?", "expect": ["LibreChat"], @@ -700,7 +700,7 @@ { "id": "help-why-ranked", "kind": "help", - "use_case": "U17 why search returned this", + "use_case": "U17 Why search returned this", "person": "alice", "question": "How can I see why a search ranked a memory where it did?", "expect": ["(explain|score_components|search_trace|Recall)"], @@ -716,7 +716,7 @@ { "id": "help-runs", "kind": "help", - "use_case": "U18 runs", + "use_case": "U18 Runs", "person": "alice", "question": "What is a run in Loom, and how does an agent start one?", "expect": ["run\\.begin"], @@ -732,7 +732,7 @@ { "id": "help-tasks", "kind": "help", - "use_case": "U19 tasks between agents", + "use_case": "U19 Tasks between agents", "person": "alice", "question": "How does one agent hand work to another agent in Loom?", "expect": ["(task|inbox)"], @@ -748,7 +748,7 @@ { "id": "help-tracker", "kind": "help", - "use_case": "U20 tracker", + "use_case": "U20 Tracker", "person": "alice", "question": "Does Loom copy our issue tracker's data into its own database?", "expect": ["(never copies|reads it live|live|does not copy|doesn't copy)"], @@ -764,7 +764,7 @@ { "id": "help-erase-user", "kind": "help", - "use_case": "U21 retention and erasure", + "use_case": "U21 Retention and erasure", "person": "alice", "question": "Who may erase every memory of one user id across the org?", "expect": ["org admin"], @@ -780,7 +780,7 @@ { "id": "help-extraction", "kind": "help", - "use_case": "U22 extraction from transcripts", + "use_case": "U22 Extraction from transcripts", "person": "alice", "question": "How do I have Loom extract memories from a conversation transcript?", "expect": ["memory\\.set_from_messages"], @@ -796,7 +796,7 @@ { "id": "help-working-memory", "kind": "help", - "use_case": "U23 working memory", + "use_case": "U23 Working memory", "person": "alice", "question": "What is working memory in Loom, and does it expire?", "expect": ["(no TTL|surviv|do(es)? not expire|never expire|n.t expire)"], @@ -812,7 +812,7 @@ { "id": "help-langfuse", "kind": "help", - "use_case": "U24 integrations", + "use_case": "U24 Integrations", "person": "alice", "question": "Which settings send Loom's traces to Langfuse?", "expect": ["LOOM_LANGFUSE_URL", "LOOM_LANGFUSE_ADMIN_TOKEN"], @@ -828,7 +828,7 @@ { "id": "help-setting", "kind": "help", - "use_case": "U25 what a setting does", + "use_case": "U25 What a setting does", "person": "alice", "question": "What does LOOM_ASSISTANT_MODEL set?", "expect": ["(assistant|agent)", "model"], @@ -844,7 +844,7 @@ { "id": "help-quickstart", "kind": "help", - "use_case": "U26 getting started", + "use_case": "U26 Getting started", "person": "alice", "question": "Does Loom's quickstart need an API key?", "expect": ["\\bno\\b"], @@ -860,7 +860,7 @@ { "id": "help-upgrade", "kind": "help", - "use_case": "U27 operating a deployment", + "use_case": "U27 Operating a deployment", "person": "alice", "question": "How do I upgrade a Loom deployment to a new release?", "expect": ["migrate"], @@ -876,7 +876,7 @@ { "id": "help-undocumented", "kind": "help_abstain", - "use_case": "U28 refusals and abstentions", + "use_case": "U28 Refusals and abstentions", "person": "alice", "question": "Which Loom setting changes the colour theme of the dashboard?", "expect": [], @@ -893,7 +893,7 @@ { "id": "data-connected-agents", "kind": "inventory", - "use_case": "U24 integrations", + "use_case": "U24 Integrations", "person": "alice", "question": "Which agents have written to this namespace?", "expect": ["handbook-bot", "ops-bot"], @@ -908,7 +908,7 @@ { "id": "data-history", "kind": "memory", - "use_case": "U7 history of a fact", + "use_case": "U7 History of a fact", "person": "alice", "question": "Has the default public API rate limit changed over time? What was it before?", "expect": ["300", "600"], diff --git a/integrations/librechat/qualification/qualify.py b/integrations/librechat/qualification/qualify.py index 2a32beb8ee..f99941db2b 100644 --- a/integrations/librechat/qualification/qualify.py +++ b/integrations/librechat/qualification/qualify.py @@ -480,7 +480,7 @@ def check_citations( st: dict[str, Any], person: dict[str, Any], text: str ) -> tuple[list[str], list[str]]: """Every memory key the answer names, and those that do not exist in the person's namespace - or name a version other than the row's current one.""" + or name a version the key never had.""" ns = person["namespace"] scorer = st["tokens"][f"scorer:{ns}"] # memory.get over HTTP reads one writer's row; the fixture says who wrote each key. @@ -576,6 +576,10 @@ def parse_doc_citations(text: str) -> list[dict[str, Any]]: ) +# The kinds whose right answer is an abstention: from the namespace, or from the docs. +ABSTAIN_KINDS = ("abstain", "help_abstain") + + def is_help_case(case: dict[str, Any]) -> bool: """A question about Loom itself: its direct path is help.search.""" return case["baseline"]["op"] == "help.search" @@ -605,7 +609,8 @@ def check_help_citations( continue section = m["section"] or "" if section and not names_section( - section_key(section), [section_key(e["section"]) for e in page.get("sections", [])] + help_breadcrumb(section), + [help_breadcrumb(e["section"]) for e in page.get("sections", [])], ): invalid.append(f"{name}: no such section") continue @@ -622,6 +627,12 @@ def names_section(cited: tuple[str, ...], sections: list[tuple[str, ...]]) -> bo return sum(s[-len(cited) :] == cited for s in sections) == 1 +def help_breadcrumb(section: str) -> tuple[str, ...]: + """A help breadcrumb as its headings, as the server reads it + (`server.help.domain.index.section_path`): each trimmed, case and inner spacing kept.""" + return tuple(part.strip() for part in section.split(">") if part.strip()) + + def section_key(section: str) -> tuple[str, ...]: """A breadcrumb compared case- and spacing-blind: `A > B` and `a >b` are one section.""" return tuple(" ".join(p.split()).casefold() for p in section.split(">") if p.strip()) @@ -730,6 +741,14 @@ def score(case: dict[str, Any], text: str) -> dict[str, Any]: return {"correct": correct, "abstained": abstained} +def score_answer(case: dict[str, Any], got: dict[str, Any]) -> dict[str, Any]: + """Score an answer through LibreChat: its text, and wrong when it names an op or setting + the build neither serves nor documents (the bridge's `unknown_names`).""" + result = score(case, got["answer"] or got["error"]) + result["correct"] = result["correct"] and not got.get("unknown_names") + return result + + # ---------------------------------------------------------------- run @@ -776,11 +795,13 @@ def native_score(case: dict[str, Any], code: int, out: dict[str, Any]) -> dict[s elif spec["op"] == "knowledge.search": return native_document_score(case, out) elif spec["op"] == "help.search": - # The direct path finds the page; it writes no answer, so only that is scored. + # The direct path finds the page; it writes no answer, so only that is scored. A + # question the docs leave open has no page to find, and a word search finds some + # page for any question, so that case's direct path is not scored (None). pages = [h["path"] for h in out.get("hits") or []] text = json.dumps(pages) wanted = set(case.get("cite_help") or []) - correct = bool(wanted & set(pages)) if wanted else not pages + correct = bool(wanted & set(pages)) if wanted else None cited = pages[:1] elif "findings" in spec: # A recommendation's direct path: the audit names each labeled finding on rows. @@ -862,9 +883,7 @@ def cmd_run(args: argparse.Namespace) -> None: time.sleep(2) # the ledger write is asynchronous calls = loom_calls(args.ch_url, case["person"], t0, t1) text = got["answer"] or got["error"] - result = score(case, text) - # An answer that names an op or setting the build neither serves nor documents. - result["correct"] = result["correct"] and not got.get("unknown_names") + result = score_answer(case, got) rows.append( { "id": case["id"], @@ -887,9 +906,9 @@ def cmd_run(args: argparse.Namespace) -> None: ) lc = rows[-1]["librechat"] print( - f"{case['id']:<28} librechat {'ok ' if lc['correct'] else 'BAD'} " + f"{case['id']:<28} librechat {verdict(lc['correct'])} " f"{lc['latency_s']:5.1f}s tools={lc['tool_calls']} | " - f"native {'ok ' if native['correct'] else 'BAD'} {native['latency_s']:.2f}s" + f"native {verdict(native['correct'])} {native['latency_s']:.2f}s" ) if args.cancel_probe: rows.append(cancel_probe(st, args)) @@ -936,8 +955,7 @@ def run_native_only(st: dict[str, Any], people: dict[str, Any], args: argparse.N rows[case["id"]]["native"] = baseline(st, case, people[case["person"]]) native = rows[case["id"]]["native"] print( - f"{case['id']:<28} native {'ok ' if native['correct'] else 'BAD'} " - f"{native['latency_s']:.2f}s" + f"{case['id']:<28} native {verdict(native['correct'])} {native['latency_s']:.2f}s" ) out.write_text(json.dumps(saved, indent=2)) print(report(saved["rows"], saved.get("model", ""))) @@ -1044,6 +1062,15 @@ def pct(values: list[float], q: float) -> float: return values[min(len(values) - 1, round(q * (len(values) - 1)))] +def verdict(correct: bool | None) -> str: + """A case's line in a run's log: `- ` for a path that is not scored.""" + return "- " if correct is None else "ok " if correct else "BAD" + + +def yes_no(correct: bool | None) -> str: + return "-" if correct is None else "yes" if correct else "no" + + def fmt_s(seconds: float | None, digits: int = 2, unit: str = "") -> str: return "-" if seconds is None else f"{seconds:.{digits}f}{unit}" @@ -1062,13 +1089,14 @@ def report(rows: list[dict[str, Any]], model: str) -> str: f"| {r['id']} | {r['kind']} | {'yes' if lc['correct'] else 'no'} | {len(lc['cited'])} " f"({len(lc['invalid_citations'])}) | {lc['tool_calls']} | {lc['latency_s']:.1f} | " f"{ttft} | " - f"{'yes' if nv['correct'] else 'no'} | {nv['latency_s']:.2f} |" + f"{yes_no(nv['correct'])} | {nv['latency_s']:.2f} |" ) # The document cases are reported on their own lines (document_report). others = [r for r in cases if not r.get("documents")] if others: for side in ("librechat", "native"): got = [r[side] for r in others] + scored = [g for g in got if g["correct"] is not None] lat = [g["latency_s"] for g in got] ttft = [g["ttft_s"] for g in got if g["ttft_s"] is not None] cited = sum(len(g["cited"]) for g in got) @@ -1076,14 +1104,16 @@ def report(rows: list[dict[str, Any]], model: str) -> str: # The direct path cites the search hit itself, so its citations are not checked. validity = "-" if side == "native" else f"{cited - invalid}/{cited} valid" expected = [g["cited_expected"] for g in got if g["cited_expected"] is not None] - abst = [r for r in others if r["kind"] == "abstain"] + abst = [ + r for r in others if r["kind"] in ABSTAIN_KINDS and r[side]["correct"] is not None + ] false_abst = [ r for r in others - if r["kind"] not in ("abstain", "refusal") and r[side]["abstained"] + if r["kind"] not in (*ABSTAIN_KINDS, "refusal") and r[side]["abstained"] ] lines.append( - f"\n{side}: correct {sum(g['correct'] for g in got)}/{len(got)}; " + f"\n{side}: correct {sum(g['correct'] for g in scored)}/{len(scored)}; " f"citations {validity}, " f"expected key cited {sum(expected)}/{len(expected)}; " f"abstained {sum(r[side]['correct'] for r in abst)}/{len(abst)} where it should, " @@ -1126,7 +1156,7 @@ def use_case_report(cases: list[dict[str, Any]]) -> list[str]: "\n| use case | correct | citations valid | unknown names |", "| --- | --- | --- | --- |", ] - for name in sorted(by): + for name in sorted(by, key=use_case_order): got = [r["librechat"] for r in by[name]] valid = sum(not g["invalid_citations"] for g in got) unknown = sorted({n for g in got for n in g.get("unknown_names") or []}) @@ -1137,6 +1167,12 @@ def use_case_report(cases: list[dict[str, Any]]) -> list[str]: return lines +def use_case_order(name: str) -> tuple[int, str]: + """`U2` before `U10`: by the use case's number, an unlabeled case last.""" + number = name.split()[0][1:] + return (int(number) if name[:1] == "U" and number.isdigit() else 1_000_000, name) + + def document_report(cases: list[dict[str, Any]]) -> list[str]: """The document cases on their own: recall of the labeled section among the direct path's hits, citation validity, the labeled section cited, and abstention.""" diff --git a/tests/unit/test_librechat_integration.py b/tests/unit/test_librechat_integration.py index e1890ef820..e033721d56 100644 --- a/tests/unit/test_librechat_integration.py +++ b/tests/unit/test_librechat_integration.py @@ -754,3 +754,173 @@ def fake_call(base, token, op, body): # Every document is written before any revision of one. first = {b["source_uri"]: i for i, b in reversed(list(enumerate(docs)))} assert docs.index(next(b for b in docs if b["content"] == writes[-1])) > max(first.values()) + + +_HELP_PAGE = """# Cost and usage + +## Daily spend caps + +Text. + +## Limits + +### Daily spend caps + +More. + +## Webhooks + +### Retries +""" + + +@pytest.mark.parametrize( + "breadcrumb", + [ + "Cost and usage > Webhooks > Retries", # exact + "Webhooks > Retries", # without the page title + "Retries", # a tail one section has + "Daily spend caps", # a tail two sections have + "Limits > Daily spend caps", + "webhooks > retries", # the server compares case + "Web hooks > Retries", + " Webhooks >Retries ", # and trims each heading + "Cost and usage", + ], +) +def test_help_section_rule_is_the_servers(breadcrumb): + from server.help.domain.index import build, find_section, page_sections, section_path + + q = _qualify() + index = build([("features/cost.md", _HELP_PAGE)]) + sections = [s.breadcrumb for s in page_sections(index, "features/cost.md")] + server = find_section(index, "features/cost.md", section_path(breadcrumb)) is not None + assert q.names_section(q.help_breadcrumb(breadcrumb), sections) is server + + +def test_check_help_citations_reads_the_page_and_its_sections(monkeypatch): + q = _qualify() + + def fake_read(st, token, op, body): + assert op == "help.get" and token == "viewer-token" + if body["path"] != "features/cost.md": + return {"found": False} + return {"found": True, "sections": [{"section": "Cost and usage > Daily spend caps"}]} + + monkeypatch.setattr(q, "scorer_read", fake_read) + st = {"tokens": {"scorer:acme-handbook": "viewer-token"}} + person = {"namespace": "acme-handbook"} + case = {"cite_help": ["features/cost.md"]} + text = ( + "[help:docs/features/cost.md § Daily spend caps] " + "[help:features/cost.md § daily spend caps] " + "[help:features/other.md]" + ) + cited, invalid, expected = q.check_help_citations(st, person, case, text) + assert cited == [ + "help:docs/features/cost.md § Daily spend caps", + "help:features/cost.md § daily spend caps", + "help:features/other.md", + ] + assert invalid == [ + "help:features/cost.md § daily spend caps: no such section", + "help:features/other.md: no such page", + ] + assert expected is True + + +def test_memory_citations_skip_help_pages_and_quoted_examples(monkeypatch): + q = _qualify() + asked = [] + + def fake_call(base, token, op, body): + asked.append(body["memory_key"]) + return 200, {"found": True, "version": 1793745407448901606}, 0.0 + + monkeypatch.setattr(q, "loom_call", fake_call) + st = {"loom_url": "http://loom", "tokens": {"scorer:acme-handbook": "viewer-token"}} + person = {"org": "acme", "namespace": "acme-handbook"} + text = ( + "Keys look like `scope/kind/id` [help:features/memory/writing.md § Keys]. " + "The freeze: [memory:policy/deploy/freeze@v1793745407448901606]." + ) + # A help page's path is no key; on the direct path a quoted example still reads as one. + assert q.check_citations(st, person, text)[0] == ["scope/kind/id", "policy/deploy/freeze"] + # Through the bridge only a `[memory:]` citation is a memory citation. + asked.clear() + assert q.check_citations({**st, "bridge": True}, person, text) == ( + ["policy/deploy/freeze"], + [], + ) + assert asked == ["policy/deploy/freeze"] + + +def test_a_help_abstention_and_an_unknown_name_are_scored(): + q = _qualify() + case = {"kind": "help_abstain", "expect": [], "baseline": {"op": "help.search"}} + said = {"answer": "Loom's documentation doesn't cover a colour theme.", "error": ""} + assert q.score_answer(case, said) == {"correct": True, "abstained": True} + guessed = {"answer": "Set LOOM_DASHBOARD_THEME=dark.", "error": ""} + assert q.score_answer(case, guessed)["correct"] is False + # A right answer that names an op the build neither serves nor documents is wrong. + case = {"kind": "fact", "expect": [r"revoke-token"], "baseline": {"op": "help.search"}} + answer = {"answer": "Run `loom revoke-token`.", "error": ""} + assert q.score_answer(case, answer)["correct"] is True + assert q.score_answer(case, {**answer, "unknown_names": ["token.revoke_all"]}) == { + "correct": False, + "abstained": False, + } + + +def test_the_direct_path_does_not_score_a_question_the_docs_leave_open(): + q = _qualify() + case = {"kind": "help_abstain", "cite_help": [], "baseline": {"op": "help.search"}} + hit = {"hits": [{"path": "features/dashboard.md"}]} + assert q.native_score(case, 200, hit)["correct"] is None + case = {"kind": "fact", "cite_help": ["features/dashboard.md"], "baseline": case["baseline"]} + assert q.native_score(case, 200, hit)["correct"] is True + + +def test_report_counts_a_help_abstention_and_orders_the_use_cases(): + q = _qualify() + + def side(correct, abstained=False): + return { + "correct": correct, + "abstained": abstained, + "cited": [], + "invalid_citations": [], + "cited_expected": None, + "tool_calls": 1, + "latency_s": 1.0, + "ttft_s": 0.5, + "prompt_tokens": 0, + "completion_tokens": 0, + } + + rows = [ + { + "id": f"case-{n}", + "kind": "fact", + "use_case": f"U{n} Case {n}", + "librechat": side(True), + "native": side(True), + } + for n in (10, 2, 1) + ] + rows.append( + { + "id": "help-undocumented", + "kind": "help_abstain", + "use_case": "U28 Refusals and abstentions", + "librechat": side(True, abstained=True), + "native": side(None), + } + ) + text = q.report(rows, "m") + assert "librechat: correct 4/4;" in text + assert "abstained 1/1 where it should, 0 false abstentions" in text + # The direct path does not score that case. + assert "native: correct 3/3;" in text and "abstained 0/0 where it should" in text + order = [line.split(" | ")[0][2:] for line in text.splitlines() if line.startswith("| U")] + assert order == ["U1 Case 1", "U2 Case 2", "U10 Case 10", "U28 Refusals and abstentions"] From dc5f6fb3532a18043fe8cfe8ca7731d040b16e67 Mon Sep 17 00:00:00 2001 From: zlareb1 Date: Wed, 11 Nov 2026 00:13:32 +0000 Subject: [PATCH 03/41] The connected-agents case checks the agent count, and a help answer's abstention is read with the documentation patterns namespace.inventory always returns four populations, so the direct path now reads the agents' total. Every help case reads abstention with the documentation phrases. The tracker case no longer accepts a bare 'live'. The guide's column says what it counts (no invalid citation) and names the 14 re-probed cases. Co-Authored-By: Claude Opus 5.5 Signed-off-by: zlareb1 --- docs/features/integrations/librechat.md | 69 ++++++++++--------- .../librechat/qualification/cases.json | 7 +- .../librechat/qualification/qualify.py | 15 ++-- tests/unit/test_librechat_integration.py | 25 +++++++ 4 files changed, 72 insertions(+), 44 deletions(-) diff --git a/docs/features/integrations/librechat.md b/docs/features/integrations/librechat.md index 96df31d1dc..2d0598e968 100644 --- a/docs/features/integrations/librechat.md +++ b/docs/features/integrations/librechat.md @@ -230,43 +230,46 @@ the bridge's own citation check. assistant: an agent with no help tools. It answered 10 of 26 by its own knowledge and cited none. **After** is the current agent definition. -| Use case | Cases | Before: answered with a citation | After: correct | After: citations valid | -| --------------------------------- | ----- | -------------------------------- | -------------- | ---------------------- | -| U1 Look up a stored fact | 7 | 0 of 1 | 7 of 7 | 7 of 7 | -| U2 What a document says | 10 | 0 of 1 | 9 of 10 | 9 of 10 | -| U3 What the namespace holds | 3 | - | 3 of 3 | 3 of 3 | -| U4 Usage counts and trends | 3 | - | 3 of 3 | 3 of 3 | -| U5 Cost and spend | 1 | 0 of 1 | 1 of 1 | 1 of 1 | -| U6 Write memory better | 4 | 0 of 1 | 4 of 4 | 2 of 4 | -| U7 History of a fact | 2 | 0 of 1 | 2 of 2 | 2 of 2 | -| U8 Entity graph | 1 | 0 of 1 | 1 of 1 | 1 of 1 | -| U9 Code index | 1 | 0 of 1 | 1 of 1 | 1 of 1 | -| U10 Conflicts and refusal | 1 | 0 of 1 | 1 of 1 | 1 of 1 | -| U11 Sharing and collections | 1 | 0 of 1 | 1 of 1 | 1 of 1 | -| U12 My role and who can change it | 1 | 0 of 1 | 1 of 1 | 1 of 1 | -| U13 Connect a coding agent | 1 | 0 of 1 | 1 of 1 | 1 of 1 | -| U14 Tokens | 1 | 0 of 1 | 1 of 1 | 1 of 1 | -| U15 Models and keys | 1 | 0 of 1 | 1 of 1 | 0 of 1 | -| U16 Health problems | 1 | 0 of 1 | 1 of 1 | 1 of 1 | -| U17 Why search returned this | 1 | 0 of 1 | 1 of 1 | 1 of 1 | -| U18 Runs | 1 | 0 of 1 | 1 of 1 | 1 of 1 | -| U19 Tasks between agents | 1 | 0 of 1 | 1 of 1 | 1 of 1 | -| U20 Tracker | 1 | 0 of 1 | 1 of 1 | 1 of 1 | -| U21 Retention and erasure | 1 | 0 of 1 | 1 of 1 | 1 of 1 | -| U22 Extraction from transcripts | 1 | 0 of 1 | 1 of 1 | 1 of 1 | -| U23 Working memory | 1 | 0 of 1 | 1 of 1 | 1 of 1 | -| U24 Integrations | 2 | 0 of 1 | 2 of 2 | 2 of 2 | -| U25 What a setting does | 1 | 0 of 1 | 1 of 1 | 1 of 1 | -| U26 Getting started | 1 | 0 of 1 | 1 of 1 | 1 of 1 | -| U27 Operating a deployment | 1 | 0 of 1 | 1 of 1 | 1 of 1 | -| U28 Refusals and abstentions | 5 | 0 of 1 | 5 of 5 | 5 of 5 | -| All | 56 | 0 of 26 | 55 of 56 | 52 of 56 | +| Use case | Cases | Before: answered with a citation | After: correct | After: no invalid citation | +| --------------------------------- | ----- | -------------------------------- | -------------- | -------------------------- | +| U1 Look up a stored fact | 7 | 0 of 1 | 7 of 7 | 7 of 7 | +| U2 What a document says | 10 | 0 of 1 | 9 of 10 | 9 of 10 | +| U3 What the namespace holds | 3 | - | 3 of 3 | 3 of 3 | +| U4 Usage counts and trends | 3 | - | 3 of 3 | 3 of 3 | +| U5 Cost and spend | 1 | 0 of 1 | 1 of 1 | 1 of 1 | +| U6 Write memory better | 4 | 0 of 1 | 4 of 4 | 2 of 4 | +| U7 History of a fact | 2 | 0 of 1 | 2 of 2 | 2 of 2 | +| U8 Entity graph | 1 | 0 of 1 | 1 of 1 | 1 of 1 | +| U9 Code index | 1 | 0 of 1 | 1 of 1 | 1 of 1 | +| U10 Conflicts and refusal | 1 | 0 of 1 | 1 of 1 | 1 of 1 | +| U11 Sharing and collections | 1 | 0 of 1 | 1 of 1 | 1 of 1 | +| U12 My role and who can change it | 1 | 0 of 1 | 1 of 1 | 1 of 1 | +| U13 Connect a coding agent | 1 | 0 of 1 | 1 of 1 | 1 of 1 | +| U14 Tokens | 1 | 0 of 1 | 1 of 1 | 1 of 1 | +| U15 Models and keys | 1 | 0 of 1 | 1 of 1 | 0 of 1 | +| U16 Health problems | 1 | 0 of 1 | 1 of 1 | 1 of 1 | +| U17 Why search returned this | 1 | 0 of 1 | 1 of 1 | 1 of 1 | +| U18 Runs | 1 | 0 of 1 | 1 of 1 | 1 of 1 | +| U19 Tasks between agents | 1 | 0 of 1 | 1 of 1 | 1 of 1 | +| U20 Tracker | 1 | 0 of 1 | 1 of 1 | 1 of 1 | +| U21 Retention and erasure | 1 | 0 of 1 | 1 of 1 | 1 of 1 | +| U22 Extraction from transcripts | 1 | 0 of 1 | 1 of 1 | 1 of 1 | +| U23 Working memory | 1 | 0 of 1 | 1 of 1 | 1 of 1 | +| U24 Integrations | 2 | 0 of 1 | 2 of 2 | 2 of 2 | +| U25 What a setting does | 1 | 0 of 1 | 1 of 1 | 1 of 1 | +| U26 Getting started | 1 | 0 of 1 | 1 of 1 | 1 of 1 | +| U27 Operating a deployment | 1 | 0 of 1 | 1 of 1 | 1 of 1 | +| U28 Refusals and abstentions | 5 | 0 of 1 | 5 of 5 | 5 of 5 | +| All | 56 | 0 of 26 | 55 of 56 | 52 of 56 | Measured on v0.8.8 with `claude-haiku-4-5`, on a server running fake embeddings and a fake LLM for Loom's own model jobs. A full run of the 56 cases costs about $3 at list price counting every prompt token, a mean of $0.053 per answer. The after columns are from a -full run, with the 14 cases the last instruction change touches (the memory and document -cases and three others) from a run after that change. The misses: +full run, with the 14 cases the last instruction change touches (three memory cases, the +seven document cases, the two unanswerable document cases and two help cases) from a run +after that change. Twelve answers cite nothing: the refusals, the abstentions and the +counts, which come from tallies with no row to cite; every other answer cites one. The +misses: - `doc-cache-entries` answers a question the namespace's documents leave open from Loom's own settings instead of abstaining: the question and a Loom setting share their words. diff --git a/integrations/librechat/qualification/cases.json b/integrations/librechat/qualification/cases.json index 940d38a18f..d8a23f39bd 100644 --- a/integrations/librechat/qualification/cases.json +++ b/integrations/librechat/qualification/cases.json @@ -751,7 +751,7 @@ "use_case": "U20 Tracker", "person": "alice", "question": "Does Loom copy our issue tracker's data into its own database?", - "expect": ["(never copies|reads it live|live|does not copy|doesn't copy)"], + "expect": ["(never copies|reads it live|does not copy|doesn't copy)"], "cite_help": ["features/tracker/overview.md"], "baseline": { "op": "help.search", @@ -900,9 +900,8 @@ "baseline": { "op": "namespace.inventory", "args": {}, - "path": ["populations"], - "count": true, - "equals": 4 + "path": ["populations", 1, "total"], + "equals": 2 } }, { diff --git a/integrations/librechat/qualification/qualify.py b/integrations/librechat/qualification/qualify.py index f99941db2b..5c8801a4b7 100644 --- a/integrations/librechat/qualification/qualify.py +++ b/integrations/librechat/qualification/qualify.py @@ -725,13 +725,14 @@ def check_doc_citations( def score(case: dict[str, Any], text: str) -> dict[str, Any]: """Score a written answer: the labeled values present, no forbidden text.""" kind = case["kind"] - abstained = matches(ABSTAIN_PATTERNS, text) or ( - is_document_case(case) and matches(DOC_ABSTAIN_PATTERNS, text) - ) - if kind == "abstain": - correct = abstained - elif kind == "help_abstain": + if is_help_case(case): + # A question about Loom: an abstention says the documentation does not cover it. abstained = matches(HELP_ABSTAIN_PATTERNS, text) + else: + abstained = matches(ABSTAIN_PATTERNS, text) or ( + is_document_case(case) and matches(DOC_ABSTAIN_PATTERNS, text) + ) + if kind in ABSTAIN_KINDS: correct = abstained elif kind == "refusal": correct = matches(REFUSAL_PATTERNS, text) @@ -1153,7 +1154,7 @@ def use_case_report(cases: list[dict[str, Any]]) -> list[str]: for r in cases: by.setdefault(r.get("use_case") or "-", []).append(r) lines = [ - "\n| use case | correct | citations valid | unknown names |", + "\n| use case | correct | no invalid citation | unknown names |", "| --- | --- | --- | --- |", ] for name in sorted(by, key=use_case_order): diff --git a/tests/unit/test_librechat_integration.py b/tests/unit/test_librechat_integration.py index e033721d56..d2b75c7bf5 100644 --- a/tests/unit/test_librechat_integration.py +++ b/tests/unit/test_librechat_integration.py @@ -924,3 +924,28 @@ def side(correct, abstained=False): assert "native: correct 3/3;" in text and "abstained 0/0 where it should" in text order = [line.split(" | ")[0][2:] for line in text.splitlines() if line.startswith("| U")] assert order == ["U1 Case 1", "U2 Case 2", "U10 Case 10", "U28 Refusals and abstentions"] + + +def test_a_help_answer_is_read_for_an_abstention_from_the_docs(): + q = _qualify() + case = {"kind": "help", "expect": [r"revoke-token"], "baseline": {"op": "help.search"}} + left_open = "Loom's documentation doesn't cover revoking every token at once." + assert q.score(case, left_open)["abstained"] is True + # A how-to answer that quotes an error is no abstention. + quoted = "`loom revoke-token` answers `not found` for a token it doesn't have." + assert q.score(case, quoted) == {"correct": True, "abstained": False} + + +def test_the_connected_agents_direct_path_counts_the_agents(): + q = _qualify() + case = _case("data-connected-agents") + + def inventory(agents): + return { + "populations": [{"population": p, "total": 0} for p in ("members",)] + + [{"population": "agents", "total": agents}] + + [{"population": p, "total": 0} for p in ("authors", "subjects")] + } + + assert q.native_score(case, 200, inventory(2))["correct"] is True + assert q.native_score(case, 200, inventory(1))["correct"] is False From d7c2ee72262d32649ff3b5945f36e25705903196 Mon Sep 17 00:00:00 2001 From: zlareb1 Date: Wed, 11 Nov 2026 00:22:39 +0000 Subject: [PATCH 04/41] Rescore keeps the unknown-name rule, and the help labels need what the docs say rescore scores with score_answer and takes the cases' current use-case labels. A history read that is rate-limited waits instead of marking a citation invalid. The setting and quickstart labels need the page's own words; a question the docs leave open forbids telling the person to set a setting, not naming one to deny it. The history case's direct path reads the key's versions. Rescored, the before run answers 9 of 26 help questions, not 10. Co-Authored-By: Claude Opus 5.5 Signed-off-by: zlareb1 --- docs/features/integrations/librechat.md | 4 +- docs/features/memory/retention-and-erasure.md | 4 +- .../librechat/qualification/cases.json | 20 ++-- .../librechat/qualification/qualify.py | 15 +-- tests/unit/test_librechat_integration.py | 92 +++++++++++++++++++ 5 files changed, 117 insertions(+), 18 deletions(-) diff --git a/docs/features/integrations/librechat.md b/docs/features/integrations/librechat.md index 2d0598e968..8289f0698a 100644 --- a/docs/features/integrations/librechat.md +++ b/docs/features/integrations/librechat.md @@ -227,7 +227,7 @@ server's own check uses. The cases go through Loom's assistant route the bridge's own citation check. **Before** is the same help questions on the build before the documentation reached the -assistant: an agent with no help tools. It answered 10 of 26 by its own knowledge and +assistant: an agent with no help tools. It answered 9 of 26 by its own knowledge and cited none. **After** is the current agent definition. | Use case | Cases | Before: answered with a citation | After: correct | After: no invalid citation | @@ -267,7 +267,7 @@ LLM for Loom's own model jobs. A full run of the 56 cases costs about $3 at list counting every prompt token, a mean of $0.053 per answer. The after columns are from a full run, with the 14 cases the last instruction change touches (three memory cases, the seven document cases, the two unanswerable document cases and two help cases) from a run -after that change. Twelve answers cite nothing: the refusals, the abstentions and the +after that change. Twelve answers cite nothing: two refusals, three abstentions and seven counts, which come from tallies with no row to cite; every other answer cites one. The misses: diff --git a/docs/features/memory/retention-and-erasure.md b/docs/features/memory/retention-and-erasure.md index eb616405d5..6ceb720a46 100644 --- a/docs/features/memory/retention-and-erasure.md +++ b/docs/features/memory/retention-and-erasure.md @@ -104,8 +104,8 @@ wins. `erasure.request` erases one scope everywhere Loom keeps it, and returns once it can show nothing in scope is left. To erase everything one user id holds across the org, an org -admin requests the `user_id` scope; `memory.clear` is not erasure: it tombstones one -agent's or user's memories in one namespace, and the rows stay in history. +admin requests the `user_id` scope; `memory.clear` only tombstones +([delete is not erase](#delete-is-not-erase)). | `scope_type` | `scope_value` | Who may request it | | ---------------- | --------------------------------------------------------------------------- | -------------------------------------------- | diff --git a/integrations/librechat/qualification/cases.json b/integrations/librechat/qualification/cases.json index d8a23f39bd..4e41e0d444 100644 --- a/integrations/librechat/qualification/cases.json +++ b/integrations/librechat/qualification/cases.json @@ -831,7 +831,7 @@ "use_case": "U25 What a setting does", "person": "alice", "question": "What does LOOM_ASSISTANT_MODEL set?", - "expect": ["(assistant|agent)", "model"], + "expect": ["agent definition", "\\bboot"], "cite_help": ["reference/configuration.md", "architecture/assistant.md"], "baseline": { "op": "help.search", @@ -847,7 +847,7 @@ "use_case": "U26 Getting started", "person": "alice", "question": "Does Loom's quickstart need an API key?", - "expect": ["\\bno\\b"], + "expect": ["no API key|needs? no (API )?key|(does ?n[o']t|do not) need an? (API )?key"], "cite_help": ["getting-started/quickstart.md"], "baseline": { "op": "help.search", @@ -855,7 +855,8 @@ "query": "Does Loom's quickstart need an API key?", "limit": 5 } - } + }, + "forbid": ["\\byou (do |will )?need an? (\\w+ )?(API )?key"] }, { "id": "help-upgrade", @@ -888,7 +889,7 @@ "limit": 5 } }, - "forbid": ["LOOM_[A-Z_]*THEME"] + "forbid": ["\\b(set|use|change)\\s+`?LOOM_[A-Z_]*THEME", "LOOM_[A-Z_]*THEME`?\\s*="] }, { "id": "data-connected-agents", @@ -913,11 +914,14 @@ "expect": ["300", "600"], "cite": "policy/api/rate-limit", "baseline": { - "op": "memory.search", + "op": "memory.history", "args": { - "query": "default public API rate limit", - "top_k": 1 - } + "memory_key": "policy/api/rate-limit", + "agent": "handbook-bot" + }, + "path": ["rows"], + "count": true, + "equals": 2 } } ] diff --git a/integrations/librechat/qualification/qualify.py b/integrations/librechat/qualification/qualify.py index 5c8801a4b7..47056b3d9f 100644 --- a/integrations/librechat/qualification/qualify.py +++ b/integrations/librechat/qualification/qualify.py @@ -504,8 +504,7 @@ def history(key: str) -> set[int]: "memory_key": key, "agent": writers.get(key, "-"), } - code, out, _ = loom_call(st["loom_url"], scorer, "memory.history", body) - rows = (out.get("rows") or []) if code == 200 else [] + rows = scorer_read(st, scorer, "memory.history", body).get("rows") or [] versions[key] = {int(r["version"]) for r in rows if r.get("version")} return versions[key] @@ -744,9 +743,12 @@ def score(case: dict[str, Any], text: str) -> dict[str, Any]: def score_answer(case: dict[str, Any], got: dict[str, Any]) -> dict[str, Any]: """Score an answer through LibreChat: its text, and wrong when it names an op or setting - the build neither serves nor documents (the bridge's `unknown_names`).""" + the build neither serves nor documents (the bridge's `unknown_names`). A question the + docs leave open is the exception: its answer may name a setting to say there is none, + and its case forbids an answer that tells the person to set one.""" result = score(case, got["answer"] or got["error"]) - result["correct"] = result["correct"] and not got.get("unknown_names") + if case["kind"] != "help_abstain": + result["correct"] = result["correct"] and not got.get("unknown_names") return result @@ -975,7 +977,8 @@ def cmd_rescore(args: argparse.Namespace) -> None: lc = row["librechat"] case = cases[row["id"]] text = lc["answer"] or lc["error"] - lc.update(score(case, text)) + row["use_case"] = case.get("use_case", "") + lc.update(score_answer(case, lc)) if args.citations: lc.update(answer_citations(st, case, people[case["person"]], text)) Path(args.out).write_text(json.dumps(saved, indent=2)) @@ -1116,7 +1119,7 @@ def report(rows: list[dict[str, Any]], model: str) -> str: lines.append( f"\n{side}: correct {sum(g['correct'] for g in scored)}/{len(scored)}; " f"citations {validity}, " - f"expected key cited {sum(expected)}/{len(expected)}; " + f"expected source cited {sum(expected)}/{len(expected)}; " f"abstained {sum(r[side]['correct'] for r in abst)}/{len(abst)} where it should, " f"{len(false_abst)} false abstentions; " f"latency p50 {pct(lat, 0.5):.2f}s p95 {pct(lat, 0.95):.2f}s; " diff --git a/tests/unit/test_librechat_integration.py b/tests/unit/test_librechat_integration.py index d2b75c7bf5..20d821d9b5 100644 --- a/tests/unit/test_librechat_integration.py +++ b/tests/unit/test_librechat_integration.py @@ -949,3 +949,95 @@ def inventory(agents): assert q.native_score(case, 200, inventory(2))["correct"] is True assert q.native_score(case, 200, inventory(1))["correct"] is False + + +def _saved_side(answer, **extra): + return { + "answer": answer, + "error": "", + "correct": True, + "abstained": False, + "cited": [], + "invalid_citations": [], + "cited_expected": None, + "tool_calls": 1, + "latency_s": 1.0, + "ttft_s": 0.5, + "prompt_tokens": 0, + "completion_tokens": 0, + **extra, + } + + +def test_rescore_keeps_the_unknown_name_rule_and_takes_the_current_labels(tmp_path): + import argparse + + q = _qualify() + answer = "Run `loom revoke-token `; `token.revoke_all` revokes them all." + side = _saved_side(answer, unknown_names=["token.revoke_all"]) + row = {"id": "help-revoke-token", "kind": "help", "use_case": "-"} + out = tmp_path / "results.json" + out.write_text(json.dumps({"model": "m", "rows": [{**row, "librechat": side, "native": side}]})) + q.cmd_rescore(argparse.Namespace(out=str(out), citations=False)) + got = json.loads(out.read_text())["rows"][0] + assert got["librechat"]["correct"] is False + assert got["use_case"] == _case("help-revoke-token")["use_case"] + + +def test_a_help_answer_that_cites_no_page_misses_the_labeled_one(monkeypatch): + q = _qualify() + monkeypatch.setattr(q, "check_citations", lambda st, person, text: ([], [])) + case = _case("help-revoke-token") + person = {"namespace": "acme-handbook"} + got = q.answer_citations({}, case, person, "Run `loom revoke-token`.") + assert got == {"cited": [], "invalid_citations": [], "cited_expected": False} + # A memory key cited beside the page does not decide it: the labeled page does. + monkeypatch.setattr(q, "check_citations", lambda st, person, text: (["a/b/c"], [])) + monkeypatch.setattr( + q, "check_help_citations", lambda st, person, case, text: (["help:x.md"], [], False) + ) + got = q.answer_citations({}, {**case, "cite": "a/b/c"}, person, "[help:x.md]") + assert got["cited_expected"] is False + + +@pytest.mark.parametrize( + "answer, correct", + [ + ("Loom's documentation does not describe a dashboard colour theme.", True), + # Naming a setting to say there is none is still an abstention. + ("There is no `LOOM_THEME` setting; the docs don't cover a colour theme.", True), + ("The docs don't cover it, but set `LOOM_DASHBOARD_THEME=dark`.", False), + ("Use LOOM_UI_THEME to change it.", False), + ], +) +def test_a_question_the_docs_leave_open(answer, correct): + q = _qualify() + got = q.score_answer(_case("help-undocumented"), _saved_side(answer, unknown_names=["X"])) + assert got["correct"] is correct + + +@pytest.mark.parametrize( + "case_id, answer, correct", + [ + ( + "help-setting", + "The agent's model: Loom writes it into the agent definition at boot.", + True, + ), + ("help-setting", "I could not find what LOOM_ASSISTANT_MODEL sets.", False), + ("help-quickstart", "No: the quickstart needs no API key and no account.", True), + ("help-quickstart", "Yes, you need an API key; no account is needed.", False), + ], +) +def test_help_labels_need_what_the_page_says(case_id, answer, correct): + q = _qualify() + assert q.score(_case(case_id), answer)["correct"] is correct + + +def test_the_history_direct_path_counts_the_keys_versions(): + q = _qualify() + case = _case("data-history") + assert case["baseline"]["op"] == "memory.history" + two = {"rows": [{"version": 2}, {"version": 1}]} + assert q.native_score(case, 200, two)["correct"] is True + assert q.native_score(case, 200, {"rows": [{"version": 1}]})["correct"] is False From 4267f0c6aee2dc7f889fe74b2bc1675319af87bb Mon Sep 17 00:00:00 2001 From: zlareb1 Date: Wed, 11 Nov 2026 00:32:47 +0000 Subject: [PATCH 05/41] Every help label is held to right and wrong sample answers, and a help citation in a document answer is checked only as help Each help case carries samples; a test scores each label against them, and the labels that passed a wrong answer or restated the question now need what the page states. The document citation parse no longer reads [help:] citations as documents. The guide's figures follow: before 8 of 26, after 53 of 56 with no invalid citation, and the doc-cache-entries miss is described as it happened. Co-Authored-By: Claude Opus 5.5 Signed-off-by: zlareb1 --- docs/features/integrations/librechat.md | 38 ++-- .../librechat/qualification/cases.json | 174 ++++++++++++++++-- .../librechat/qualification/qualify.py | 6 +- tests/unit/test_librechat_integration.py | 56 ++++-- 4 files changed, 221 insertions(+), 53 deletions(-) diff --git a/docs/features/integrations/librechat.md b/docs/features/integrations/librechat.md index 8289f0698a..c08ad69967 100644 --- a/docs/features/integrations/librechat.md +++ b/docs/features/integrations/librechat.md @@ -217,23 +217,25 @@ only on the two unanswerable questions. The case set holds at least one question per use case of Loom: what a namespace holds and how it is used (the data tools), and how Loom works and how to do something in it (the help tools, which read the documentation the server ships). Each help case labels the -values its answer must state and the pages that hold them. Its answer is scored correct -when it states them, names no op or setting the server neither serves nor documents -(`unknown_names` on the answer's `loom.citations` event), and, for a case with no answer -in the docs, says so. A help citation is valid when its page is in the server's +values its answer must state and the pages that hold them, with a right and a wrong sample +answer the label is tested against. Its answer is scored correct when it states them and +names no op or setting the server neither serves nor documents (`unknown_names` on the +answer's `loom.citations` event). For the case with no answer in the docs, the answer is +correct when it says so and tells the person to set no setting; it may name one to deny +it. A help citation is valid when its page is in the server's documentation (`help.get`) and its section is one of the page's own, by the rule the server's own check uses. The cases go through Loom's assistant route (`qualify.py setup-bridge`), so each answer also carries the question's asker line and the bridge's own citation check. **Before** is the same help questions on the build before the documentation reached the -assistant: an agent with no help tools. It answered 9 of 26 by its own knowledge and +assistant: an agent with no help tools. It answered 8 of 26 by its own knowledge and cited none. **After** is the current agent definition. | Use case | Cases | Before: answered with a citation | After: correct | After: no invalid citation | | --------------------------------- | ----- | -------------------------------- | -------------- | -------------------------- | | U1 Look up a stored fact | 7 | 0 of 1 | 7 of 7 | 7 of 7 | -| U2 What a document says | 10 | 0 of 1 | 9 of 10 | 9 of 10 | +| U2 What a document says | 10 | 0 of 1 | 9 of 10 | 10 of 10 | | U3 What the namespace holds | 3 | - | 3 of 3 | 3 of 3 | | U4 Usage counts and trends | 3 | - | 3 of 3 | 3 of 3 | | U5 Cost and spend | 1 | 0 of 1 | 1 of 1 | 1 of 1 | @@ -260,27 +262,29 @@ cited none. **After** is the current agent definition. | U26 Getting started | 1 | 0 of 1 | 1 of 1 | 1 of 1 | | U27 Operating a deployment | 1 | 0 of 1 | 1 of 1 | 1 of 1 | | U28 Refusals and abstentions | 5 | 0 of 1 | 5 of 5 | 5 of 5 | -| All | 56 | 0 of 26 | 55 of 56 | 52 of 56 | +| All | 56 | 0 of 26 | 55 of 56 | 53 of 56 | Measured on v0.8.8 with `claude-haiku-4-5`, on a server running fake embeddings and a fake LLM for Loom's own model jobs. A full run of the 56 cases costs about $3 at list price -counting every prompt token, a mean of $0.053 per answer. The after columns are from a -full run, with the 14 cases the last instruction change touches (three memory cases, the -seven document cases, the two unanswerable document cases and two help cases) from a run -after that change. Twelve answers cite nothing: two refusals, three abstentions and seven +counting every prompt token, a mean of $0.053 per answer. The after columns take 14 cases +(three memory, nine document and two help cases) from a run on the agent definition in +`integrations/librechat/agent.yaml`, and the other 42 from a full run on a definition that +differs from it in the wording of the first step's searches and of one sentence on the +asker's role. Twelve answers cite nothing: two refusals, three abstentions and seven counts, which come from tallies with no row to cite; every other answer cites one. The misses: -- `doc-cache-entries` answers a question the namespace's documents leave open from Loom's - own settings instead of abstaining: the question and a Loom setting share their words. +- `doc-cache-entries` asks for a value one of the namespace's documents holds + (`config/cache.toml`); the answer searches Loom's own documentation instead and does not + find it: the question and Loom's settings share their words. - Two recommendation answers cite `mentor.guide`, Loom's writing guide, as a docs page, which the check marks unverified: the guide has no citation form. - One answer names a section the page does not have. -Answers vary from run to run at this model. Across the runs that led here, a question -about the person's own rate limit or webhook retries was answered from Loom's docs in some -runs and from the namespace in others; asking for the memory, document and help searches -together in the first step reduced it. +Answers vary from run to run at this model. A question about the person's own data that +shares words with Loom's docs (a rate limit, webhook retries) is sometimes answered from +the docs; the agent's instructions ask for the memory, document and help searches together +in its first step for that reason. ## The deployed assistant diff --git a/integrations/librechat/qualification/cases.json b/integrations/librechat/qualification/cases.json index 4e41e0d444..63a08b577c 100644 --- a/integrations/librechat/qualification/cases.json +++ b/integrations/librechat/qualification/cases.json @@ -470,7 +470,7 @@ "use_case": "U1 Look up a stored fact", "person": "alice", "question": "What is the difference between memory.search and memory.ask?", - "expect": ["memory\\.ask", "(answer|synthes)"], + "expect": ["memory\\.search`?[^.]{0,60}(rank|hits)", "memory\\.ask`?[^.]{0,80}(synthesi|answer)"], "cite_help": ["features/memory/search-and-ask.md", "features/unified-search.md"], "baseline": { "op": "help.search", @@ -478,6 +478,15 @@ "query": "What is the difference between memory.search and memory.ask?", "limit": 5 } + }, + "samples": { + "right": [ + "`memory.search` returns ranked hits for the agent to read; `memory.ask` runs the same retrieval and writes a synthesised, cited answer." + ], + "wrong": [ + "They are the same op and return the same answer.", + "`memory.ask` returns ranked hits; `memory.search` writes a synthesised answer." + ] } }, { @@ -494,6 +503,10 @@ "query": "How do I add a PDF file to Loom as a document?", "limit": 5 } + }, + "samples": { + "right": ["Upload it with `knowledge.upload`."], + "wrong": ["Save its text with `memory.set`."] } }, { @@ -502,7 +515,7 @@ "use_case": "U5 Cost and spend", "person": "alice", "question": "What is the default daily spend cap of a namespace, and what does Loom skip once it is spent?", - "expect": ["(\\$\\s?1(\\.0+)?\\b|\\b1(\\.0)? ?(USD|dollar)|\\b1\\.0\\b)", "(synthes|extract|skip)"], + "expect": ["(\\$\\s?1(\\.0+)?\\b|\\b1(\\.0)? ?(USD|dollar)|\\b1\\.0\\b)", "(synthes|extract)"], "cite_help": ["features/observability/cost-and-usage.md"], "baseline": { "op": "help.search", @@ -510,6 +523,13 @@ "query": "What is the default daily spend cap of a namespace, and what does Loom skip once it is spent?", "limit": 5 } + }, + "samples": { + "right": ["$1.0 a day; once it is spent Loom skips synthesis and entity extraction."], + "wrong": [ + "$1.0, and nothing is skipped: the cap only warns.", + "There is no default cap; extraction keeps running." + ] } }, { @@ -518,7 +538,7 @@ "use_case": "U6 Write memory better", "person": "alice", "question": "What shape should a memory key have?", - "expect": ["scope", "kind"], + "expect": ["?/?///`, readable, like `billing/decision/refund-window`."], + "wrong": ["Any string works; a UUID is best.", "Scope and kind are tags, not part of the key."] } }, { @@ -542,6 +566,10 @@ "query": "How do I see every earlier version of a memory?", "limit": 5 } + }, + "samples": { + "right": ["Call `memory.history` with the key."], + "wrong": ["Loom keeps only the latest version."] } }, { @@ -550,7 +578,7 @@ "use_case": "U8 Entity graph", "person": "alice", "question": "How do entities get into Loom's entity graph?", - "expect": ["entit", "(extract|memory\\.set)"], + "expect": ["memory\\.set|entities` (array|field|list)|`entities`", "extract"], "cite_help": ["features/entity-graph.md"], "baseline": { "op": "help.search", @@ -558,6 +586,13 @@ "query": "How do entities get into Loom's entity graph?", "limit": 5 } + }, + "forbid": ["\\b(are|is) not extracted", "by hand only"], + "samples": { + "right": [ + "Pass them in `entities` on `memory.set`; otherwise the extractor worker extracts them from the memory's text." + ], + "wrong": ["Entities are not extracted from memories; an admin adds them by hand only."] } }, { @@ -566,7 +601,7 @@ "use_case": "U9 Code index", "person": "alice", "question": "How do I add a repository to Loom's code index?", - "expect": ["add (a )?repositor"], + "expect": ["code\\.repo\\.add|Add repository"], "cite_help": ["features/code-index/repositories.md", "features/code-index/overview.md"], "baseline": { "op": "help.search", @@ -574,6 +609,10 @@ "query": "How do I add a repository to Loom's code index?", "limit": 5 } + }, + "samples": { + "right": ["Use **Repositories → Add repository** in the dashboard, or call `code.repo.add`."], + "wrong": ["You cannot add a repository; Loom indexes only its own code."] } }, { @@ -582,7 +621,7 @@ "use_case": "U10 Conflicts and refusal", "person": "alice", "question": "What happens when I write a memory that conflicts with one already stored?", - "expect": ["conflict", "(review|conflicts\\.resolve|resolve)"], + "expect": ["flag|status.{0,5}conflicted|both (stay|rows)", "Review|conflicts\\.resolve"], "cite_help": ["features/memory/conflicts-and-refusal.md", "concepts/memory.md"], "baseline": { "op": "help.search", @@ -590,6 +629,12 @@ "query": "What happens when I write a memory that conflicts with one already stored?", "limit": 5 } + }, + "samples": { + "right": [ + "The new row is stored and flagged as a conflict; the namespace owner decides in the Review queue or with `conflicts.resolve`." + ], + "wrong": ["The new write overwrites the old one.", "Loom refuses the write and asks you to resolve the conflict."] } }, { @@ -598,7 +643,7 @@ "use_case": "U11 Sharing and collections", "person": "alice", "question": "What is a collection in Loom, and how is one shared?", - "expect": ["col-", "grant"], + "expect": ["col-", "(through|by|via|with|creat\\w*|add\\w*) (a |its )?grants?|grants? on it"], "cite_help": [ "concepts/identities-and-namespaces.md", "architecture/sharing.md", @@ -610,6 +655,15 @@ "query": "What is a collection in Loom, and how is one shared?", "limit": 5 } + }, + "samples": { + "right": [ + "A collection is a `col-…` namespace that opens only through grants; you share it by creating grants on it." + ], + "wrong": [ + "A collection is a folder of documents; share it with a link.", + "A `col-` namespace is shared by putting it in the token's claims; no grant is needed." + ] } }, { @@ -631,7 +685,11 @@ "limit": 5 } }, - "forbid": ["\\byou (can|may) write\\b", "\\byou are (a |an )?(writer|admin)\\b"] + "forbid": ["\\byou (can|may) write\\b", "\\byou are (a |an )?(writer|admin)\\b"], + "samples": { + "right": ["You are a viewer here, so you cannot write; an admin can grant you writer."], + "wrong": ["Yes, you can write here.", "You are an admin, so you can write."] + } }, { "id": "help-claude-code", @@ -647,6 +705,10 @@ "query": "How do I connect Claude Code to Loom?", "limit": 5 } + }, + "samples": { + "right": ["Run `claude plugin marketplace add ClickHouse/loom`, then install the plugin."], + "wrong": ["Install a Loom editor extension and paste your token."] } }, { @@ -663,6 +725,10 @@ "query": "How do I revoke a Loom token?", "limit": 5 } + }, + "samples": { + "right": ["Run `loom revoke-token `."], + "wrong": ["Tokens cannot be revoked; wait for them to expire."] } }, { @@ -679,6 +745,12 @@ "query": "Where do I configure the LLM that Loom uses, and its API key?", "limit": 5 } + }, + "samples": { + "right": [ + "On the server: set `LOOM_LLM_PROVIDER` and `LOOM_LLM_MODEL`, and the provider's key, or use the dashboard's Models & keys page." + ], + "wrong": ["Each namespace picks its model in its profile."] } }, { @@ -687,7 +759,7 @@ "use_case": "U16 Health problems", "person": "alice", "question": "What does the health problem assistant_service_failing mean?", - "expect": ["LibreChat"], + "expect": ["LibreChat", "set ?up|setup|sign-?in|configur|retr"], "cite_help": ["features/integrations/librechat.md", "architecture/assistant.md"], "baseline": { "op": "help.search", @@ -695,6 +767,10 @@ "query": "What does the health problem assistant_service_failing mean?", "limit": 5 } + }, + "samples": { + "right": ["Loom's setup of the LibreChat assistant failed; it retries, and `/v1/health` names what to fix."], + "wrong": ["It means the LibreChat chat history is full."] } }, { @@ -703,7 +779,7 @@ "use_case": "U17 Why search returned this", "person": "alice", "question": "How can I see why a search ranked a memory where it did?", - "expect": ["(explain|score_components|search_trace|Recall)"], + "expect": ["explain\\s*=\\s*true|score_components|search_trace"], "cite_help": ["concepts/retrieval-and-ranking.md", "guides/debugging.md", "features/memory/search-and-ask.md"], "baseline": { "op": "help.search", @@ -711,6 +787,10 @@ "query": "How can I see why a search ranked a memory where it did?", "limit": 5 } + }, + "samples": { + "right": ["Search with `explain=true`: each hit carries its `score_components`."], + "wrong": ["Loom does not explain rankings.", "I can't explain why it ranked there; recall varies."] } }, { @@ -727,6 +807,10 @@ "query": "What is a run in Loom, and how does an agent start one?", "limit": 5 } + }, + "samples": { + "right": ["A run is one execution of a task; the agent starts it with `run.begin`."], + "wrong": ["A run is a CI job; agents cannot start one."] } }, { @@ -735,7 +819,7 @@ "use_case": "U19 Tasks between agents", "person": "alice", "question": "How does one agent hand work to another agent in Loom?", - "expect": ["(task|inbox)"], + "expect": ["task\\.create", "task\\.pull|inbox"], "cite_help": ["features/tasks-and-decisions.md"], "baseline": { "op": "help.search", @@ -743,6 +827,13 @@ "query": "How does one agent hand work to another agent in Loom?", "limit": 5 } + }, + "samples": { + "right": ["The sender calls `task.create` into the receiver's inbox; the receiver claims it with `task.pull`."], + "wrong": [ + "The agents share a memory key and poll it.", + "They hand work over through a shared task list in the dashboard." + ] } }, { @@ -759,6 +850,10 @@ "query": "Does Loom copy our issue tracker's data into its own database?", "limit": 5 } + }, + "samples": { + "right": ["No: Loom never copies it; it reads the tracker live."], + "wrong": ["Yes, it copies every issue into its database each night."] } }, { @@ -767,7 +862,7 @@ "use_case": "U21 Retention and erasure", "person": "alice", "question": "Who may erase every memory of one user id across the org?", - "expect": ["org admin"], + "expect": ["erasure\\.request", "org admin"], "cite_help": ["features/memory/retention-and-erasure.md"], "baseline": { "op": "help.search", @@ -775,6 +870,11 @@ "query": "Who may erase every memory of one user id across the org?", "limit": 5 } + }, + "forbid": ["run\\w* `?memory\\.clear", "`?memory\\.clear`? (erases|with `?agent)"], + "samples": { + "right": ["An org admin, with `erasure.request` and the `user_id` scope."], + "wrong": ["An org admin runs `memory.clear` with `agent=\"*\"`.", "Any writer may, with `memory.delete`."] } }, { @@ -791,6 +891,10 @@ "query": "How do I have Loom extract memories from a conversation transcript?", "limit": 5 } + }, + "samples": { + "right": ["Send the transcript to `memory.set_from_messages`."], + "wrong": ["Copy each fact out by hand and call `memory.set`."] } }, { @@ -799,7 +903,10 @@ "use_case": "U23 Working memory", "person": "alice", "question": "What is working memory in Loom, and does it expire?", - "expect": ["(no TTL|surviv|do(es)? not expire|never expire|n.t expire)"], + "expect": [ + "block|not (embedded|ranked|searched)|every (turn|time|call)", + "(no TTL|surviv|do(es)? not expire|never expire|n.t expire)" + ], "cite_help": ["features/memory/working-memory-and-profiles.md"], "baseline": { "op": "help.search", @@ -807,6 +914,15 @@ "query": "What is working memory in Loom, and does it expire?", "limit": 5 } + }, + "samples": { + "right": [ + "A small block given to the agent every time instead of searched; it has no TTL and survives restarts." + ], + "wrong": [ + "A cache of recent searches; it expires after a day.", + "A block given every time; it expires after 24 hours." + ] } }, { @@ -823,6 +939,10 @@ "query": "Which settings send Loom's traces to Langfuse?", "limit": 5 } + }, + "samples": { + "right": ["Set `LOOM_LANGFUSE_URL` and `LOOM_LANGFUSE_ADMIN_TOKEN`."], + "wrong": ["Set `LOOM_TRACE_URL`."] } }, { @@ -839,6 +959,10 @@ "query": "What does LOOM_ASSISTANT_MODEL set?", "limit": 5 } + }, + "samples": { + "right": ["The assistant agent's model; Loom writes it into the agent definition at boot."], + "wrong": ["I could not find what LOOM_ASSISTANT_MODEL sets."] } }, { @@ -856,7 +980,11 @@ "limit": 5 } }, - "forbid": ["\\byou (do |will )?need an? (\\w+ )?(API )?key"] + "forbid": ["\\byou (do |will )?need an? (\\w+ )?(API )?key"], + "samples": { + "right": ["No: the quickstart needs no API key and no account."], + "wrong": ["Yes, you need an API key; no account is needed."] + } }, { "id": "help-upgrade", @@ -864,7 +992,7 @@ "use_case": "U27 Operating a deployment", "person": "alice", "question": "How do I upgrade a Loom deployment to a new release?", - "expect": ["migrate"], + "expect": ["migrat", "boot|start"], "cite_help": ["operations/upgrades.md"], "baseline": { "op": "help.search", @@ -872,6 +1000,13 @@ "query": "How do I upgrade a Loom deployment to a new release?", "limit": 5 } + }, + "samples": { + "right": ["Deploy the new image; the first container to boot applies the migrations."], + "wrong": [ + "Export every memory, reinstall the new release and import them back.", + "Loom cannot be upgraded in place; migrate the data by hand." + ] } }, { @@ -889,7 +1024,14 @@ "limit": 5 } }, - "forbid": ["\\b(set|use|change)\\s+`?LOOM_[A-Z_]*THEME", "LOOM_[A-Z_]*THEME`?\\s*="] + "forbid": ["\\b(set|use|change)\\s+`?LOOM_[A-Z_]+", "LOOM_[A-Z_]+`?\\s*="], + "samples": { + "right": [ + "Loom's documentation does not describe a dashboard colour theme.", + "There is no `LOOM_THEME` setting; the docs don't cover a colour theme." + ], + "wrong": ["The docs don't cover it, but set `LOOM_DASHBOARD_COLOUR=dark`.", "Use LOOM_UI_THEME to change it."] + } }, { "id": "data-connected-agents", diff --git a/integrations/librechat/qualification/qualify.py b/integrations/librechat/qualification/qualify.py index 47056b3d9f..7f112b7af5 100644 --- a/integrations/librechat/qualification/qualify.py +++ b/integrations/librechat/qualification/qualify.py @@ -659,7 +659,7 @@ def scorer_read(st: dict[str, Any], token: str, op: str, body: dict[str, Any]) - break time.sleep(retry_after(out)) if code != 200: - sys.exit(f"scorer {op} {body.get('source_uri')}: {code} {out}") + sys.exit(f"scorer {op} {json.dumps(body)}: {code} {out}") return out @@ -927,7 +927,9 @@ def answer_citations( cited, invalid = check_citations(st, person, text) expected = case.get("cite") in cited if case.get("cite") else None if is_document_case(case): - doc_cited, doc_invalid, doc_expected = check_doc_citations(st, person, case, text) + # A help citation (`[help: § …]`) is checked as one below, not as a document. + doc_text = HELP_CITE_RE.sub("", text) + doc_cited, doc_invalid, doc_expected = check_doc_citations(st, person, case, doc_text) cited, invalid = cited + doc_cited, invalid + doc_invalid expected = doc_expected if case.get("cite_doc") else None if HELP_CITE_RE.search(text): diff --git a/tests/unit/test_librechat_integration.py b/tests/unit/test_librechat_integration.py index 20d821d9b5..eae128b5fc 100644 --- a/tests/unit/test_librechat_integration.py +++ b/tests/unit/test_librechat_integration.py @@ -1016,24 +1016,6 @@ def test_a_question_the_docs_leave_open(answer, correct): assert got["correct"] is correct -@pytest.mark.parametrize( - "case_id, answer, correct", - [ - ( - "help-setting", - "The agent's model: Loom writes it into the agent definition at boot.", - True, - ), - ("help-setting", "I could not find what LOOM_ASSISTANT_MODEL sets.", False), - ("help-quickstart", "No: the quickstart needs no API key and no account.", True), - ("help-quickstart", "Yes, you need an API key; no account is needed.", False), - ], -) -def test_help_labels_need_what_the_page_says(case_id, answer, correct): - q = _qualify() - assert q.score(_case(case_id), answer)["correct"] is correct - - def test_the_history_direct_path_counts_the_keys_versions(): q = _qualify() case = _case("data-history") @@ -1041,3 +1023,41 @@ def test_the_history_direct_path_counts_the_keys_versions(): two = {"rows": [{"version": 2}, {"version": 1}]} assert q.native_score(case, 200, two)["correct"] is True assert q.native_score(case, 200, {"rows": [{"version": 1}]})["correct"] is False + + +def _help_cases(): + return [ + c + for c in json.loads((QUAL / "cases.json").read_text()) + if c["baseline"]["op"] == "help.search" + ] + + +@pytest.mark.parametrize("case", _help_cases(), ids=lambda c: c["id"]) +def test_each_help_label_passes_its_right_samples_and_fails_its_wrong_ones(case): + q = _qualify() + samples = case["samples"] + assert samples["right"] and samples["wrong"] + for answer in samples["right"]: + assert q.score_answer(case, {"answer": answer, "error": ""})["correct"], answer + for answer in samples["wrong"]: + assert not q.score_answer(case, {"answer": answer, "error": ""})["correct"], answer + + +def test_a_document_answer_that_cites_a_help_page_checks_it_as_help(monkeypatch): + q = _qualify() + docs_read = [] + monkeypatch.setattr(q, "check_citations", lambda st, person, text: ([], [])) + + def fake_docs(st, person, case, text): + docs_read.append(text) + return [], [], False + + monkeypatch.setattr(q, "check_doc_citations", fake_docs) + monkeypatch.setattr( + q, "check_help_citations", lambda st, person, case, text: (["help:a.md"], [], False) + ) + case = _case("doc-cache-entries") + got = q.answer_citations({}, case, {"namespace": "acme-library"}, "See [help:a.md § A].") + assert docs_read == ["See ."] + assert got["cited"] == ["help:a.md"] and got["invalid_citations"] == [] From dfcf154d02728d6832106036f1426a0edb6db515 Mon Sep 17 00:00:00 2001 From: zlareb1 Date: Wed, 11 Nov 2026 00:40:40 +0000 Subject: [PATCH 06/41] The guide's table holds only what the current harness measures, and the cost-cap and no-docs labels catch near misses The before column describes a build the tree does not have, so it moves to the PR; the guide names the agent definitions the runs used. The cost cap needs 1.0, not 1.50; the no-docs case forbids any suggested setting. A help citation whose section is only separators cites the page, as the server reads it. Co-Authored-By: Claude Opus 5.5 Signed-off-by: zlareb1 --- docs/features/integrations/librechat.md | 102 +++++++++--------- .../librechat/qualification/cases.json | 14 ++- .../librechat/qualification/qualify.py | 8 +- tests/unit/test_librechat_integration.py | 4 +- 4 files changed, 67 insertions(+), 61 deletions(-) diff --git a/docs/features/integrations/librechat.md b/docs/features/integrations/librechat.md index c08ad69967..146b12332e 100644 --- a/docs/features/integrations/librechat.md +++ b/docs/features/integrations/librechat.md @@ -90,19 +90,19 @@ Loom's erasure saga does not reach LibreChat's database: erasing a user or a mem Loom leaves every copy LibreChat holds. LibreChat must not become a second store of memory, so this configuration keeps its memory feature off and its search index out. -| Data | Where (MongoDB collection or volume) | Holds tenant content | Retention in this configuration | How it is deleted | -| --------------------------------------- | ------------------------------------------------- | ------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | ----------------------------------------------------------------------------------------------------------------------------- | -| Conversations | `conversations` | titles (title generation is off) | `expiredAt` after `generalChatRetention` (720 h), TTL index | the person deletes the chat; account deletion; TTL | -| Messages, with every tool call's output | `messages` (`content[].tool_call.output`) | yes: the questions, the answers and the full Loom results each tool returned | `expiredAt` after 720 h, TTL index | as above | -| Tool call records | `toolcalls` | tool outputs | `expiredAt`, TTL index | account deletion; TTL | -| Token usage | `transactions` | no: token counts per message | kept | account deletion | -| Each person's Loom token | `pluginauths`, encrypted with `CREDS_KEY` | a credential | until the person removes it | removing it in MCP settings; account deletion; revoke it in Loom with `loom revoke-token` | -| Uploaded files | `files` and the `uploads` volume | yes, if people upload | `expiredAt` under `retentionMode: all`; a sweep deletes the stored file, then the record (`packages/data-schemas/src/schema/file.ts`, `packages/api/src/files/sweep.ts`) | the person deletes the file; account deletion; the sweep | -| Agents | `agents` | the agent's instructions, which may name an org and a namespace | until deleted | the person deletes the agent (`DELETE /api/agents/:id`); account deletion | -| Agents API keys | `agentapikeys`, stored as a hash | a bearer credential: it runs the person's agents, and so Loom reads under their stored Loom token | until deleted | the person deletes the key (`DELETE /api/api-keys/:id`); account deletion; turn `interface.remoteAgents` off to stop new keys | -| LibreChat memories | `memoryentries` | none: `memory.disabled: true`, writes refused | not written | - | -| Message search index | none: Meilisearch is not deployed, `SEARCH=false` | - | - | - | -| Server logs | the `logs` volume and container output | errors with request ids, user ids and token `jti`s; no token, no message text | one file per day, kept 14 days (`packages/data-schemas/src/config/winston.ts`) | delete the files | +| Data | Where (MongoDB collection or volume) | Holds tenant content | Retention in this configuration | How it is deleted | +| --------------------------------------- | ------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | ----------------------------------------------------------------------------------------------------------------------------- | +| Conversations | `conversations` | titles (title generation is off) | `expiredAt` after `generalChatRetention` (720 h), TTL index | the person deletes the chat; account deletion; TTL | +| Messages, with every tool call's output | `messages` (`content[].tool_call.output`) | yes: the questions, the answers and the full Loom results each tool returned | `expiredAt` after 720 h, TTL index | as above | +| Tool call records | `toolcalls` | tool outputs | `expiredAt`, TTL index | account deletion; TTL | +| Token usage | `transactions` | no: token counts per message | kept | account deletion | +| Each person's Loom token | `pluginauths`, encrypted with `CREDS_KEY` | a credential | until the person removes it | removing it in MCP settings; account deletion; revoke it in Loom with `loom revoke-token` | +| Uploaded files | `files` and the `uploads` volume | `expiredAt` under `retentionMode: all`; a sweep deletes the stored file, then the record (`packages/data-schemas/src/schema/file.ts`, `packages/api/src/files/sweep.ts`) | the person deletes the file; account deletion; the sweep | +| Agents | `agents` | the agent's instructions, which may name an org and a namespace | until deleted | the person deletes the agent (`DELETE /api/agents/:id`); account deletion | +| Agents API keys | `agentapikeys`, stored as a hash | a bearer credential: it runs the person's agents, and so Loom reads under their stored Loom token | until deleted | the person deletes the key (`DELETE /api/api-keys/:id`); account deletion; turn `interface.remoteAgents` off to stop new keys | +| LibreChat memories | `memoryentries` | none: `memory.disabled: true`, writes refused | not written | - | +| Message search index | none: Meilisearch is not deployed, `SEARCH=false` | - | - | - | +| Server logs | the `logs` volume and container output | errors with request ids, user ids and token `jti`s; no token, no message text | one file per day, kept 14 days (`packages/data-schemas/src/config/winston.ts`) | delete the files | - `retentionMode: all` gives every chat an expiry, not only temporary ones. It applies to chats created after it is set; existing rows keep their `expiredAt` (see the comment in @@ -228,49 +228,45 @@ server's own check uses. The cases go through Loom's assistant route (`qualify.py setup-bridge`), so each answer also carries the question's asker line and the bridge's own citation check. -**Before** is the same help questions on the build before the documentation reached the -assistant: an agent with no help tools. It answered 8 of 26 by its own knowledge and -cited none. **After** is the current agent definition. - -| Use case | Cases | Before: answered with a citation | After: correct | After: no invalid citation | -| --------------------------------- | ----- | -------------------------------- | -------------- | -------------------------- | -| U1 Look up a stored fact | 7 | 0 of 1 | 7 of 7 | 7 of 7 | -| U2 What a document says | 10 | 0 of 1 | 9 of 10 | 10 of 10 | -| U3 What the namespace holds | 3 | - | 3 of 3 | 3 of 3 | -| U4 Usage counts and trends | 3 | - | 3 of 3 | 3 of 3 | -| U5 Cost and spend | 1 | 0 of 1 | 1 of 1 | 1 of 1 | -| U6 Write memory better | 4 | 0 of 1 | 4 of 4 | 2 of 4 | -| U7 History of a fact | 2 | 0 of 1 | 2 of 2 | 2 of 2 | -| U8 Entity graph | 1 | 0 of 1 | 1 of 1 | 1 of 1 | -| U9 Code index | 1 | 0 of 1 | 1 of 1 | 1 of 1 | -| U10 Conflicts and refusal | 1 | 0 of 1 | 1 of 1 | 1 of 1 | -| U11 Sharing and collections | 1 | 0 of 1 | 1 of 1 | 1 of 1 | -| U12 My role and who can change it | 1 | 0 of 1 | 1 of 1 | 1 of 1 | -| U13 Connect a coding agent | 1 | 0 of 1 | 1 of 1 | 1 of 1 | -| U14 Tokens | 1 | 0 of 1 | 1 of 1 | 1 of 1 | -| U15 Models and keys | 1 | 0 of 1 | 1 of 1 | 0 of 1 | -| U16 Health problems | 1 | 0 of 1 | 1 of 1 | 1 of 1 | -| U17 Why search returned this | 1 | 0 of 1 | 1 of 1 | 1 of 1 | -| U18 Runs | 1 | 0 of 1 | 1 of 1 | 1 of 1 | -| U19 Tasks between agents | 1 | 0 of 1 | 1 of 1 | 1 of 1 | -| U20 Tracker | 1 | 0 of 1 | 1 of 1 | 1 of 1 | -| U21 Retention and erasure | 1 | 0 of 1 | 1 of 1 | 1 of 1 | -| U22 Extraction from transcripts | 1 | 0 of 1 | 1 of 1 | 1 of 1 | -| U23 Working memory | 1 | 0 of 1 | 1 of 1 | 1 of 1 | -| U24 Integrations | 2 | 0 of 1 | 2 of 2 | 2 of 2 | -| U25 What a setting does | 1 | 0 of 1 | 1 of 1 | 1 of 1 | -| U26 Getting started | 1 | 0 of 1 | 1 of 1 | 1 of 1 | -| U27 Operating a deployment | 1 | 0 of 1 | 1 of 1 | 1 of 1 | -| U28 Refusals and abstentions | 5 | 0 of 1 | 5 of 5 | 5 of 5 | -| All | 56 | 0 of 26 | 55 of 56 | 53 of 56 | +| Use case | Cases | Correct | No invalid citation | +| --------------------------------- | ----- | -------- | ------------------- | +| U1 Look up a stored fact | 7 | 7 of 7 | 7 of 7 | +| U2 What a document says | 10 | 9 of 10 | 10 of 10 | +| U3 What the namespace holds | 3 | 3 of 3 | 3 of 3 | +| U4 Usage counts and trends | 3 | 3 of 3 | 3 of 3 | +| U5 Cost and spend | 1 | 1 of 1 | 1 of 1 | +| U6 Write memory better | 4 | 4 of 4 | 2 of 4 | +| U7 History of a fact | 2 | 2 of 2 | 2 of 2 | +| U8 Entity graph | 1 | 1 of 1 | 1 of 1 | +| U9 Code index | 1 | 1 of 1 | 1 of 1 | +| U10 Conflicts and refusal | 1 | 1 of 1 | 1 of 1 | +| U11 Sharing and collections | 1 | 1 of 1 | 1 of 1 | +| U12 My role and who can change it | 1 | 1 of 1 | 1 of 1 | +| U13 Connect a coding agent | 1 | 1 of 1 | 1 of 1 | +| U14 Tokens | 1 | 1 of 1 | 1 of 1 | +| U15 Models and keys | 1 | 1 of 1 | 0 of 1 | +| U16 Health problems | 1 | 1 of 1 | 1 of 1 | +| U17 Why search returned this | 1 | 1 of 1 | 1 of 1 | +| U18 Runs | 1 | 1 of 1 | 1 of 1 | +| U19 Tasks between agents | 1 | 1 of 1 | 1 of 1 | +| U20 Tracker | 1 | 1 of 1 | 1 of 1 | +| U21 Retention and erasure | 1 | 1 of 1 | 1 of 1 | +| U22 Extraction from transcripts | 1 | 1 of 1 | 1 of 1 | +| U23 Working memory | 1 | 1 of 1 | 1 of 1 | +| U24 Integrations | 2 | 2 of 2 | 2 of 2 | +| U25 What a setting does | 1 | 1 of 1 | 1 of 1 | +| U26 Getting started | 1 | 1 of 1 | 1 of 1 | +| U27 Operating a deployment | 1 | 1 of 1 | 1 of 1 | +| U28 Refusals and abstentions | 5 | 5 of 5 | 5 of 5 | +| All | 56 | 55 of 56 | 53 of 56 | Measured on v0.8.8 with `claude-haiku-4-5`, on a server running fake embeddings and a fake LLM for Loom's own model jobs. A full run of the 56 cases costs about $3 at list price -counting every prompt token, a mean of $0.053 per answer. The after columns take 14 cases -(three memory, nine document and two help cases) from a run on the agent definition in -`integrations/librechat/agent.yaml`, and the other 42 from a full run on a definition that -differs from it in the wording of the first step's searches and of one sentence on the -asker's role. Twelve answers cite nothing: two refusals, three abstentions and seven +counting every prompt token, a mean of $0.053 per answer. The figures take 14 cases (three +memory, nine document and two help cases) from one run and the other 42 from a full run, +on agent definitions that differ from `integrations/librechat/agent.yaml` in one sentence +on the asker's role, and for the full run also in the wording of the first step's +searches. Twelve answers cite nothing: two refusals, three abstentions and seven counts, which come from tallies with no row to cite; every other answer cites one. The misses: diff --git a/integrations/librechat/qualification/cases.json b/integrations/librechat/qualification/cases.json index 63a08b577c..00b4c67abe 100644 --- a/integrations/librechat/qualification/cases.json +++ b/integrations/librechat/qualification/cases.json @@ -515,7 +515,7 @@ "use_case": "U5 Cost and spend", "person": "alice", "question": "What is the default daily spend cap of a namespace, and what does Loom skip once it is spent?", - "expect": ["(\\$\\s?1(\\.0+)?\\b|\\b1(\\.0)? ?(USD|dollar)|\\b1\\.0\\b)", "(synthes|extract)"], + "expect": ["(\\$\\s?1(\\.0+)?(?![\\d.])|\\b1(\\.0)? ?(USD|dollar)|\\b1\\.0(?![\\d.]))", "(synthes|extract)"], "cite_help": ["features/observability/cost-and-usage.md"], "baseline": { "op": "help.search", @@ -528,7 +528,8 @@ "right": ["$1.0 a day; once it is spent Loom skips synthesis and entity extraction."], "wrong": [ "$1.0, and nothing is skipped: the cap only warns.", - "There is no default cap; extraction keeps running." + "There is no default cap; extraction keeps running.", + "$1.50 a day; once it is spent Loom skips synthesis and extraction." ] } }, @@ -1024,13 +1025,18 @@ "limit": 5 } }, - "forbid": ["\\b(set|use|change)\\s+`?LOOM_[A-Z_]+", "LOOM_[A-Z_]+`?\\s*="], + "forbid": ["\\b(set|setting|use|using|try|change|export|enable)\\s+`?LOOM_[A-Z_]+", "LOOM_[A-Z_]+`?\\s*="], "samples": { "right": [ "Loom's documentation does not describe a dashboard colour theme.", "There is no `LOOM_THEME` setting; the docs don't cover a colour theme." ], - "wrong": ["The docs don't cover it, but set `LOOM_DASHBOARD_COLOUR=dark`.", "Use LOOM_UI_THEME to change it."] + "wrong": [ + "The docs don't cover it, but set `LOOM_DASHBOARD_COLOUR=dark`.", + "Use LOOM_UI_THEME to change it.", + "I couldn't find a theme setting in the docs; try `LOOM_UI_THEME`.", + "Not documented, but export LOOM_UI_THEME=dark." + ] } }, { diff --git a/integrations/librechat/qualification/qualify.py b/integrations/librechat/qualification/qualify.py index 7f112b7af5..c7cb826168 100644 --- a/integrations/librechat/qualification/qualify.py +++ b/integrations/librechat/qualification/qualify.py @@ -606,8 +606,9 @@ def check_help_citations( if not page.get("found"): invalid.append(f"{name}: no such page") continue + # A section that is only separators (`§ >`) cites the page, as the server reads it. section = m["section"] or "" - if section and not names_section( + if help_breadcrumb(section) and not names_section( help_breadcrumb(section), [help_breadcrumb(e["section"]) for e in page.get("sections", [])], ): @@ -922,8 +923,9 @@ def cmd_run(args: argparse.Namespace) -> None: def answer_citations( st: dict[str, Any], case: dict[str, Any], person: dict[str, Any], text: str ) -> dict[str, Any]: - """The memory keys and document passages an answer cites, the invalid ones, and whether - the labeled key or section is among them (None when the case labels neither).""" + """The memory keys, document passages and help pages an answer cites, the invalid ones, + and whether the labeled key, section or page is among them: False for a case that labels + a help page when the answer cites none, None when the case labels nothing.""" cited, invalid = check_citations(st, person, text) expected = case.get("cite") in cited if case.get("cite") else None if is_document_case(case): diff --git a/tests/unit/test_librechat_integration.py b/tests/unit/test_librechat_integration.py index eae128b5fc..aac8b1fa20 100644 --- a/tests/unit/test_librechat_integration.py +++ b/tests/unit/test_librechat_integration.py @@ -814,13 +814,15 @@ def fake_read(st, token, op, body): text = ( "[help:docs/features/cost.md § Daily spend caps] " "[help:features/cost.md § daily spend caps] " - "[help:features/other.md]" + "[help:features/other.md] " + "[help:features/cost.md § >]" # only separators: the page itself, as the server reads it ) cited, invalid, expected = q.check_help_citations(st, person, case, text) assert cited == [ "help:docs/features/cost.md § Daily spend caps", "help:features/cost.md § daily spend caps", "help:features/other.md", + "help:features/cost.md § >", ] assert invalid == [ "help:features/cost.md § daily spend caps: no such section", From b4e3ffed6caaae3a59d64827b092d5bbd00eaccf Mon Sep 17 00:00:00 2001 From: zlareb1 Date: Wed, 11 Nov 2026 00:47:34 +0000 Subject: [PATCH 07/41] The forbids no longer fail an answer that denies the wrong thing, and rescore reads the saved run's path The role, no-docs and erasure forbids catch the wrong claim, not a denial of it, with right samples that deny it; the docs-abstention phrases cover 'no setting' and 'don't list'. A run saves whether it went through the bridge, and rescore reads memory citations by that. The guide's storage table is restored. Co-Authored-By: Claude Opus 5.5 Signed-off-by: zlareb1 --- docs/features/integrations/librechat.md | 26 +++++++++--------- .../librechat/qualification/cases.json | 27 ++++++++++++++----- .../librechat/qualification/qualify.py | 22 ++++++++------- tests/unit/test_librechat_integration.py | 21 +++++++++++++++ 4 files changed, 66 insertions(+), 30 deletions(-) diff --git a/docs/features/integrations/librechat.md b/docs/features/integrations/librechat.md index 146b12332e..1b6a528ac9 100644 --- a/docs/features/integrations/librechat.md +++ b/docs/features/integrations/librechat.md @@ -90,19 +90,19 @@ Loom's erasure saga does not reach LibreChat's database: erasing a user or a mem Loom leaves every copy LibreChat holds. LibreChat must not become a second store of memory, so this configuration keeps its memory feature off and its search index out. -| Data | Where (MongoDB collection or volume) | Holds tenant content | Retention in this configuration | How it is deleted | -| --------------------------------------- | ------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | ----------------------------------------------------------------------------------------------------------------------------- | -| Conversations | `conversations` | titles (title generation is off) | `expiredAt` after `generalChatRetention` (720 h), TTL index | the person deletes the chat; account deletion; TTL | -| Messages, with every tool call's output | `messages` (`content[].tool_call.output`) | yes: the questions, the answers and the full Loom results each tool returned | `expiredAt` after 720 h, TTL index | as above | -| Tool call records | `toolcalls` | tool outputs | `expiredAt`, TTL index | account deletion; TTL | -| Token usage | `transactions` | no: token counts per message | kept | account deletion | -| Each person's Loom token | `pluginauths`, encrypted with `CREDS_KEY` | a credential | until the person removes it | removing it in MCP settings; account deletion; revoke it in Loom with `loom revoke-token` | -| Uploaded files | `files` and the `uploads` volume | `expiredAt` under `retentionMode: all`; a sweep deletes the stored file, then the record (`packages/data-schemas/src/schema/file.ts`, `packages/api/src/files/sweep.ts`) | the person deletes the file; account deletion; the sweep | -| Agents | `agents` | the agent's instructions, which may name an org and a namespace | until deleted | the person deletes the agent (`DELETE /api/agents/:id`); account deletion | -| Agents API keys | `agentapikeys`, stored as a hash | a bearer credential: it runs the person's agents, and so Loom reads under their stored Loom token | until deleted | the person deletes the key (`DELETE /api/api-keys/:id`); account deletion; turn `interface.remoteAgents` off to stop new keys | -| LibreChat memories | `memoryentries` | none: `memory.disabled: true`, writes refused | not written | - | -| Message search index | none: Meilisearch is not deployed, `SEARCH=false` | - | - | - | -| Server logs | the `logs` volume and container output | errors with request ids, user ids and token `jti`s; no token, no message text | one file per day, kept 14 days (`packages/data-schemas/src/config/winston.ts`) | delete the files | +| Data | Where (MongoDB collection or volume) | Holds tenant content | Retention in this configuration | How it is deleted | +| --------------------------------------- | ------------------------------------------------- | ------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | ----------------------------------------------------------------------------------------------------------------------------- | +| Conversations | `conversations` | titles (title generation is off) | `expiredAt` after `generalChatRetention` (720 h), TTL index | the person deletes the chat; account deletion; TTL | +| Messages, with every tool call's output | `messages` (`content[].tool_call.output`) | yes: the questions, the answers and the full Loom results each tool returned | `expiredAt` after 720 h, TTL index | as above | +| Tool call records | `toolcalls` | tool outputs | `expiredAt`, TTL index | account deletion; TTL | +| Token usage | `transactions` | no: token counts per message | kept | account deletion | +| Each person's Loom token | `pluginauths`, encrypted with `CREDS_KEY` | a credential | until the person removes it | removing it in MCP settings; account deletion; revoke it in Loom with `loom revoke-token` | +| Uploaded files | `files` and the `uploads` volume | yes, if people upload | `expiredAt` under `retentionMode: all`; a sweep deletes the stored file, then the record (`packages/data-schemas/src/schema/file.ts`, `packages/api/src/files/sweep.ts`) | the person deletes the file; account deletion; the sweep | +| Agents | `agents` | the agent's instructions, which may name an org and a namespace | until deleted | the person deletes the agent (`DELETE /api/agents/:id`); account deletion | +| Agents API keys | `agentapikeys`, stored as a hash | a bearer credential: it runs the person's agents, and so Loom reads under their stored Loom token | until deleted | the person deletes the key (`DELETE /api/api-keys/:id`); account deletion; turn `interface.remoteAgents` off to stop new keys | +| LibreChat memories | `memoryentries` | none: `memory.disabled: true`, writes refused | not written | - | +| Message search index | none: Meilisearch is not deployed, `SEARCH=false` | - | - | - | +| Server logs | the `logs` volume and container output | errors with request ids, user ids and token `jti`s; no token, no message text | one file per day, kept 14 days (`packages/data-schemas/src/config/winston.ts`) | delete the files | - `retentionMode: all` gives every chat an expiry, not only temporary ones. It applies to chats created after it is set; existing rows keep their `expiredAt` (see the comment in diff --git a/integrations/librechat/qualification/cases.json b/integrations/librechat/qualification/cases.json index 00b4c67abe..1d537bf163 100644 --- a/integrations/librechat/qualification/cases.json +++ b/integrations/librechat/qualification/cases.json @@ -686,10 +686,17 @@ "limit": 5 } }, - "forbid": ["\\byou (can|may) write\\b", "\\byou are (a |an )?(writer|admin)\\b"], + "forbid": ["^\\W*yes\\b", "\\byou (can|may) already write\\b", "\\byou are (a |an )?(writer|admin)\\b"], "samples": { - "right": ["You are a viewer here, so you cannot write; an admin can grant you writer."], - "wrong": ["Yes, you can write here.", "You are an admin, so you can write."] + "right": [ + "You are a viewer here, so you cannot write; an admin can grant you writer.", + "No: you are a viewer here. Ask an admin to grant you writer; once granted, you can write here." + ], + "wrong": [ + "Yes, you can write here.", + "You are an admin, so you can write.", + "You can already write here as a viewer." + ] } }, { @@ -872,9 +879,12 @@ "limit": 5 } }, - "forbid": ["run\\w* `?memory\\.clear", "`?memory\\.clear`? (erases|with `?agent)"], + "forbid": ["run\\w* `?memory\\.clear", "`?memory\\.clear`?\\s+(erases(?!\\s+nothing)|with `?agent)"], "samples": { - "right": ["An org admin, with `erasure.request` and the `user_id` scope."], + "right": [ + "An org admin, with `erasure.request` and the `user_id` scope.", + "`memory.clear` erases nothing; it only tombstones. An org admin uses `erasure.request` with the `user_id` scope." + ], "wrong": ["An org admin runs `memory.clear` with `agent=\"*\"`.", "Any writer may, with `memory.delete`."] } }, @@ -1025,11 +1035,14 @@ "limit": 5 } }, - "forbid": ["\\b(set|setting|use|using|try|change|export|enable)\\s+`?LOOM_[A-Z_]+", "LOOM_[A-Z_]+`?\\s*="], + "forbid": ["\\b(set|use|using|try|change|export|enable)\\s+`?LOOM_[A-Z_]+", "LOOM_[A-Z_]+`?\\s*="], "samples": { "right": [ "Loom's documentation does not describe a dashboard colour theme.", - "There is no `LOOM_THEME` setting; the docs don't cover a colour theme." + "There is no `LOOM_THEME` setting; the docs don't cover a colour theme.", + "There is no setting `LOOM_THEME`; the docs don't cover a colour theme.", + "Loom has no setting for the dashboard's colour theme.", + "The docs don't list a theme setting." ], "wrong": [ "The docs don't cover it, but set `LOOM_DASHBOARD_COLOUR=dark`.", diff --git a/integrations/librechat/qualification/qualify.py b/integrations/librechat/qualification/qualify.py index c7cb826168..6584087cf9 100644 --- a/integrations/librechat/qualification/qualify.py +++ b/integrations/librechat/qualification/qualify.py @@ -568,9 +568,9 @@ def parse_doc_citations(text: str) -> list[dict[str, Any]]: HELP_CITE_RE = re.compile(r"\[help:(?P[^\]§\s]+?)(?:\s*§\s*(?P
[^\]]+?))?\s*\]") # How an answer says the documentation does not cover a question. HELP_ABSTAIN_PATTERNS = ( - r"\bnot (documented|covered|described|mentioned|in (loom's|the) documentation)\b", - r"\b(documentation|docs) (does|do) ?n[o']t (cover|describe|mention|say)\b", - r"\bno (documented|such) (setting|option|feature)\b", + r"\bnot (documented|covered|described|mentioned|listed|in (loom's|the) documentation)\b", + r"\b(documentation|docs) (does|do) ?n[o']t (cover|describe|mention|say|list)\b", + r"\bno (documented |such )?(setting|option|feature)\b", r"\b(could ?n[o']t|did ?n[o']t|can ?not) find\b", ) @@ -607,10 +607,9 @@ def check_help_citations( invalid.append(f"{name}: no such page") continue # A section that is only separators (`§ >`) cites the page, as the server reads it. - section = m["section"] or "" - if help_breadcrumb(section) and not names_section( - help_breadcrumb(section), - [help_breadcrumb(e["section"]) for e in page.get("sections", [])], + breadcrumb = help_breadcrumb(m["section"] or "") + if breadcrumb and not names_section( + breadcrumb, [help_breadcrumb(e["section"]) for e in page.get("sections", [])] ): invalid.append(f"{name}: no such section") continue @@ -916,7 +915,9 @@ def cmd_run(args: argparse.Namespace) -> None: ) if args.cancel_probe: rows.append(cancel_probe(st, args)) - Path(args.out).write_text(json.dumps({"model": st.get("model"), "rows": rows}, indent=2)) + # Which path the answers took: through the bridge, a memory citation is `[memory:…]` only. + saved = {"model": st.get("model"), "bridge": bool(st.get("bridge")), "rows": rows} + Path(args.out).write_text(json.dumps(saved, indent=2)) print(report(rows, st.get("model", ""))) @@ -975,7 +976,8 @@ def cmd_rescore(args: argparse.Namespace) -> None: saved = json.loads(Path(args.out).read_text()) cases = {c["id"]: c for c in load("cases.json")} people = {p["name"]: p for p in load("fixture.json")["people"]} - st = state() if args.citations else {} + # The answers' own path decides how their memory citations read, not the current state. + st = {**state(), "bridge": saved.get("bridge", False)} if args.citations else {} for row in saved["rows"]: if row["kind"] != "cancel": lc = row["librechat"] @@ -1156,7 +1158,7 @@ def report(rows: list[dict[str, Any]], model: str) -> str: def use_case_report(cases: list[dict[str, Any]]) -> list[str]: """Per use case (cases.json `use_case`): the answers through LibreChat that are - correct and cite validly, out of its cases.""" + correct, those with no invalid citation, and the unknown names they wrote.""" by: dict[str, list[dict[str, Any]]] = {} for r in cases: by.setdefault(r.get("use_case") or "-", []).append(r) diff --git a/tests/unit/test_librechat_integration.py b/tests/unit/test_librechat_integration.py index aac8b1fa20..9d03dc5c55 100644 --- a/tests/unit/test_librechat_integration.py +++ b/tests/unit/test_librechat_integration.py @@ -1063,3 +1063,24 @@ def fake_docs(st, person, case, text): got = q.answer_citations({}, case, {"namespace": "acme-library"}, "See [help:a.md § A].") assert docs_read == ["See ."] assert got["cited"] == ["help:a.md"] and got["invalid_citations"] == [] + + +def test_rescore_reads_memory_citations_by_the_saved_runs_path(monkeypatch, tmp_path): + import argparse + + q = _qualify() + seen = [] + + def fake_citations(st, case, person, text): + seen.append(st.get("bridge")) + return {"cited": [], "invalid_citations": [], "cited_expected": None} + + monkeypatch.setattr(q, "answer_citations", fake_citations) + # The current state is the bridge's; the saved run went straight through LibreChat. + monkeypatch.setattr(q, "state", lambda: {"bridge": True}) + side = _saved_side("The freeze is on Fridays (policy/deploy/freeze).") + out = tmp_path / "results.json" + row = {"id": "memory-freeze", "kind": "memory", "librechat": side, "native": side} + out.write_text(json.dumps({"model": "m", "bridge": False, "rows": [row]})) + q.cmd_rescore(argparse.Namespace(out=str(out), citations=True)) + assert seen == [False] From e3308b0a409eb0bb241ffe4cf9a419726e84cdef Mon Sep 17 00:00:00 2001 From: zlareb1 Date: Wed, 11 Nov 2026 00:55:56 +0000 Subject: [PATCH 08/41] The no-docs case is held to the documented settings, every forbid is reached by a wrong sample, and bridge citations are read whole An answer to the question the docs leave open is correct when it abstains and writes no LOOM_ name a docs page lacks, the docs half of the server's unknown-name check, in place of verb patterns; the bridge's unknown names count for it too. Each help forbid has a wrong sample that passes the label and fails only on it. Through the bridge a memory citation is parsed in the server's form, and memory citations are not read as documents. Rescore needs the saved run's path. The upgrade label ties booting to applying the migrations. Co-Authored-By: Claude Opus 5.5 Signed-off-by: zlareb1 --- docs/features/integrations/librechat.md | 4 +- .../librechat/qualification/cases.json | 36 +++++--- .../librechat/qualification/qualify.py | 90 ++++++++++++------- tests/unit/test_librechat_integration.py | 71 ++++++++++++--- 4 files changed, 143 insertions(+), 58 deletions(-) diff --git a/docs/features/integrations/librechat.md b/docs/features/integrations/librechat.md index 1b6a528ac9..cea0d141c9 100644 --- a/docs/features/integrations/librechat.md +++ b/docs/features/integrations/librechat.md @@ -221,8 +221,8 @@ values its answer must state and the pages that hold them, with a right and a wr answer the label is tested against. Its answer is scored correct when it states them and names no op or setting the server neither serves nor documents (`unknown_names` on the answer's `loom.citations` event). For the case with no answer in the docs, the answer is -correct when it says so and tells the person to set no setting; it may name one to deny -it. A help citation is valid when its page is in the server's +correct when it says so and writes no `LOOM_` name that no docs page writes; an answer +that names an invented setting only to deny it is scored wrong. A help citation is valid when its page is in the server's documentation (`help.get`) and its section is one of the page's own, by the rule the server's own check uses. The cases go through Loom's assistant route (`qualify.py setup-bridge`), so each answer also carries the question's asker line and diff --git a/integrations/librechat/qualification/cases.json b/integrations/librechat/qualification/cases.json index 1d537bf163..fa292273f8 100644 --- a/integrations/librechat/qualification/cases.json +++ b/integrations/librechat/qualification/cases.json @@ -593,7 +593,10 @@ "right": [ "Pass them in `entities` on `memory.set`; otherwise the extractor worker extracts them from the memory's text." ], - "wrong": ["Entities are not extracted from memories; an admin adds them by hand only."] + "wrong": [ + "Entities are not extracted from memories; an admin adds them by hand only.", + "Entities come from `memory.set`; they are not extracted from text." + ] } }, { @@ -695,7 +698,8 @@ "wrong": [ "Yes, you can write here.", "You are an admin, so you can write.", - "You can already write here as a viewer." + "You can already write here as a viewer.", + "You are a viewer, but you can already write here; an admin can grant more." ] } }, @@ -885,7 +889,11 @@ "An org admin, with `erasure.request` and the `user_id` scope.", "`memory.clear` erases nothing; it only tombstones. An org admin uses `erasure.request` with the `user_id` scope." ], - "wrong": ["An org admin runs `memory.clear` with `agent=\"*\"`.", "Any writer may, with `memory.delete`."] + "wrong": [ + "An org admin runs `memory.clear` with `agent=\"*\"`.", + "Any writer may, with `memory.delete`.", + "An org admin can use `erasure.request`, or run `memory.clear` across the org." + ] } }, { @@ -994,7 +1002,10 @@ "forbid": ["\\byou (do |will )?need an? (\\w+ )?(API )?key"], "samples": { "right": ["No: the quickstart needs no API key and no account."], - "wrong": ["Yes, you need an API key; no account is needed."] + "wrong": [ + "Yes, you need an API key; no account is needed.", + "The quickstart needs no API key for its fake models, but you need an API key to start it." + ] } }, { @@ -1003,7 +1014,9 @@ "use_case": "U27 Operating a deployment", "person": "alice", "question": "How do I upgrade a Loom deployment to a new release?", - "expect": ["migrat", "boot|start"], + "expect": [ + "(boot|start)\\w*[^.]{0,60}(appl|run)\\w* (the |pending |its )?migrat|migrations? (run|are applied|apply) (at|on|when) (boot|start)" + ], "cite_help": ["operations/upgrades.md"], "baseline": { "op": "help.search", @@ -1016,7 +1029,9 @@ "right": ["Deploy the new image; the first container to boot applies the migrations."], "wrong": [ "Export every memory, reinstall the new release and import them back.", - "Loom cannot be upgraded in place; migrate the data by hand." + "Loom cannot be upgraded in place; migrate the data by hand.", + "Loom cannot be upgraded in place; migrate the data by hand, then start the new build.", + "Stop every server, run the migrations by hand, then start the new release." ] } }, @@ -1035,20 +1050,17 @@ "limit": 5 } }, - "forbid": ["\\b(set|use|using|try|change|export|enable)\\s+`?LOOM_[A-Z_]+", "LOOM_[A-Z_]+`?\\s*="], "samples": { "right": [ "Loom's documentation does not describe a dashboard colour theme.", - "There is no `LOOM_THEME` setting; the docs don't cover a colour theme.", - "There is no setting `LOOM_THEME`; the docs don't cover a colour theme.", "Loom has no setting for the dashboard's colour theme.", - "The docs don't list a theme setting." + "The docs don't list a theme setting; `LOOM_COLOUR` picks a blue/green deployment, not a theme." ], "wrong": [ "The docs don't cover it, but set `LOOM_DASHBOARD_COLOUR=dark`.", "Use LOOM_UI_THEME to change it.", - "I couldn't find a theme setting in the docs; try `LOOM_UI_THEME`.", - "Not documented, but export LOOM_UI_THEME=dark." + "The docs don't cover it; try setting `LOOM_UI_THEME`.", + "There is no setting `LOOM_THEME`; the docs don't cover a colour theme." ] } }, diff --git a/integrations/librechat/qualification/qualify.py b/integrations/librechat/qualification/qualify.py index 6584087cf9..49d309dc3d 100644 --- a/integrations/librechat/qualification/qualify.py +++ b/integrations/librechat/qualification/qualify.py @@ -30,6 +30,7 @@ import argparse import asyncio +import functools import json import os import re @@ -508,15 +509,7 @@ def history(key: str) -> set[int]: versions[key] = {int(r["version"]) for r in rows if r.get("version")} return versions[key] - # A help citation's page path (`features/memory/writing.md`) is no memory key. An - # answer through Loom's assistant cites a memory as `[memory:@v]`, so a - # key-shaped example it quotes from the docs (`scope/kind/id`) is no citation either. - keyed = HELP_CITE_RE.sub("", text) - if st.get("bridge"): - keyed = " ".join(m[0] for m in re.finditer(r"\[memory:[^\]]+\]", keyed)) - found = list(KEY_RE.finditer(keyed)) - for i, m in enumerate(found): - key = m.group(0) + for key, version in memory_mentions(st, text): if key not in current: cited.append(key) body = { @@ -530,21 +523,38 @@ def history(key: str) -> set[int]: current[key] = int(out["version"]) if ok else None if current[key] is None: invalid.append(key) - if current[key] is None: + if current[key] is None or version is None or version == current[key]: + continue + # An earlier version is a valid citation of what the key once held (an answer about + # its history); a version the key never had is not. + if version in history(key): continue - # Every mention is checked: a version belongs to the key before it, up to the next key. + stale = f"{key}@{version}" + if stale not in invalid: + invalid.append(stale) + return cited, invalid + + +# A memory citation as Loom's assistant writes it (`server.assistant.domain.citations`). +MEMORY_CITE_RE = re.compile(r"\[memory:(?P[^\]\s]+)@v(?P\d+)\]") + + +def memory_mentions(st: dict[str, Any], text: str) -> list[tuple[str, int | None]]: + """Each memory key an answer cites, with the version it names (None for none). Through + Loom's assistant a citation is `[memory:@v]`, so a key-shaped example it + quotes from the docs (`scope/kind/id`) is none. Otherwise a key is any key-shaped text + outside a help citation (whose page path is no key), with the version written after it, + up to the next key.""" + if st.get("bridge"): + return [(m["key"], int(m["version"])) for m in MEMORY_CITE_RE.finditer(text)] + keyed = HELP_CITE_RE.sub("", text) + found = list(KEY_RE.finditer(keyed)) + mentions: list[tuple[str, int | None]] = [] + for i, m in enumerate(found): end = min(m.end() + 80, found[i + 1].start() if i + 1 < len(found) else len(keyed)) - # A bare version, or the deployed agent's `[memory:@v]`. near = re.search(r"(?:\b|@v)(\d{16,20})\b", keyed[m.end() : end]) - if near and int(near.group(1)) != current[key]: - # An earlier version is a valid citation of what the key once held (an answer - # about its history); a version the key never had is not. - if int(near.group(1)) in history(key): - continue - stale = f"{key}@{near.group(1)}" - if stale not in invalid: - invalid.append(stale) - return cited, invalid + mentions.append((m.group(0), int(near.group(1)) if near else None)) + return mentions def parse_doc_citations(text: str) -> list[dict[str, Any]]: @@ -575,10 +585,27 @@ def parse_doc_citations(text: str) -> list[dict[str, Any]]: ) +DOCS = HERE.parents[2] / "docs" +SETTING_RE = re.compile(r"\bLOOM_[A-Z0-9_]*[A-Z0-9]") # The kinds whose right answer is an abstention: from the namespace, or from the docs. ABSTAIN_KINDS = ("abstain", "help_abstain") +@functools.cache +def documented_settings() -> frozenset[str]: + """Every `LOOM_*` name a docs page writes: the documentation half of the server's + unknown-name check (`server.assistant.domain.names`).""" + return frozenset( + name for page in DOCS.rglob("*.md") for name in SETTING_RE.findall(page.read_text()) + ) + + +def undocumented_settings(text: str) -> list[str]: + """The `LOOM_*` names an answer writes that no docs page does: a setting the answer made + up, even one it names to deny.""" + return sorted(set(SETTING_RE.findall(text)) - documented_settings()) + + def is_help_case(case: dict[str, Any]) -> bool: """A question about Loom itself: its direct path is help.search.""" return case["baseline"]["op"] == "help.search" @@ -731,7 +758,10 @@ def score(case: dict[str, Any], text: str) -> dict[str, Any]: abstained = matches(ABSTAIN_PATTERNS, text) or ( is_document_case(case) and matches(DOC_ABSTAIN_PATTERNS, text) ) - if kind in ABSTAIN_KINDS: + if kind == "help_abstain": + # It says the docs leave it open, and invents no setting for it. + correct = abstained and not undocumented_settings(text) + elif kind == "abstain": correct = abstained elif kind == "refusal": correct = matches(REFUSAL_PATTERNS, text) @@ -743,12 +773,9 @@ def score(case: dict[str, Any], text: str) -> dict[str, Any]: def score_answer(case: dict[str, Any], got: dict[str, Any]) -> dict[str, Any]: """Score an answer through LibreChat: its text, and wrong when it names an op or setting - the build neither serves nor documents (the bridge's `unknown_names`). A question the - docs leave open is the exception: its answer may name a setting to say there is none, - and its case forbids an answer that tells the person to set one.""" + the build neither serves nor documents (the bridge's `unknown_names`).""" result = score(case, got["answer"] or got["error"]) - if case["kind"] != "help_abstain": - result["correct"] = result["correct"] and not got.get("unknown_names") + result["correct"] = result["correct"] and not got.get("unknown_names") return result @@ -930,8 +957,9 @@ def answer_citations( cited, invalid = check_citations(st, person, text) expected = case.get("cite") in cited if case.get("cite") else None if is_document_case(case): - # A help citation (`[help: § …]`) is checked as one below, not as a document. - doc_text = HELP_CITE_RE.sub("", text) + # Help and memory citations (`[help:…]`, `[memory:…]`) are checked as such, not as + # documents. + doc_text = MEMORY_CITE_RE.sub("", HELP_CITE_RE.sub("", text)) doc_cited, doc_invalid, doc_expected = check_doc_citations(st, person, case, doc_text) cited, invalid = cited + doc_cited, invalid + doc_invalid expected = doc_expected if case.get("cite_doc") else None @@ -977,7 +1005,9 @@ def cmd_rescore(args: argparse.Namespace) -> None: cases = {c["id"]: c for c in load("cases.json")} people = {p["name"]: p for p in load("fixture.json")["people"]} # The answers' own path decides how their memory citations read, not the current state. - st = {**state(), "bridge": saved.get("bridge", False)} if args.citations else {} + if args.citations and "bridge" not in saved: + sys.exit(f"{args.out} does not say which path its answers took: run it again") + st = {**state(), "bridge": saved["bridge"]} if args.citations else {} for row in saved["rows"]: if row["kind"] != "cancel": lc = row["librechat"] diff --git a/tests/unit/test_librechat_integration.py b/tests/unit/test_librechat_integration.py index 9d03dc5c55..8c395ecba4 100644 --- a/tests/unit/test_librechat_integration.py +++ b/tests/unit/test_librechat_integration.py @@ -717,7 +717,9 @@ def fake_call(base, token, op, body): row = {"id": "doc-revised-ack", "kind": "document", "documents": True} out = tmp_path / "results.json" out.write_text( - json.dumps({"model": "m", "rows": [{**row, "librechat": side, "native": native}]}) + json.dumps( + {"model": "m", "bridge": False, "rows": [{**row, "librechat": side, "native": native}]} + ) ) q.cmd_rescore(argparse.Namespace(out=str(out), citations=True)) got = json.loads(out.read_text())["rows"][0]["librechat"] @@ -1002,20 +1004,15 @@ def test_a_help_answer_that_cites_no_page_misses_the_labeled_one(monkeypatch): assert got["cited_expected"] is False -@pytest.mark.parametrize( - "answer, correct", - [ - ("Loom's documentation does not describe a dashboard colour theme.", True), - # Naming a setting to say there is none is still an abstention. - ("There is no `LOOM_THEME` setting; the docs don't cover a colour theme.", True), - ("The docs don't cover it, but set `LOOM_DASHBOARD_THEME=dark`.", False), - ("Use LOOM_UI_THEME to change it.", False), - ], -) -def test_a_question_the_docs_leave_open(answer, correct): +def test_a_question_the_docs_leave_open_is_held_to_the_documented_settings(): q = _qualify() - got = q.score_answer(_case("help-undocumented"), _saved_side(answer, unknown_names=["X"])) - assert got["correct"] is correct + case = _case("help-undocumented") + # A real variable named beside the abstention is fine; an invented one is not, and the + # bridge's unknown names count too. + real = _saved_side("The docs don't cover a theme; `LOOM_COLOUR` picks a deployment.") + assert q.score_answer(case, real)["correct"] is True + assert q.score_answer(case, {**real, "unknown_names": ["LOOM_X"]})["correct"] is False + assert q.undocumented_settings("set LOOM_UI_THEME, not LOOM_COLOUR") == ["LOOM_UI_THEME"] def test_the_history_direct_path_counts_the_keys_versions(): @@ -1084,3 +1081,49 @@ def fake_citations(st, case, person, text): out.write_text(json.dumps({"model": "m", "bridge": False, "rows": [row]})) q.cmd_rescore(argparse.Namespace(out=str(out), citations=True)) assert seen == [False] + + +@pytest.mark.parametrize( + "case", [c for c in _help_cases() if c.get("forbid")], ids=lambda c: c["id"] +) +def test_each_help_forbid_is_what_fails_one_wrong_sample(case): + q = _qualify() + # A wrong sample that states what the label expects, and fails only on the forbid. + reached = [ + a + for a in case["samples"]["wrong"] + if q.score({**case, "forbid": []}, a)["correct"] and not q.score(case, a)["correct"] + ] + assert reached, case["id"] + + +def test_a_memory_citation_in_a_document_answer_is_no_document(monkeypatch): + q = _qualify() + read = [] + monkeypatch.setattr(q, "check_citations", lambda st, person, text: ([], [])) + monkeypatch.setattr( + q, + "check_doc_citations", + lambda st, person, case, text: read.append(text) or ([], [], False), + ) + q.answer_citations({}, _case("doc-cache-entries"), {}, "A [memory:a/b/c@v1793745407448901606].") + assert read == ["A ."] + + +def test_through_the_bridge_a_memory_citation_is_read_whole(): + q = _qualify() + text = "`user/pref/example` [memory:user/pref/john_doe@v1793745407448901606]" + assert q.memory_mentions({"bridge": True}, text) == [ + ("user/pref/john_doe", 1793745407448901606) + ] + assert q.memory_mentions({}, text)[0] == ("user/pref/example", 1793745407448901606) + + +def test_rescore_asks_for_a_new_run_when_the_saved_path_is_unknown(tmp_path): + import argparse + + q = _qualify() + out = tmp_path / "results.json" + out.write_text(json.dumps({"model": "m", "rows": []})) + with pytest.raises(SystemExit, match="which path"): + q.cmd_rescore(argparse.Namespace(out=str(out), citations=True)) From bd6a9329bc1530ac1adbe9bc8e2a5714b7a65bef Mon Sep 17 00:00:00 2001 From: zlareb1 Date: Wed, 11 Nov 2026 01:05:38 +0000 Subject: [PATCH 09/41] An earlier memory version is a valid citation only in a history case, and the op-naming help cases fail a wrong claim about their op check_citations takes history_ok from the case's cite_history; elsewhere an earlier version is stale again, as the guide says. Six help cases gain a wrong sample that names the op and denies it, with a forbid that fails it. Code citations are not read as documents; the documented settings skip development/, as the help index does; the history and get reads share one body. Co-Authored-By: Claude Opus 5.5 Signed-off-by: zlareb1 --- docs/features/integrations/librechat.md | 9 +-- .../librechat/qualification/cases.json | 56 +++++++++++++----- .../librechat/qualification/qualify.py | 58 ++++++++++--------- tests/unit/test_librechat_integration.py | 12 ++-- 4 files changed, 87 insertions(+), 48 deletions(-) diff --git a/docs/features/integrations/librechat.md b/docs/features/integrations/librechat.md index cea0d141c9..66bc9e1166 100644 --- a/docs/features/integrations/librechat.md +++ b/docs/features/integrations/librechat.md @@ -136,7 +136,8 @@ orgs, mints a token per person, revokes one, and scores each answer: other org's canary for the cross-tenant case, the person's own answer (`friday`) for the revoked-token case, and a stale or wrong value for some others. - **citation valid:** every memory key the answer names exists in the person's namespace, - and a version written next to it is the row's current version. + and a version written next to it is the row's current version, or, for a question about + the key's history (`cite_history`), one of its earlier versions. - **tool calls:** the `mcp` rows Loom ledgered under the person's subject during the answer. - **latency and time to first token:** end to end, and to the first streamed delta, which for the harness's own agent (`setup`) is the model's one-line preamble before its first @@ -222,9 +223,9 @@ answer the label is tested against. Its answer is scored correct when it states names no op or setting the server neither serves nor documents (`unknown_names` on the answer's `loom.citations` event). For the case with no answer in the docs, the answer is correct when it says so and writes no `LOOM_` name that no docs page writes; an answer -that names an invented setting only to deny it is scored wrong. A help citation is valid when its page is in the server's -documentation (`help.get`) and its section is one of the page's own, by the rule the -server's own check uses. The cases go through Loom's assistant route +that names an invented setting only to deny it is scored wrong. A help citation is valid +when its page is in the server's documentation (`help.get`) and its section is one of the +page's own, by the rule the server's own check uses. The cases go through Loom's assistant route (`qualify.py setup-bridge`), so each answer also carries the question's asker line and the bridge's own citation check. diff --git a/integrations/librechat/qualification/cases.json b/integrations/librechat/qualification/cases.json index fa292273f8..515f0190b6 100644 --- a/integrations/librechat/qualification/cases.json +++ b/integrations/librechat/qualification/cases.json @@ -506,8 +506,15 @@ }, "samples": { "right": ["Upload it with `knowledge.upload`."], - "wrong": ["Save its text with `memory.set`."] - } + "wrong": [ + "Save its text with `memory.set`.", + "`knowledge.upload` does not accept a PDF; convert it to text first." + ] + }, + "forbid": [ + "\\bno `?knowledge\\.(upload|ingest)", + "`?knowledge\\.(upload|ingest)`? (does ?n[o']t|cannot|can ?not) (take|accept|read) (a )?PDF" + ] }, { "id": "help-cost-cap", @@ -570,8 +577,12 @@ }, "samples": { "right": ["Call `memory.history` with the key."], - "wrong": ["Loom keeps only the latest version."] - } + "wrong": [ + "Loom keeps only the latest version.", + "Loom has no `memory.history` op; it keeps only the latest version." + ] + }, + "forbid": ["\\bno `?memory\\.history", "only (keeps |the )?(the )?latest"] }, { "id": "help-graph", @@ -616,8 +627,12 @@ }, "samples": { "right": ["Use **Repositories → Add repository** in the dashboard, or call `code.repo.add`."], - "wrong": ["You cannot add a repository; Loom indexes only its own code."] - } + "wrong": [ + "You cannot add a repository; Loom indexes only its own code.", + "You cannot use `code.repo.add`; only Loom's own repository is indexed." + ] + }, + "forbid": ["\\bno `?code\\.repo\\.add", "(cannot|can ?not|can't) (call|use) `?code\\.repo\\.add"] }, { "id": "help-conflict", @@ -689,7 +704,12 @@ "limit": 5 } }, - "forbid": ["^\\W*yes\\b", "\\byou (can|may) already write\\b", "\\byou are (a |an )?(writer|admin)\\b"], + "forbid": [ + "^\\W*yes\\b", + "\\byou (can|may) already write\\b", + "\\byou are (a |an )?(writer|admin)\\b", + "\\bviewers? (can|may) write" + ], "samples": { "right": [ "You are a viewer here, so you cannot write; an admin can grant you writer.", @@ -699,7 +719,8 @@ "Yes, you can write here.", "You are an admin, so you can write.", "You can already write here as a viewer.", - "You are a viewer, but you can already write here; an admin can grant more." + "You are a viewer, but you can already write here; an admin can grant more.", + "You are a viewer; viewers can write here, no admin grant needed." ] } }, @@ -822,8 +843,12 @@ }, "samples": { "right": ["A run is one execution of a task; the agent starts it with `run.begin`."], - "wrong": ["A run is a CI job; agents cannot start one."] - } + "wrong": [ + "A run is a CI job; agents cannot start one.", + "There is no `run.begin`; a run starts on its own when an agent connects." + ] + }, + "forbid": ["\\bno `?run\\.begin", "`?run\\.begin`? (does ?n[o']t exist|is removed)"] }, { "id": "help-tasks", @@ -913,8 +938,12 @@ }, "samples": { "right": ["Send the transcript to `memory.set_from_messages`."], - "wrong": ["Copy each fact out by hand and call `memory.set`."] - } + "wrong": [ + "Copy each fact out by hand and call `memory.set`.", + "`memory.set_from_messages` does not exist; copy each fact out by hand." + ] + }, + "forbid": ["\\bno `?memory\\.set_from_messages", "`?memory\\.set_from_messages`? (does ?n[o']t exist|is removed)"] }, { "id": "help-working-memory", @@ -1095,6 +1124,7 @@ "path": ["rows"], "count": true, "equals": 2 - } + }, + "cite_history": true } ] diff --git a/integrations/librechat/qualification/qualify.py b/integrations/librechat/qualification/qualify.py index 49d309dc3d..cd60e973f0 100644 --- a/integrations/librechat/qualification/qualify.py +++ b/integrations/librechat/qualification/qualify.py @@ -478,10 +478,11 @@ def matches(patterns: tuple[str, ...] | list[str], text: str) -> bool: def check_citations( - st: dict[str, Any], person: dict[str, Any], text: str + st: dict[str, Any], person: dict[str, Any], text: str, history_ok: bool = False ) -> tuple[list[str], list[str]]: """Every memory key the answer names, and those that do not exist in the person's namespace - or name a version the key never had.""" + or name a version other than the row's current one. With `history_ok` (a question about + a key's history), an earlier version the key had is valid too.""" ns = person["namespace"] scorer = st["tokens"][f"scorer:{ns}"] # memory.get over HTTP reads one writer's row; the fixture says who wrote each key. @@ -497,37 +498,36 @@ def check_citations( current: dict[str, int | None] = {} # each key's current version, read once versions: dict[str, set[int]] = {} # each key's every version, read when one is cited + def body(key: str) -> dict[str, Any]: + return { + "org": person["org"], + "namespace": ns, + "memory_key": key, + "agent": writers.get(key, "-"), + } + def history(key: str) -> set[int]: + # The key exists (memory.get found it), so a failed history read says nothing about + # the answer: scorer_read waits out a 429 and stops the run on anything else. if key not in versions: - body = { - "org": person["org"], - "namespace": ns, - "memory_key": key, - "agent": writers.get(key, "-"), - } - rows = scorer_read(st, scorer, "memory.history", body).get("rows") or [] + rows = scorer_read(st, scorer, "memory.history", body(key)).get("rows") or [] versions[key] = {int(r["version"]) for r in rows if r.get("version")} return versions[key] for key, version in memory_mentions(st, text): if key not in current: cited.append(key) - body = { - "org": person["org"], - "namespace": ns, - "memory_key": key, - "agent": writers.get(key, "-"), - } - code, out, _ = loom_call(st["loom_url"], scorer, "memory.get", body) + # A key that is not there is the answer's fault: it is marked invalid. + code, out, _ = loom_call(st["loom_url"], scorer, "memory.get", body(key)) ok = code == 200 and out.get("found", True) and out.get("version") current[key] = int(out["version"]) if ok else None if current[key] is None: invalid.append(key) if current[key] is None or version is None or version == current[key]: continue - # An earlier version is a valid citation of what the key once held (an answer about - # its history); a version the key never had is not. - if version in history(key): + # An earlier version cites what the key once held: valid in an answer about its + # history, and stale anywhere else. + if history_ok and version in history(key): continue stale = f"{key}@{version}" if stale not in invalid: @@ -535,8 +535,10 @@ def history(key: str) -> set[int]: return cited, invalid -# A memory citation as Loom's assistant writes it (`server.assistant.domain.citations`). +# A memory and a code citation as Loom's assistant writes them +# (`server.assistant.domain.citations`). MEMORY_CITE_RE = re.compile(r"\[memory:(?P[^\]\s]+)@v(?P\d+)\]") +CODE_CITE_RE = re.compile(r"\[code:(?P[^\]\s]+?):(?P\d+)\]") def memory_mentions(st: dict[str, Any], text: str) -> list[tuple[str, int | None]]: @@ -593,10 +595,14 @@ def parse_doc_citations(text: str) -> list[dict[str, Any]]: @functools.cache def documented_settings() -> frozenset[str]: - """Every `LOOM_*` name a docs page writes: the documentation half of the server's - unknown-name check (`server.assistant.domain.names`).""" + """Every `LOOM_*` name a docs page the server ships writes (the help index skips + `development/`): the documentation half of the server's unknown-name check + (`server.assistant.domain.names`).""" return frozenset( - name for page in DOCS.rglob("*.md") for name in SETTING_RE.findall(page.read_text()) + name + for page in DOCS.rglob("*.md") + if not page.relative_to(DOCS).as_posix().startswith("development/") + for name in SETTING_RE.findall(page.read_text()) ) @@ -954,12 +960,12 @@ def answer_citations( """The memory keys, document passages and help pages an answer cites, the invalid ones, and whether the labeled key, section or page is among them: False for a case that labels a help page when the answer cites none, None when the case labels nothing.""" - cited, invalid = check_citations(st, person, text) + cited, invalid = check_citations(st, person, text, history_ok=bool(case.get("cite_history"))) expected = case.get("cite") in cited if case.get("cite") else None if is_document_case(case): - # Help and memory citations (`[help:…]`, `[memory:…]`) are checked as such, not as + # Help, memory and code citations (`[help:…]`, `[memory:…]`, `[code:…]`) are not # documents. - doc_text = MEMORY_CITE_RE.sub("", HELP_CITE_RE.sub("", text)) + doc_text = CODE_CITE_RE.sub("", MEMORY_CITE_RE.sub("", HELP_CITE_RE.sub("", text))) doc_cited, doc_invalid, doc_expected = check_doc_citations(st, person, case, doc_text) cited, invalid = cited + doc_cited, invalid + doc_invalid expected = doc_expected if case.get("cite_doc") else None diff --git a/tests/unit/test_librechat_integration.py b/tests/unit/test_librechat_integration.py index 8c395ecba4..582ebe20aa 100644 --- a/tests/unit/test_librechat_integration.py +++ b/tests/unit/test_librechat_integration.py @@ -208,7 +208,9 @@ def fake_call(base, token, op, body): ["policy/deploy/freeze@1793745407000000000"], ) earlier = "Before: `policy/deploy/freeze` (version 1793745400000000000)." - assert q.check_citations(st, person, earlier) == (["policy/deploy/freeze"], []) + assert q.check_citations(st, person, earlier, history_ok=True) == (["policy/deploy/freeze"], []) + # Outside a question about history, an earlier version cited is stale. + assert q.check_citations(st, person, earlier)[1] == ["policy/deploy/freeze@1793745400000000000"] unknown = "See policy/deploy/thaw." assert q.check_citations(st, person, unknown) == ( ["policy/deploy/thaw"], @@ -990,13 +992,13 @@ def test_rescore_keeps_the_unknown_name_rule_and_takes_the_current_labels(tmp_pa def test_a_help_answer_that_cites_no_page_misses_the_labeled_one(monkeypatch): q = _qualify() - monkeypatch.setattr(q, "check_citations", lambda st, person, text: ([], [])) + monkeypatch.setattr(q, "check_citations", lambda st, person, text, **_: ([], [])) case = _case("help-revoke-token") person = {"namespace": "acme-handbook"} got = q.answer_citations({}, case, person, "Run `loom revoke-token`.") assert got == {"cited": [], "invalid_citations": [], "cited_expected": False} # A memory key cited beside the page does not decide it: the labeled page does. - monkeypatch.setattr(q, "check_citations", lambda st, person, text: (["a/b/c"], [])) + monkeypatch.setattr(q, "check_citations", lambda st, person, text, **_: (["a/b/c"], [])) monkeypatch.setattr( q, "check_help_citations", lambda st, person, case, text: (["help:x.md"], [], False) ) @@ -1046,7 +1048,7 @@ def test_each_help_label_passes_its_right_samples_and_fails_its_wrong_ones(case) def test_a_document_answer_that_cites_a_help_page_checks_it_as_help(monkeypatch): q = _qualify() docs_read = [] - monkeypatch.setattr(q, "check_citations", lambda st, person, text: ([], [])) + monkeypatch.setattr(q, "check_citations", lambda st, person, text, **_: ([], [])) def fake_docs(st, person, case, text): docs_read.append(text) @@ -1100,7 +1102,7 @@ def test_each_help_forbid_is_what_fails_one_wrong_sample(case): def test_a_memory_citation_in_a_document_answer_is_no_document(monkeypatch): q = _qualify() read = [] - monkeypatch.setattr(q, "check_citations", lambda st, person, text: ([], [])) + monkeypatch.setattr(q, "check_citations", lambda st, person, text, **_: ([], [])) monkeypatch.setattr( q, "check_doc_citations", From 63773083e5af4d792b09af0d81cb4a252777a6c1 Mon Sep 17 00:00:00 2001 From: zlareb1 Date: Wed, 11 Nov 2026 01:13:50 +0000 Subject: [PATCH 10/41] Help labels accept the docs' answer in other words, and the guide's scoring bullets match the scorer The upgrade, cost-cap, setting and no-docs labels pass the docs' own and paraphrased wording, each held by a right sample; the history and erasure forbids fail only the wrong claim. The connected-agents case is a namespace-inventory question (U3). The guide states the unknown-name rule for every case and the bridge's memory citation form. Co-Authored-By: Claude Opus 5.5 Signed-off-by: zlareb1 --- docs/features/integrations/librechat.md | 19 ++++--- .../librechat/qualification/cases.json | 49 ++++++++++++++----- .../librechat/qualification/qualify.py | 2 +- tests/unit/test_librechat_integration.py | 1 - 4 files changed, 48 insertions(+), 23 deletions(-) diff --git a/docs/features/integrations/librechat.md b/docs/features/integrations/librechat.md index 66bc9e1166..948b320c59 100644 --- a/docs/features/integrations/librechat.md +++ b/docs/features/integrations/librechat.md @@ -134,10 +134,14 @@ orgs, mints a token per person, revokes one, and scores each answer: inspect or tune case contains the labeled value; a refusal case says access was refused or failed; an abstention case says the fact is not stored. The forbidden text is the other org's canary for the cross-tenant case, the person's own answer (`friday`) for the - revoked-token case, and a stale or wrong value for some others. -- **citation valid:** every memory key the answer names exists in the person's namespace, + revoked-token case, and a stale or wrong value for some others. Through Loom's assistant + route, an answer of any kind that names an op or setting the build neither serves nor + documents (`unknown_names`) is wrong. +- **citation valid:** every memory key the answer cites exists in the person's namespace, and a version written next to it is the row's current version, or, for a question about - the key's history (`cite_history`), one of its earlier versions. + the key's history (`cite_history`), one of its earlier versions. Through Loom's assistant + route a memory citation is `[memory:@v]`; otherwise it is any key-shaped + text. - **tool calls:** the `mcp` rows Loom ledgered under the person's subject during the answer. - **latency and time to first token:** end to end, and to the first streamed delta, which for the harness's own agent (`setup`) is the model's one-line preamble before its first @@ -219,9 +223,8 @@ The case set holds at least one question per use case of Loom: what a namespace how it is used (the data tools), and how Loom works and how to do something in it (the help tools, which read the documentation the server ships). Each help case labels the values its answer must state and the pages that hold them, with a right and a wrong sample -answer the label is tested against. Its answer is scored correct when it states them and -names no op or setting the server neither serves nor documents (`unknown_names` on the -answer's `loom.citations` event). For the case with no answer in the docs, the answer is +answer the label is tested against. Its answer is scored correct when it states them, +under the unknown-name rule above. For the case with no answer in the docs, the answer is correct when it says so and writes no `LOOM_` name that no docs page writes; an answer that names an invented setting only to deny it is scored wrong. A help citation is valid when its page is in the server's documentation (`help.get`) and its section is one of the @@ -233,7 +236,7 @@ the bridge's own citation check. | --------------------------------- | ----- | -------- | ------------------- | | U1 Look up a stored fact | 7 | 7 of 7 | 7 of 7 | | U2 What a document says | 10 | 9 of 10 | 10 of 10 | -| U3 What the namespace holds | 3 | 3 of 3 | 3 of 3 | +| U3 What the namespace holds | 4 | 4 of 4 | 4 of 4 | | U4 Usage counts and trends | 3 | 3 of 3 | 3 of 3 | | U5 Cost and spend | 1 | 1 of 1 | 1 of 1 | | U6 Write memory better | 4 | 4 of 4 | 2 of 4 | @@ -254,7 +257,7 @@ the bridge's own citation check. | U21 Retention and erasure | 1 | 1 of 1 | 1 of 1 | | U22 Extraction from transcripts | 1 | 1 of 1 | 1 of 1 | | U23 Working memory | 1 | 1 of 1 | 1 of 1 | -| U24 Integrations | 2 | 2 of 2 | 2 of 2 | +| U24 Integrations | 1 | 1 of 1 | 1 of 1 | | U25 What a setting does | 1 | 1 of 1 | 1 of 1 | | U26 Getting started | 1 | 1 of 1 | 1 of 1 | | U27 Operating a deployment | 1 | 1 of 1 | 1 of 1 | diff --git a/integrations/librechat/qualification/cases.json b/integrations/librechat/qualification/cases.json index 515f0190b6..07a389e72e 100644 --- a/integrations/librechat/qualification/cases.json +++ b/integrations/librechat/qualification/cases.json @@ -522,7 +522,7 @@ "use_case": "U5 Cost and spend", "person": "alice", "question": "What is the default daily spend cap of a namespace, and what does Loom skip once it is spent?", - "expect": ["(\\$\\s?1(\\.0+)?(?![\\d.])|\\b1(\\.0)? ?(USD|dollar)|\\b1\\.0(?![\\d.]))", "(synthes|extract)"], + "expect": ["(\\$\\s?1(\\.0+)?(?!\\.?\\d)|\\b1(\\.0)? ?(USD|dollar)|\\b1\\.0(?!\\.?\\d))", "(synthes|extract)"], "cite_help": ["features/observability/cost-and-usage.md"], "baseline": { "op": "help.search", @@ -532,7 +532,11 @@ } }, "samples": { - "right": ["$1.0 a day; once it is spent Loom skips synthesis and entity extraction."], + "right": [ + "$1.0 a day; once it is spent Loom skips synthesis and entity extraction.", + "The default cap is $1. Once it is spent, Loom skips synthesis.", + "The cap is $1.0. Past it Loom skips entity extraction." + ], "wrong": [ "$1.0, and nothing is skipped: the cap only warns.", "There is no default cap; extraction keeps running.", @@ -576,13 +580,16 @@ } }, "samples": { - "right": ["Call `memory.history` with the key."], + "right": [ + "Call `memory.history` with the key.", + "`memory.get` returns only the latest version; `memory.history` returns every earlier one." + ], "wrong": [ "Loom keeps only the latest version.", "Loom has no `memory.history` op; it keeps only the latest version." ] }, - "forbid": ["\\bno `?memory\\.history", "only (keeps |the )?(the )?latest"] + "forbid": ["\\bno `?memory\\.history", "\\b(keeps only|only keeps) the latest"] }, { "id": "help-graph", @@ -908,16 +915,21 @@ "limit": 5 } }, - "forbid": ["run\\w* `?memory\\.clear", "`?memory\\.clear`?\\s+(erases(?!\\s+nothing)|with `?agent)"], + "forbid": [ + "\\b(admin|you|or|then) (can )?runs? `?memory\\.clear", + "`?memory\\.clear`?\\s+(erases(?!\\s+nothing)|with `?agent)" + ], "samples": { "right": [ "An org admin, with `erasure.request` and the `user_id` scope.", - "`memory.clear` erases nothing; it only tombstones. An org admin uses `erasure.request` with the `user_id` scope." + "`memory.clear` erases nothing; it only tombstones. An org admin uses `erasure.request` with the `user_id` scope.", + "Running `memory.clear` is not enough: it only tombstones. An org admin uses `erasure.request` with the `user_id` scope." ], "wrong": [ "An org admin runs `memory.clear` with `agent=\"*\"`.", "Any writer may, with `memory.delete`.", - "An org admin can use `erasure.request`, or run `memory.clear` across the org." + "An org admin can use `erasure.request`, or run `memory.clear` across the org.", + "An org admin runs `memory.clear` across every namespace, which also calls `erasure.request`." ] } }, @@ -999,7 +1011,10 @@ "use_case": "U25 What a setting does", "person": "alice", "question": "What does LOOM_ASSISTANT_MODEL set?", - "expect": ["agent definition", "\\bboot"], + "expect": [ + "agent definition|agent('s)? model|model the (assistant|agent)|agent\\.yaml", + "\\bboot|restart|start-?up" + ], "cite_help": ["reference/configuration.md", "architecture/assistant.md"], "baseline": { "op": "help.search", @@ -1009,7 +1024,10 @@ } }, "samples": { - "right": ["The assistant agent's model; Loom writes it into the agent definition at boot."], + "right": [ + "The assistant agent's model; Loom writes it into the agent definition at boot.", + "It sets the model the assistant's agent runs, in place of `agent.yaml`'s; a change takes effect at the next restart." + ], "wrong": ["I could not find what LOOM_ASSISTANT_MODEL sets."] } }, @@ -1044,7 +1062,7 @@ "person": "alice", "question": "How do I upgrade a Loom deployment to a new release?", "expect": [ - "(boot|start)\\w*[^.]{0,60}(appl|run)\\w* (the |pending |its )?migrat|migrations? (run|are applied|apply) (at|on|when) (boot|start)" + "(boot|start)\\w*[^.]{0,60}(appl|run)\\w* (the |pending |its )?migrat|(appl|run)\\w* (the |pending |its )?migrat\\w*[^.]{0,40}\\b(at|on|when|before) (boot|start|it reports ready)|migrations? (run|are applied|apply) (at|on|when) (boot|start)" ], "cite_help": ["operations/upgrades.md"], "baseline": { @@ -1055,7 +1073,10 @@ } }, "samples": { - "right": ["Deploy the new image; the first container to boot applies the migrations."], + "right": [ + "Deploy the new image; the first container to boot applies the migrations.", + "Deploy the new image; the server applies pending migrations at boot." + ], "wrong": [ "Export every memory, reinstall the new release and import them back.", "Loom cannot be upgraded in place; migrate the data by hand.", @@ -1083,7 +1104,9 @@ "right": [ "Loom's documentation does not describe a dashboard colour theme.", "Loom has no setting for the dashboard's colour theme.", - "The docs don't list a theme setting; `LOOM_COLOUR` picks a blue/green deployment, not a theme." + "The docs don't list a theme setting; `LOOM_COLOUR` picks a blue/green deployment, not a theme.", + "No Loom setting changes the dashboard's colour theme.", + "There is no colour theme setting." ], "wrong": [ "The docs don't cover it, but set `LOOM_DASHBOARD_COLOUR=dark`.", @@ -1096,7 +1119,7 @@ { "id": "data-connected-agents", "kind": "inventory", - "use_case": "U24 Integrations", + "use_case": "U3 What the namespace holds", "person": "alice", "question": "Which agents have written to this namespace?", "expect": ["handbook-bot", "ops-bot"], diff --git a/integrations/librechat/qualification/qualify.py b/integrations/librechat/qualification/qualify.py index cd60e973f0..fb13f864af 100644 --- a/integrations/librechat/qualification/qualify.py +++ b/integrations/librechat/qualification/qualify.py @@ -582,7 +582,7 @@ def parse_doc_citations(text: str) -> list[dict[str, Any]]: HELP_ABSTAIN_PATTERNS = ( r"\bnot (documented|covered|described|mentioned|listed|in (loom's|the) documentation)\b", r"\b(documentation|docs) (does|do) ?n[o']t (cover|describe|mention|say|list)\b", - r"\bno (documented |such )?(setting|option|feature)\b", + r"\bno (\w+ ){0,3}(setting|option|feature)s?\b", r"\b(could ?n[o']t|did ?n[o']t|can ?not) find\b", ) diff --git a/tests/unit/test_librechat_integration.py b/tests/unit/test_librechat_integration.py index 582ebe20aa..11531109d7 100644 --- a/tests/unit/test_librechat_integration.py +++ b/tests/unit/test_librechat_integration.py @@ -1118,7 +1118,6 @@ def test_through_the_bridge_a_memory_citation_is_read_whole(): assert q.memory_mentions({"bridge": True}, text) == [ ("user/pref/john_doe", 1793745407448901606) ] - assert q.memory_mentions({}, text)[0] == ("user/pref/example", 1793745407448901606) def test_rescore_asks_for_a_new_run_when_the_saved_path_is_unknown(tmp_path): From 8019694c17f4ec9804cd6671b04b9c35729ec67f Mon Sep 17 00:00:00 2001 From: zlareb1 Date: Wed, 11 Nov 2026 01:21:43 +0000 Subject: [PATCH 11/41] The quickstart and erasure cases rely on their expected values alone, and the no-docs and tracker labels read more of the docs' answer Their forbids failed right answers that contrasted the wrong op or added a caveat; the expected op and role decide those cases now, and the guide says a label shows the answer has what the page says. The docs-abstention phrases read 'doesn't have a setting' and 'there is no ... setting' but not a how-to's 'no other setting'. The tracker label reads 'doesn't store' and 'queries it live'. The revoke-token sample uses the CLI's --jti. Co-Authored-By: Claude Opus 5.5 Signed-off-by: zlareb1 --- docs/features/integrations/librechat.md | 4 +- .../librechat/qualification/cases.json | 46 ++++++++++--------- .../librechat/qualification/qualify.py | 5 +- 3 files changed, 31 insertions(+), 24 deletions(-) diff --git a/docs/features/integrations/librechat.md b/docs/features/integrations/librechat.md index 948b320c59..c282f7e933 100644 --- a/docs/features/integrations/librechat.md +++ b/docs/features/integrations/librechat.md @@ -226,7 +226,9 @@ values its answer must state and the pages that hold them, with a right and a wr answer the label is tested against. Its answer is scored correct when it states them, under the unknown-name rule above. For the case with no answer in the docs, the answer is correct when it says so and writes no `LOOM_` name that no docs page writes; an answer -that names an invented setting only to deny it is scored wrong. A help citation is valid +that names an invented setting only to deny it is scored wrong. The labels are patterns +over the answer's text: an answer that states the labeled values beside a wrong claim +about them can still pass, so a correct score means the answer has what the page says. A help citation is valid when its page is in the server's documentation (`help.get`) and its section is one of the page's own, by the rule the server's own check uses. The cases go through Loom's assistant route (`qualify.py setup-bridge`), so each answer also carries the question's asker line and diff --git a/integrations/librechat/qualification/cases.json b/integrations/librechat/qualification/cases.json index 07a389e72e..5632b9c428 100644 --- a/integrations/librechat/qualification/cases.json +++ b/integrations/librechat/qualification/cases.json @@ -767,7 +767,7 @@ } }, "samples": { - "right": ["Run `loom revoke-token `."], + "right": ["Run `loom revoke-token --jti `."], "wrong": ["Tokens cannot be revoked; wait for them to expire."] } }, @@ -886,7 +886,9 @@ "use_case": "U20 Tracker", "person": "alice", "question": "Does Loom copy our issue tracker's data into its own database?", - "expect": ["(never copies|reads it live|does not copy|doesn't copy)"], + "expect": [ + "(never|does ?n[o']t|does not) (copy|copies|store|stores|keep|keeps)\\b|(reads|queries) (it|the tracker|\\w+) live|keeps? no copy" + ], "cite_help": ["features/tracker/overview.md"], "baseline": { "op": "help.search", @@ -896,7 +898,10 @@ } }, "samples": { - "right": ["No: Loom never copies it; it reads the tracker live."], + "right": [ + "No: Loom never copies it; it reads the tracker live.", + "No. Loom doesn't store your tracker's data; it queries it live with a read-only credential." + ], "wrong": ["Yes, it copies every issue into its database each night."] } }, @@ -915,22 +920,15 @@ "limit": 5 } }, - "forbid": [ - "\\b(admin|you|or|then) (can )?runs? `?memory\\.clear", - "`?memory\\.clear`?\\s+(erases(?!\\s+nothing)|with `?agent)" - ], "samples": { "right": [ "An org admin, with `erasure.request` and the `user_id` scope.", "`memory.clear` erases nothing; it only tombstones. An org admin uses `erasure.request` with the `user_id` scope.", - "Running `memory.clear` is not enough: it only tombstones. An org admin uses `erasure.request` with the `user_id` scope." + "Running `memory.clear` is not enough: it only tombstones. An org admin uses `erasure.request` with the `user_id` scope.", + "`memory.clear` with `agent` or `user_id` only tombstones in one namespace; an org admin uses `erasure.request` with the `user_id` scope.", + "An admin can run `memory.clear`, but it only tombstones; an org admin erases with `erasure.request` and the `user_id` scope." ], - "wrong": [ - "An org admin runs `memory.clear` with `agent=\"*\"`.", - "Any writer may, with `memory.delete`.", - "An org admin can use `erasure.request`, or run `memory.clear` across the org.", - "An org admin runs `memory.clear` across every namespace, which also calls `erasure.request`." - ] + "wrong": ["An org admin runs `memory.clear` with `agent=\"*\"`.", "Any writer may, with `memory.delete`."] } }, { @@ -1001,7 +999,10 @@ } }, "samples": { - "right": ["Set `LOOM_LANGFUSE_URL` and `LOOM_LANGFUSE_ADMIN_TOKEN`."], + "right": [ + "Set `LOOM_LANGFUSE_URL` and `LOOM_LANGFUSE_ADMIN_TOKEN`.", + "Set `LOOM_LANGFUSE_URL` and `LOOM_LANGFUSE_ADMIN_TOKEN`; no other setting is needed." + ], "wrong": ["Set `LOOM_TRACE_URL`."] } }, @@ -1046,13 +1047,12 @@ "limit": 5 } }, - "forbid": ["\\byou (do |will )?need an? (\\w+ )?(API )?key"], "samples": { - "right": ["No: the quickstart needs no API key and no account."], - "wrong": [ - "Yes, you need an API key; no account is needed.", - "The quickstart needs no API key for its fake models, but you need an API key to start it." - ] + "right": [ + "No: the quickstart needs no API key and no account.", + "No: the quickstart needs no API key. For real models you need an OpenAI API key (Settings → Models & keys)." + ], + "wrong": ["Yes, you need an API key; no account is needed."] } }, { @@ -1106,7 +1106,9 @@ "Loom has no setting for the dashboard's colour theme.", "The docs don't list a theme setting; `LOOM_COLOUR` picks a blue/green deployment, not a theme.", "No Loom setting changes the dashboard's colour theme.", - "There is no colour theme setting." + "There is no colour theme setting.", + "Loom doesn't have a setting for the dashboard's colour theme.", + "There isn't a Loom setting that changes the colour theme." ], "wrong": [ "The docs don't cover it, but set `LOOM_DASHBOARD_COLOUR=dark`.", diff --git a/integrations/librechat/qualification/qualify.py b/integrations/librechat/qualification/qualify.py index fb13f864af..4095f10b06 100644 --- a/integrations/librechat/qualification/qualify.py +++ b/integrations/librechat/qualification/qualify.py @@ -582,7 +582,10 @@ def parse_doc_citations(text: str) -> list[dict[str, Any]]: HELP_ABSTAIN_PATTERNS = ( r"\bnot (documented|covered|described|mentioned|listed|in (loom's|the) documentation)\b", r"\b(documentation|docs) (does|do) ?n[o']t (cover|describe|mention|say|list)\b", - r"\bno (\w+ ){0,3}(setting|option|feature)s?\b", + r"\b(there is|there's|loom has) no (\w+ ){0,3}(setting|option|feature)s?\b", + r"\bno (\w+ ){0,3}setting (changes|sets|controls)\b", + r"\b(does ?n[o']t|do not) (have|offer|provide|expose) an? (\w+ ){0,3}(setting|option)", + r"\bis ?n[o']t an? (\w+ ){0,3}(setting|option)", r"\b(could ?n[o']t|did ?n[o']t|can ?not) find\b", ) From eb5360d467b117bb1bcfae750bde57db13277a40 Mon Sep 17 00:00:00 2001 From: zlareb1 Date: Wed, 11 Nov 2026 01:29:01 +0000 Subject: [PATCH 12/41] The quickstart, upgrade, setting and no-docs labels pass the common ways of saying the docs' answer "You don't need an API key", "migrations run automatically at boot", a setting answer without its timing, and "the dashboard has no theme setting" now score correct, each held by a right sample. The documented settings are read as UTF-8, as the help index reads them. Co-Authored-By: Claude Opus 5.5 Signed-off-by: zlareb1 --- .../librechat/qualification/cases.json | 25 +++++++++++-------- .../librechat/qualification/qualify.py | 7 +++--- 2 files changed, 19 insertions(+), 13 deletions(-) diff --git a/integrations/librechat/qualification/cases.json b/integrations/librechat/qualification/cases.json index 5632b9c428..51329049eb 100644 --- a/integrations/librechat/qualification/cases.json +++ b/integrations/librechat/qualification/cases.json @@ -1012,10 +1012,7 @@ "use_case": "U25 What a setting does", "person": "alice", "question": "What does LOOM_ASSISTANT_MODEL set?", - "expect": [ - "agent definition|agent('s)? model|model the (assistant|agent)|agent\\.yaml", - "\\bboot|restart|start-?up" - ], + "expect": ["agent definition|agent('s)? model|model the (assistant|agent)|agent\\.yaml"], "cite_help": ["reference/configuration.md", "architecture/assistant.md"], "baseline": { "op": "help.search", @@ -1027,7 +1024,8 @@ "samples": { "right": [ "The assistant agent's model; Loom writes it into the agent definition at boot.", - "It sets the model the assistant's agent runs, in place of `agent.yaml`'s; a change takes effect at the next restart." + "It sets the model the assistant's agent runs, in place of `agent.yaml`'s; a change takes effect at the next restart.", + "It sets the model the assistant's agent runs in LibreChat; empty keeps `agent.yaml`'s model." ], "wrong": ["I could not find what LOOM_ASSISTANT_MODEL sets."] } @@ -1038,7 +1036,7 @@ "use_case": "U26 Getting started", "person": "alice", "question": "Does Loom's quickstart need an API key?", - "expect": ["no API key|needs? no (API )?key|(does ?n[o']t|do not) need an? (API )?key"], + "expect": ["\\b(no|n[o']t|without)\\b[^.]{0,30}\\b(API )?keys?\\b"], "cite_help": ["getting-started/quickstart.md"], "baseline": { "op": "help.search", @@ -1050,7 +1048,9 @@ "samples": { "right": [ "No: the quickstart needs no API key and no account.", - "No: the quickstart needs no API key. For real models you need an OpenAI API key (Settings → Models & keys)." + "No: the quickstart needs no API key. For real models you need an OpenAI API key (Settings → Models & keys).", + "No, you don't need an API key to run the quickstart.", + "No, it doesn't require an API key." ], "wrong": ["Yes, you need an API key; no account is needed."] } @@ -1062,7 +1062,7 @@ "person": "alice", "question": "How do I upgrade a Loom deployment to a new release?", "expect": [ - "(boot|start)\\w*[^.]{0,60}(appl|run)\\w* (the |pending |its )?migrat|(appl|run)\\w* (the |pending |its )?migrat\\w*[^.]{0,40}\\b(at|on|when|before) (boot|start|it reports ready)|migrations? (run|are applied|apply) (at|on|when) (boot|start)" + "(boot|start)\\w*[^.]{0,60}(appl|run)\\w* (the |pending |its )?migrat|(appl|run)\\w* (the |pending |its )?migrat\\w*[^.]{0,40}\\b(at|on|when|before) (boot|start|it reports ready)|migrations? (run|are applied|apply)[^.]{0,30}\\b(at|on|when) (boot|start)" ], "cite_help": ["operations/upgrades.md"], "baseline": { @@ -1075,7 +1075,9 @@ "samples": { "right": [ "Deploy the new image; the first container to boot applies the migrations.", - "Deploy the new image; the server applies pending migrations at boot." + "Deploy the new image; the server applies pending migrations at boot.", + "Deploy the new image; migrations run automatically at boot.", + "Migrations apply automatically on startup once the new image is deployed." ], "wrong": [ "Export every memory, reinstall the new release and import them back.", @@ -1108,7 +1110,10 @@ "No Loom setting changes the dashboard's colour theme.", "There is no colour theme setting.", "Loom doesn't have a setting for the dashboard's colour theme.", - "There isn't a Loom setting that changes the colour theme." + "There isn't a Loom setting that changes the colour theme.", + "The dashboard has no colour theme setting.", + "No Loom setting exists for the dashboard's colour theme.", + "The dashboard's colour theme isn't configurable." ], "wrong": [ "The docs don't cover it, but set `LOOM_DASHBOARD_COLOUR=dark`.", diff --git a/integrations/librechat/qualification/qualify.py b/integrations/librechat/qualification/qualify.py index 4095f10b06..a1d07bce88 100644 --- a/integrations/librechat/qualification/qualify.py +++ b/integrations/librechat/qualification/qualify.py @@ -582,8 +582,9 @@ def parse_doc_citations(text: str) -> list[dict[str, Any]]: HELP_ABSTAIN_PATTERNS = ( r"\bnot (documented|covered|described|mentioned|listed|in (loom's|the) documentation)\b", r"\b(documentation|docs) (does|do) ?n[o']t (cover|describe|mention|say|list)\b", - r"\b(there is|there's|loom has) no (\w+ ){0,3}(setting|option|feature)s?\b", - r"\bno (\w+ ){0,3}setting (changes|sets|controls)\b", + r"\b(there is|there's|\w+ has) no (\w+ ){0,3}(setting|option|feature)s?\b", + r"\bno (\w+ ){0,3}setting (changes|sets|controls|exists|for)\b", + r"\b(is|are) ?n[o']t (configurable|settable)\b", r"\b(does ?n[o']t|do not) (have|offer|provide|expose) an? (\w+ ){0,3}(setting|option)", r"\bis ?n[o']t an? (\w+ ){0,3}(setting|option)", r"\b(could ?n[o']t|did ?n[o']t|can ?not) find\b", @@ -605,7 +606,7 @@ def documented_settings() -> frozenset[str]: name for page in DOCS.rglob("*.md") if not page.relative_to(DOCS).as_posix().startswith("development/") - for name in SETTING_RE.findall(page.read_text()) + for name in SETTING_RE.findall(page.read_text(encoding="utf-8")) ) From bbd6372d9a5c87f642cf86bcfb00731b7c641495 Mon Sep 17 00:00:00 2001 From: zlareb1 Date: Wed, 11 Nov 2026 01:38:59 +0000 Subject: [PATCH 13/41] The collection, task, run, erasure, tracker and graph labels pass the docs' other wordings, and the guide says labels err both ways The labels accept the sharing page's definition of a collection, the SDK forms of task and run calls, 'organization admin' and 'reads your tracker live'; the graph forbid fails only a claim that entities are not extracted. The guide says a right answer worded otherwise can fail, and the use-case report's unknown-name column has a test. Co-Authored-By: Claude Opus 5.5 Signed-off-by: zlareb1 --- docs/features/integrations/librechat.md | 9 +++-- .../librechat/qualification/cases.json | 37 +++++++++++++------ tests/unit/test_librechat_integration.py | 15 ++++++++ 3 files changed, 45 insertions(+), 16 deletions(-) diff --git a/docs/features/integrations/librechat.md b/docs/features/integrations/librechat.md index c282f7e933..e533f13436 100644 --- a/docs/features/integrations/librechat.md +++ b/docs/features/integrations/librechat.md @@ -227,10 +227,11 @@ answer the label is tested against. Its answer is scored correct when it states under the unknown-name rule above. For the case with no answer in the docs, the answer is correct when it says so and writes no `LOOM_` name that no docs page writes; an answer that names an invented setting only to deny it is scored wrong. The labels are patterns -over the answer's text: an answer that states the labeled values beside a wrong claim -about them can still pass, so a correct score means the answer has what the page says. A help citation is valid -when its page is in the server's documentation (`help.get`) and its section is one of the -page's own, by the rule the server's own check uses. The cases go through Loom's assistant route +over the answer's text, so they err both ways: an answer that states the labeled values +beside a wrong claim about them can pass, and a right answer worded otherwise can fail. A +correct score means the answer has what the page says. A help citation is valid when its +page is in the server's documentation (`help.get`) and its section is one of the page's +own, by the rule the server's own check uses. The cases go through Loom's assistant route (`qualify.py setup-bridge`), so each answer also carries the question's asker line and the bridge's own citation check. diff --git a/integrations/librechat/qualification/cases.json b/integrations/librechat/qualification/cases.json index 51329049eb..3758e42a81 100644 --- a/integrations/librechat/qualification/cases.json +++ b/integrations/librechat/qualification/cases.json @@ -606,10 +606,11 @@ "limit": 5 } }, - "forbid": ["\\b(are|is) not extracted", "by hand only"], + "forbid": ["\\b(entities|they) (are|is) not extracted", "by hand only"], "samples": { "right": [ - "Pass them in `entities` on `memory.set`; otherwise the extractor worker extracts them from the memory's text." + "Pass them in `entities` on `memory.set`; otherwise the extractor worker extracts them from the memory's text.", + "Relations you pass on `memory.set` are not extracted from the text; `memory.set_from_messages` extracts entities and triples." ], "wrong": [ "Entities are not extracted from memories; an admin adds them by hand only.", @@ -669,7 +670,10 @@ "use_case": "U11 Sharing and collections", "person": "alice", "question": "What is a collection in Loom, and how is one shared?", - "expect": ["col-", "(through|by|via|with|creat\\w*|add\\w*) (a |its )?grants?|grants? on it"], + "expect": [ + "col-|only grants open|grant-only|opens? only (through|by|via) grants?", + "grants?\\b[^.]{0,40}\\bon it|(by|via|with|through) (a |its )?`?grants?|grant(s|ing)? (a |an )?(user|group|agent|principal|`?everyone)" + ], "cite_help": [ "concepts/identities-and-namespaces.md", "architecture/sharing.md", @@ -684,7 +688,8 @@ }, "samples": { "right": [ - "A collection is a `col-…` namespace that opens only through grants; you share it by creating grants on it." + "A collection is a `col-…` namespace that opens only through grants; you share it by creating grants on it.", + "A collection is a namespace that only grants open; no token claim or org admin role reaches it. Share it by granting a user, group, agent or `everyone` a role on it." ], "wrong": [ "A collection is a folder of documents; share it with a link.", @@ -839,7 +844,7 @@ "use_case": "U18 Runs", "person": "alice", "question": "What is a run in Loom, and how does an agent start one?", - "expect": ["run\\.begin"], + "expect": ["run\\.(begin|scope)"], "cite_help": ["features/runs.md", "reference/operations/run.md"], "baseline": { "op": "help.search", @@ -849,7 +854,10 @@ } }, "samples": { - "right": ["A run is one execution of a task; the agent starts it with `run.begin`."], + "right": [ + "A run is one execution of a task; the agent starts it with `run.begin`.", + "A run is one execution of a task; in the SDK, `async with agent.run.scope(goal=...)` opens the run." + ], "wrong": [ "A run is a CI job; agents cannot start one.", "There is no `run.begin`; a run starts on its own when an agent connects." @@ -863,7 +871,7 @@ "use_case": "U19 Tasks between agents", "person": "alice", "question": "How does one agent hand work to another agent in Loom?", - "expect": ["task\\.create", "task\\.pull|inbox"], + "expect": ["tasks?\\.create", "tasks?\\.pull|inbox"], "cite_help": ["features/tasks-and-decisions.md"], "baseline": { "op": "help.search", @@ -873,7 +881,10 @@ } }, "samples": { - "right": ["The sender calls `task.create` into the receiver's inbox; the receiver claims it with `task.pull`."], + "right": [ + "The sender calls `task.create` into the receiver's inbox; the receiver claims it with `task.pull`.", + "The sender posts with `a.tasks.create(\"private-bot\", ...)` and the receiver pulls it with `tasks.pull`." + ], "wrong": [ "The agents share a memory key and poll it.", "They hand work over through a shared task list in the dashboard." @@ -887,7 +898,7 @@ "person": "alice", "question": "Does Loom copy our issue tracker's data into its own database?", "expect": [ - "(never|does ?n[o']t|does not) (copy|copies|store|stores|keep|keeps)\\b|(reads|queries) (it|the tracker|\\w+) live|keeps? no copy" + "(never|does ?n[o']t|does not) (copy|copies|store|stores|keep|keeps)\\b|(reads|queries)\\b[^.]{0,30}\\blive|keeps? no copy" ], "cite_help": ["features/tracker/overview.md"], "baseline": { @@ -900,7 +911,8 @@ "samples": { "right": [ "No: Loom never copies it; it reads the tracker live.", - "No. Loom doesn't store your tracker's data; it queries it live with a read-only credential." + "No. Loom doesn't store your tracker's data; it queries it live with a read-only credential.", + "No. Loom reads your tracker live with a read-only credential." ], "wrong": ["Yes, it copies every issue into its database each night."] } @@ -911,7 +923,7 @@ "use_case": "U21 Retention and erasure", "person": "alice", "question": "Who may erase every memory of one user id across the org?", - "expect": ["erasure\\.request", "org admin"], + "expect": ["erasure\\.request", "org(ani[sz]ation)? admin|admin of the org"], "cite_help": ["features/memory/retention-and-erasure.md"], "baseline": { "op": "help.search", @@ -926,7 +938,8 @@ "`memory.clear` erases nothing; it only tombstones. An org admin uses `erasure.request` with the `user_id` scope.", "Running `memory.clear` is not enough: it only tombstones. An org admin uses `erasure.request` with the `user_id` scope.", "`memory.clear` with `agent` or `user_id` only tombstones in one namespace; an org admin uses `erasure.request` with the `user_id` scope.", - "An admin can run `memory.clear`, but it only tombstones; an org admin erases with `erasure.request` and the `user_id` scope." + "An admin can run `memory.clear`, but it only tombstones; an org admin erases with `erasure.request` and the `user_id` scope.", + "Only an organization admin, with `erasure.request` and the `user_id` scope." ], "wrong": ["An org admin runs `memory.clear` with `agent=\"*\"`.", "Any writer may, with `memory.delete`."] } diff --git a/tests/unit/test_librechat_integration.py b/tests/unit/test_librechat_integration.py index 11531109d7..25b70e66e2 100644 --- a/tests/unit/test_librechat_integration.py +++ b/tests/unit/test_librechat_integration.py @@ -1128,3 +1128,18 @@ def test_rescore_asks_for_a_new_run_when_the_saved_path_is_unknown(tmp_path): out.write_text(json.dumps({"model": "m", "rows": []})) with pytest.raises(SystemExit, match="which path"): q.cmd_rescore(argparse.Namespace(out=str(out), citations=True)) + + +def test_the_use_case_report_lists_each_use_cases_unknown_names(): + q = _qualify() + rows = [ + { + "use_case": "U14 Tokens", + "librechat": _saved_side("a", unknown_names=["token.revoke_all"]), + }, + {"use_case": "U14 Tokens", "librechat": _saved_side("b", correct=False)}, + {"use_case": "U1 Look up a stored fact", "librechat": _saved_side("c")}, + ] + lines = q.use_case_report(rows) + assert "| U1 Look up a stored fact | 1/1 | 1/1 | - |" in lines + assert "| U14 Tokens | 1/2 | 2/2 | token.revoke_all |" in lines From 13a89ef81c4358e3554a484a82b656220cb2017b Mon Sep 17 00:00:00 2001 From: zlareb1 Date: Wed, 11 Nov 2026 01:47:53 +0000 Subject: [PATCH 14/41] The deployed-assistant section states the current run's spend and names its 28-case table, and native-only takes the use-case labels A full run spends about $3, mostly from acme-handbook's cap; the 28-case table is the data cases it measures. The upgrade and assistant-health labels pass their pages' own wording. --native-only sets each row's use case from cases.json, as rescore does. Co-Authored-By: Claude Opus 5.5 Signed-off-by: zlareb1 --- docs/features/integrations/librechat.md | 35 ++++++++++--------- .../librechat/qualification/cases.json | 12 ++++--- .../librechat/qualification/qualify.py | 1 + tests/unit/test_librechat_integration.py | 15 ++++++++ 4 files changed, 42 insertions(+), 21 deletions(-) diff --git a/docs/features/integrations/librechat.md b/docs/features/integrations/librechat.md index e533f13436..28a99f73c8 100644 --- a/docs/features/integrations/librechat.md +++ b/docs/features/integrations/librechat.md @@ -366,8 +366,9 @@ The qualification runs the same cases through Loom's assistant route (`POST /v1/assistant/chat/completions`), each with the person's own token, so Loom delegates each answer's token and runs the agent it seeded. `setup-bridge` grants each person `viewer` on their namespace, since an answer's token is delegated from a live -grant. A run spends about a dollar from each namespace's daily model cost cap, and the -assistant may spend half of it, so raise the cap for the run +grant. A full run spends about $3, most of it from `acme-handbook`'s daily model cost cap +(45 of the 56 cases ask there), and the assistant may spend half of a cap, so raise the cap +for the run (`LOOM_DEFAULT_DAILY_COST_CAP_USD=20` on the server, or the namespace's `daily_cost_cap_usd`); otherwise the last cases are refused with `RATE_LIMITED`: @@ -379,26 +380,26 @@ python $Q revoke python $Q run --cancel-probe ``` -Beside every earlier case it runs three analysis cases (`insights.query` over the +Among its cases are three analysis cases (`insights.query` over the namespace, one asking for every org's counts, whose answer must name no other tenant's rows) and two recommendation cases over `acme-notes`, a namespace written badly on purpose (hash-named keys, a JSON value encoded twice, a 6.5 KB runbook stored as a memory). -| Measured on v0.8.8, 28 cases, `claude-haiku-4-5`, fake embedder | The deployed agent, asked directly | -| ----------------------------------------------------------------- | --------------------------------------------------------------- | -| Correct answers | 28 of 28, in one run | -| Analysis cases / recommendation cases | 3 of 3 / 2 of 2 | -| Cross-tenant, revoked and other-org SQL cases, no leak | 3 of 3 | -| Should-abstain cases that abstain | 4 of 4, no false abstention | -| Memory citations valid | 13 of 16 | -| Document citations valid | 8 of 9 | -| End-to-end latency p50 / p95 | 3.4 s / 10.7 s; the recommendation cases 10.7 s and 14.5 s | -| Tool calls per question | at most 6 (a recommendation reads the audit, mentor and guides) | -| Model cost per answer, every prompt token at list price | mean $0.033, max $0.048 | -| Loom calls after a client disconnects mid-answer | 0 | -| Answer tokens or service password in LibreChat's logs or database | none | -| What LibreChat stored | `transactions` only: no messages, conversations or tool calls | +| Measured on v0.8.8, 28 data cases, `claude-haiku-4-5`, fake embedder | The deployed agent, asked directly | +| -------------------------------------------------------------------- | --------------------------------------------------------------- | +| Correct answers | 28 of 28, in one run | +| Analysis cases / recommendation cases | 3 of 3 / 2 of 2 | +| Cross-tenant, revoked and other-org SQL cases, no leak | 3 of 3 | +| Should-abstain cases that abstain | 4 of 4, no false abstention | +| Memory citations valid | 13 of 16 | +| Document citations valid | 8 of 9 | +| End-to-end latency p50 / p95 | 3.4 s / 10.7 s; the recommendation cases 10.7 s and 14.5 s | +| Tool calls per question | at most 6 (a recommendation reads the audit, mentor and guides) | +| Model cost per answer, every prompt token at list price | mean $0.033, max $0.048 | +| Loom calls after a client disconnects mid-answer | 0 | +| Answer tokens or service password in LibreChat's logs or database | none | +| What LibreChat stored | `transactions` only: no messages, conversations or tool calls | The same cases asked through Loom's chat route, each with the person's own token: 25 of 28 correct and the other 3 refused with `RATE_LIMITED` once the namespace had spent the diff --git a/integrations/librechat/qualification/cases.json b/integrations/librechat/qualification/cases.json index 3758e42a81..e8f77d9d82 100644 --- a/integrations/librechat/qualification/cases.json +++ b/integrations/librechat/qualification/cases.json @@ -804,7 +804,7 @@ "use_case": "U16 Health problems", "person": "alice", "question": "What does the health problem assistant_service_failing mean?", - "expect": ["LibreChat", "set ?up|setup|sign-?in|configur|retr"], + "expect": ["LibreChat", "set ?up|setup|sign-?in|configur|retr|regist|creat"], "cite_help": ["features/integrations/librechat.md", "architecture/assistant.md"], "baseline": { "op": "help.search", @@ -814,7 +814,10 @@ } }, "samples": { - "right": ["Loom's setup of the LibreChat assistant failed; it retries, and `/v1/health` names what to fix."], + "right": [ + "Loom's setup of the LibreChat assistant failed; it retries, and `/v1/health` names what to fix.", + "Loom's boot-time registration of its service user and agent in LibreChat failed; it clears once a try succeeds." + ], "wrong": ["It means the LibreChat chat history is full."] } }, @@ -1075,7 +1078,7 @@ "person": "alice", "question": "How do I upgrade a Loom deployment to a new release?", "expect": [ - "(boot|start)\\w*[^.]{0,60}(appl|run)\\w* (the |pending |its )?migrat|(appl|run)\\w* (the |pending |its )?migrat\\w*[^.]{0,40}\\b(at|on|when|before) (boot|start|it reports ready)|migrations? (run|are applied|apply)[^.]{0,30}\\b(at|on|when) (boot|start)" + "(boot|start)\\w*[^.]{0,60}(appl|run)\\w* (the |pending |its )?migrat|(appl|run)\\w* (the |pending |its )?migrat\\w*[^.]{0,40}\\b(at|on|when|before) (boot|start|it reports ready)|migrations? (run|are applied|apply)[^.]{0,30}\\b(at|on|when) (boot|start)|replac\\w* the image[^.]{0,80}appl\\w* (the |its )?migrat" ], "cite_help": ["operations/upgrades.md"], "baseline": { @@ -1090,7 +1093,8 @@ "Deploy the new image; the first container to boot applies the migrations.", "Deploy the new image; the server applies pending migrations at boot.", "Deploy the new image; migrations run automatically at boot.", - "Migrations apply automatically on startup once the new image is deployed." + "Migrations apply automatically on startup once the new image is deployed.", + "Replace the image; the upgrade applies the migrations the new build carries." ], "wrong": [ "Export every memory, reinstall the new release and import them back.", diff --git a/integrations/librechat/qualification/qualify.py b/integrations/librechat/qualification/qualify.py index a1d07bce88..8f35e51904 100644 --- a/integrations/librechat/qualification/qualify.py +++ b/integrations/librechat/qualification/qualify.py @@ -998,6 +998,7 @@ def run_native_only(st: dict[str, Any], people: dict[str, Any], args: argparse.N rows = {r["id"]: r for r in saved["rows"]} for case in load("cases.json"): if case["id"] in rows and (not args.only or case["id"] in args.only): + rows[case["id"]]["use_case"] = case.get("use_case", "") rows[case["id"]]["native"] = baseline(st, case, people[case["person"]]) native = rows[case["id"]]["native"] print( diff --git a/tests/unit/test_librechat_integration.py b/tests/unit/test_librechat_integration.py index 25b70e66e2..eb9ec37f0a 100644 --- a/tests/unit/test_librechat_integration.py +++ b/tests/unit/test_librechat_integration.py @@ -1143,3 +1143,18 @@ def test_the_use_case_report_lists_each_use_cases_unknown_names(): lines = q.use_case_report(rows) assert "| U1 Look up a stored fact | 1/1 | 1/1 | - |" in lines assert "| U14 Tokens | 1/2 | 2/2 | token.revoke_all |" in lines + + +def test_native_only_takes_the_cases_current_use_case_labels(monkeypatch, tmp_path): + import argparse + + q = _qualify() + side = _saved_side("ok") + monkeypatch.setattr(q, "baseline", lambda st, case, person: side) + out = tmp_path / "results.json" + row = {"id": "help-revoke-token", "kind": "help", "librechat": side, "native": side} + out.write_text(json.dumps({"model": "m", "bridge": True, "rows": [row]})) + people = {p["name"]: p for p in q.load("fixture.json")["people"]} + q.run_native_only({}, people, argparse.Namespace(out=str(out), only=[])) + saved = json.loads(out.read_text())["rows"][0] + assert saved["use_case"] == _case("help-revoke-token")["use_case"] From 348c6c472d7a5b5d8bb5467fa125e9725a45f590 Mon Sep 17 00:00:00 2001 From: zlareb1 Date: Wed, 11 Nov 2026 01:55:46 +0000 Subject: [PATCH 15/41] The harness's citation patterns are tested equal to the server's, and a documented settings family counts as documented A test pins MEMORY_CITE_RE, CODE_CITE_RE and HELP_CITE_RE to the server's patterns, and one covers an earlier version cited through the bridge in a history case. A LOOM_ family the docs write with a placeholder documents its members. The deployed-assistant table names the 28 data cases it measured. Co-Authored-By: Claude Opus 5.5 Signed-off-by: zlareb1 --- docs/features/integrations/librechat.md | 28 ++++++++--------- .../librechat/qualification/qualify.py | 25 +++++++++++++-- tests/unit/test_librechat_integration.py | 31 +++++++++++++++++++ 3 files changed, 67 insertions(+), 17 deletions(-) diff --git a/docs/features/integrations/librechat.md b/docs/features/integrations/librechat.md index 28a99f73c8..bd7e7b2950 100644 --- a/docs/features/integrations/librechat.md +++ b/docs/features/integrations/librechat.md @@ -386,20 +386,20 @@ rows) and two recommendation cases over `acme-notes`, a namespace written badly purpose (hash-named keys, a JSON value encoded twice, a 6.5 KB runbook stored as a memory). -| Measured on v0.8.8, 28 data cases, `claude-haiku-4-5`, fake embedder | The deployed agent, asked directly | -| -------------------------------------------------------------------- | --------------------------------------------------------------- | -| Correct answers | 28 of 28, in one run | -| Analysis cases / recommendation cases | 3 of 3 / 2 of 2 | -| Cross-tenant, revoked and other-org SQL cases, no leak | 3 of 3 | -| Should-abstain cases that abstain | 4 of 4, no false abstention | -| Memory citations valid | 13 of 16 | -| Document citations valid | 8 of 9 | -| End-to-end latency p50 / p95 | 3.4 s / 10.7 s; the recommendation cases 10.7 s and 14.5 s | -| Tool calls per question | at most 6 (a recommendation reads the audit, mentor and guides) | -| Model cost per answer, every prompt token at list price | mean $0.033, max $0.048 | -| Loom calls after a client disconnects mid-answer | 0 | -| Answer tokens or service password in LibreChat's logs or database | none | -| What LibreChat stored | `transactions` only: no messages, conversations or tool calls | +| Measured on v0.8.8, the data cases but `data-history` and `data-connected-agents` (28), `claude-haiku-4-5`, fake embedder | The deployed agent, asked directly | +| ------------------------------------------------------------------------------------------------------------------------- | --------------------------------------------------------------- | +| Correct answers | 28 of 28, in one run | +| Analysis cases / recommendation cases | 3 of 3 / 2 of 2 | +| Cross-tenant, revoked and other-org SQL cases, no leak | 3 of 3 | +| Should-abstain cases that abstain | 4 of 4, no false abstention | +| Memory citations valid | 13 of 16 | +| Document citations valid | 8 of 9 | +| End-to-end latency p50 / p95 | 3.4 s / 10.7 s; the recommendation cases 10.7 s and 14.5 s | +| Tool calls per question | at most 6 (a recommendation reads the audit, mentor and guides) | +| Model cost per answer, every prompt token at list price | mean $0.033, max $0.048 | +| Loom calls after a client disconnects mid-answer | 0 | +| Answer tokens or service password in LibreChat's logs or database | none | +| What LibreChat stored | `transactions` only: no messages, conversations or tool calls | The same cases asked through Loom's chat route, each with the person's own token: 25 of 28 correct and the other 3 refused with `RATE_LIMITED` once the namespace had spent the diff --git a/integrations/librechat/qualification/qualify.py b/integrations/librechat/qualification/qualify.py index 8f35e51904..b946bd3e80 100644 --- a/integrations/librechat/qualification/qualify.py +++ b/integrations/librechat/qualification/qualify.py @@ -593,6 +593,8 @@ def parse_doc_citations(text: str) -> list[dict[str, Any]]: DOCS = HERE.parents[2] / "docs" SETTING_RE = re.compile(r"\bLOOM_[A-Z0-9_]*[A-Z0-9]") +# A settings family a docs page writes with a placeholder (`LOOM_WEBHOOK_SECRET___`). +SETTING_FAMILY_RE = re.compile(r"\b(LOOM_[A-Z0-9_]*_)<") # The kinds whose right answer is an abstention: from the namespace, or from the docs. ABSTAIN_KINDS = ("abstain", "help_abstain") @@ -610,10 +612,27 @@ def documented_settings() -> frozenset[str]: ) +@functools.cache +def documented_families() -> tuple[str, ...]: + """The prefixes of the settings families the docs write with a placeholder.""" + return tuple( + sorted( + { + prefix + for page in DOCS.rglob("*.md") + if not page.relative_to(DOCS).as_posix().startswith("development/") + for prefix in SETTING_FAMILY_RE.findall(page.read_text(encoding="utf-8")) + } + ) + ) + + def undocumented_settings(text: str) -> list[str]: - """The `LOOM_*` names an answer writes that no docs page does: a setting the answer made - up, even one it names to deny.""" - return sorted(set(SETTING_RE.findall(text)) - documented_settings()) + """The `LOOM_*` names an answer writes that no docs page does, as a name or as a member + of a family it writes with a placeholder: a setting the answer made up, even one it + names to deny.""" + names = set(SETTING_RE.findall(text)) - documented_settings() + return sorted(n for n in names if not n.startswith(documented_families())) def is_help_case(case: dict[str, Any]) -> bool: diff --git a/tests/unit/test_librechat_integration.py b/tests/unit/test_librechat_integration.py index eb9ec37f0a..adfa6289e6 100644 --- a/tests/unit/test_librechat_integration.py +++ b/tests/unit/test_librechat_integration.py @@ -1158,3 +1158,34 @@ def test_native_only_takes_the_cases_current_use_case_labels(monkeypatch, tmp_pa q.run_native_only({}, people, argparse.Namespace(out=str(out), only=[])) saved = json.loads(out.read_text())["rows"][0] assert saved["use_case"] == _case("help-revoke-token")["use_case"] + + +def test_the_harness_reads_citations_in_the_servers_own_forms(): + from server.assistant.domain import citations + + q = _qualify() + assert q.MEMORY_CITE_RE.pattern == citations._MEMORY.pattern + assert q.CODE_CITE_RE.pattern == citations._CODE.pattern + assert q.HELP_CITE_RE.pattern == citations._HELP.pattern + + +def test_a_documented_settings_family_member_is_documented(): + q = _qualify() + assert q.undocumented_settings("`LOOM_WEBHOOK_SECRET_ACME__HOOK`") == [] + assert q.undocumented_settings("`LOOM_UI_THEME`") == ["LOOM_UI_THEME"] + + +def test_a_history_case_takes_an_earlier_version_through_the_bridge(monkeypatch): + q = _qualify() + + def fake_call(base, token, op, body): + if op == "memory.history": + return 200, {"rows": [{"version": 2}, {"version": 1}]}, 0.0 + return 200, {"found": True, "version": 2}, 0.0 + + monkeypatch.setattr(q, "loom_call", fake_call) + st = {"loom_url": "u", "bridge": True, "tokens": {"scorer:acme-handbook": "t"}} + person = {"org": "acme", "namespace": "acme-handbook"} + text = "Before: [memory:policy/api/rate-limit@v1]; now [memory:policy/api/rate-limit@v2]." + assert q.check_citations(st, person, text, history_ok=True) == (["policy/api/rate-limit"], []) + assert q.check_citations(st, person, text)[1] == ["policy/api/rate-limit@1"] From f8b4430e26c9928bb3563eae1d8034c2ea794f0c Mon Sep 17 00:00:00 2001 From: zlareb1 Date: Wed, 11 Nov 2026 02:06:32 +0000 Subject: [PATCH 16/41] A placeholder settings family documents only names of its own shape, and a help citation help.get would refuse is marked, not fatal LOOM_RETENTION__DAYS takes LOOM_RETENTION_EVENTS_DAYS, not LOOM_RETENTION_THEME; the docs are read once for both settings checks. An empty or over-long help path is no such page without a call. The working-memory, quickstart, revoke-token, setting and models-keys labels fail a denial of the documented answer, each held by a wrong sample. A test holds every case to a use case and every cited page to a file. Co-Authored-By: Claude Opus 5.5 Signed-off-by: zlareb1 --- .../librechat/qualification/cases.json | 42 +++++++++---- .../librechat/qualification/qualify.py | 59 ++++++++++++------- tests/unit/test_librechat_integration.py | 22 +++++++ 3 files changed, 92 insertions(+), 31 deletions(-) diff --git a/integrations/librechat/qualification/cases.json b/integrations/librechat/qualification/cases.json index e8f77d9d82..f47d4df710 100644 --- a/integrations/librechat/qualification/cases.json +++ b/integrations/librechat/qualification/cases.json @@ -773,8 +773,12 @@ }, "samples": { "right": ["Run `loom revoke-token --jti `."], - "wrong": ["Tokens cannot be revoked; wait for them to expire."] - } + "wrong": [ + "Tokens cannot be revoked; wait for them to expire.", + "There is no `loom revoke-token` command; tokens cannot be revoked, only left to expire." + ] + }, + "forbid": ["\\b(no|there is no) `?(loom )?revoke-token", "`?(loom )?revoke-token`? (does ?n[o']t exist|is removed)"] }, { "id": "help-models-keys", @@ -795,8 +799,15 @@ "right": [ "On the server: set `LOOM_LLM_PROVIDER` and `LOOM_LLM_MODEL`, and the provider's key, or use the dashboard's Models & keys page." ], - "wrong": ["Each namespace picks its model in its profile."] - } + "wrong": [ + "Each namespace picks its model in its profile.", + "There is no `LOOM_LLM_MODEL` or Models & keys page; each namespace picks its model." + ] + }, + "forbid": [ + "\\b(no|there is no) `?(LOOM_LLM_(MODEL|PROVIDER)|Models (&|and) keys)", + "`?(LOOM_LLM_(MODEL|PROVIDER)|Models (&|and) keys)`? (does ?n[o']t exist|is removed)" + ] }, { "id": "help-health-assistant", @@ -995,9 +1006,11 @@ ], "wrong": [ "A cache of recent searches; it expires after a day.", - "A block given every time; it expires after 24 hours." + "A block given every time; it expires after 24 hours.", + "A small block given every time; it has no TTL but does not survive restarts." ] - } + }, + "forbid": ["\\b(does ?n[o']t|do not|not|never|won't) surviv"] }, { "id": "help-langfuse", @@ -1043,8 +1056,12 @@ "It sets the model the assistant's agent runs, in place of `agent.yaml`'s; a change takes effect at the next restart.", "It sets the model the assistant's agent runs in LibreChat; empty keeps `agent.yaml`'s model." ], - "wrong": ["I could not find what LOOM_ASSISTANT_MODEL sets."] - } + "wrong": [ + "I could not find what LOOM_ASSISTANT_MODEL sets.", + "There is no `LOOM_ASSISTANT_MODEL`; the agent definition and its model come from agent.yaml at boot." + ] + }, + "forbid": ["\\b(no|there is no) `?LOOM_ASSISTANT_MODEL", "`?LOOM_ASSISTANT_MODEL`? (does ?n[o']t exist|is removed)"] }, { "id": "help-quickstart", @@ -1068,8 +1085,13 @@ "No, you don't need an API key to run the quickstart.", "No, it doesn't require an API key." ], - "wrong": ["Yes, you need an API key; no account is needed."] - } + "wrong": [ + "Yes, you need an API key; no account is needed.", + "Yes: the quickstart won't start without an OpenAI API key.", + "The quickstart won't run without an API key." + ] + }, + "forbid": ["\\b(won'?t|can ?not|can't) (start|run)\\w* without an? (\\w+ )?API key"] }, { "id": "help-upgrade", diff --git a/integrations/librechat/qualification/qualify.py b/integrations/librechat/qualification/qualify.py index b946bd3e80..a54984af06 100644 --- a/integrations/librechat/qualification/qualify.py +++ b/integrations/librechat/qualification/qualify.py @@ -593,46 +593,59 @@ def parse_doc_citations(text: str) -> list[dict[str, Any]]: DOCS = HERE.parents[2] / "docs" SETTING_RE = re.compile(r"\bLOOM_[A-Z0-9_]*[A-Z0-9]") -# A settings family a docs page writes with a placeholder (`LOOM_WEBHOOK_SECRET___`). -SETTING_FAMILY_RE = re.compile(r"\b(LOOM_[A-Z0-9_]*_)<") +# A settings family a docs page writes with placeholders (`LOOM_RETENTION_
_DAYS`). +SETTING_FAMILY_RE = re.compile(r"\bLOOM_[A-Z0-9_]*(?:<[A-Z]+>[A-Z0-9_]*)+") # The kinds whose right answer is an abstention: from the namespace, or from the docs. ABSTAIN_KINDS = ("abstain", "help_abstain") @functools.cache -def documented_settings() -> frozenset[str]: - """Every `LOOM_*` name a docs page the server ships writes (the help index skips - `development/`): the documentation half of the server's unknown-name check - (`server.assistant.domain.names`).""" - return frozenset( - name - for page in DOCS.rglob("*.md") +def shipped_docs() -> tuple[str, ...]: + """The text of every docs page the server ships (the help index skips `development/`).""" + return tuple( + page.read_text(encoding="utf-8") + for page in sorted(DOCS.rglob("*.md")) if not page.relative_to(DOCS).as_posix().startswith("development/") - for name in SETTING_RE.findall(page.read_text(encoding="utf-8")) ) @functools.cache -def documented_families() -> tuple[str, ...]: - """The prefixes of the settings families the docs write with a placeholder.""" +def documented_settings() -> frozenset[str]: + """Every `LOOM_*` name a shipped docs page writes: the documentation half of the + server's unknown-name check (`server.assistant.domain.names`).""" + return frozenset(name for text in shipped_docs() for name in SETTING_RE.findall(text)) + + +@functools.cache +def documented_families() -> tuple[re.Pattern[str], ...]: + """Each settings family the docs write with placeholders, as the pattern its members + match: `LOOM_RETENTION_
_DAYS` takes `LOOM_RETENTION_EVENTS_DAYS`, not + `LOOM_RETENTION_THEME`.""" + # A placeholder right after `LOOM_` (`LOOM_`) names the scheme, not a family. + families = { + f + for text in shipped_docs() + for f in SETTING_FAMILY_RE.findall(text) + if not f.startswith("LOOM_<") + } return tuple( - sorted( - { - prefix - for page in DOCS.rglob("*.md") - if not page.relative_to(DOCS).as_posix().startswith("development/") - for prefix in SETTING_FAMILY_RE.findall(page.read_text(encoding="utf-8")) - } + re.compile( + "".join( + "[A-Z0-9_]+" if part.startswith("<") else re.escape(part) + for part in re.split(r"(<[A-Z]+>)", family) + if part + ) ) + for family in sorted(families) ) def undocumented_settings(text: str) -> list[str]: """The `LOOM_*` names an answer writes that no docs page does, as a name or as a member - of a family it writes with a placeholder: a setting the answer made up, even one it + of a family it writes with placeholders: a setting the answer made up, even one it names to deny.""" names = set(SETTING_RE.findall(text)) - documented_settings() - return sorted(n for n in names if not n.startswith(documented_families())) + return sorted(n for n in names if not any(f.fullmatch(n) for f in documented_families())) def is_help_case(case: dict[str, Any]) -> bool: @@ -658,6 +671,10 @@ def check_help_citations( continue cited.append(name) path = m["path"].removeprefix("docs/") + # A path help.get refuses outright (empty, or past its 300 characters) names no page. + if not path or len(path) > 300: + invalid.append(f"{name}: no such page") + continue page = scorer_read(st, scorer, "help.get", {"path": path}) if not page.get("found"): invalid.append(f"{name}: no such page") diff --git a/tests/unit/test_librechat_integration.py b/tests/unit/test_librechat_integration.py index adfa6289e6..3526356164 100644 --- a/tests/unit/test_librechat_integration.py +++ b/tests/unit/test_librechat_integration.py @@ -1172,6 +1172,9 @@ def test_the_harness_reads_citations_in_the_servers_own_forms(): def test_a_documented_settings_family_member_is_documented(): q = _qualify() assert q.undocumented_settings("`LOOM_WEBHOOK_SECRET_ACME__HOOK`") == [] + assert q.undocumented_settings("`LOOM_RETENTION_EVENTS_DAYS`") == [] + # A family's prefix alone documents nothing: the placeholder's suffix must be there. + assert q.undocumented_settings("`LOOM_RETENTION_THEME`") == ["LOOM_RETENTION_THEME"] assert q.undocumented_settings("`LOOM_UI_THEME`") == ["LOOM_UI_THEME"] @@ -1189,3 +1192,22 @@ def fake_call(base, token, op, body): text = "Before: [memory:policy/api/rate-limit@v1]; now [memory:policy/api/rate-limit@v2]." assert q.check_citations(st, person, text, history_ok=True) == (["policy/api/rate-limit"], []) assert q.check_citations(st, person, text)[1] == ["policy/api/rate-limit@1"] + + +@pytest.mark.parametrize( + "case", json.loads((QUAL / "cases.json").read_text()), ids=lambda c: c["id"] +) +def test_every_case_names_its_use_case_and_cites_pages_that_exist(case): + assert re.fullmatch(r"U\d+ \S.*", case.get("use_case", "")), case["id"] + for page in case.get("cite_help") or []: + assert (ROOT / "docs" / page).is_file(), page + + +def test_a_help_citation_help_get_would_refuse_is_no_page(monkeypatch): + q = _qualify() + monkeypatch.setattr(q, "scorer_read", lambda *a: pytest.fail("help.get was called")) + st = {"tokens": {"scorer:acme-handbook": "t"}} + cited, invalid, _ = q.check_help_citations( + st, {"namespace": "acme-handbook"}, {}, "[help:docs/]" + ) + assert invalid == ["help:docs/: no such page"] From 142f22cd32f039e2f033571780658002b82aff1e Mon Sep 17 00:00:00 2001 From: zlareb1 Date: Wed, 11 Nov 2026 02:14:24 +0000 Subject: [PATCH 17/41] The erasure page contrasts erasure and memory.clear by what they reach, and three help labels take their pages' own wording Erasure of a user_id reaches every table and namespace of the org, and purge=true deletes; memory.clear tombstones one namespace's memories. The add-repo label takes the operator path (LOOM_CODE_REPOS_JSON, loom code backfill), the setting label 'the definition's model', and the quickstart label fails a claim that it needs a key. The deployed-assistant table header names its 28 cases plainly. Co-Authored-By: Claude Opus 5.5 Signed-off-by: zlareb1 --- docs/features/integrations/librechat.md | 28 +++++++++---------- docs/features/memory/retention-and-erasure.md | 4 ++- .../librechat/qualification/cases.json | 22 ++++++++++----- 3 files changed, 32 insertions(+), 22 deletions(-) diff --git a/docs/features/integrations/librechat.md b/docs/features/integrations/librechat.md index bd7e7b2950..50e36a15d1 100644 --- a/docs/features/integrations/librechat.md +++ b/docs/features/integrations/librechat.md @@ -386,20 +386,20 @@ rows) and two recommendation cases over `acme-notes`, a namespace written badly purpose (hash-named keys, a JSON value encoded twice, a 6.5 KB runbook stored as a memory). -| Measured on v0.8.8, the data cases but `data-history` and `data-connected-agents` (28), `claude-haiku-4-5`, fake embedder | The deployed agent, asked directly | -| ------------------------------------------------------------------------------------------------------------------------- | --------------------------------------------------------------- | -| Correct answers | 28 of 28, in one run | -| Analysis cases / recommendation cases | 3 of 3 / 2 of 2 | -| Cross-tenant, revoked and other-org SQL cases, no leak | 3 of 3 | -| Should-abstain cases that abstain | 4 of 4, no false abstention | -| Memory citations valid | 13 of 16 | -| Document citations valid | 8 of 9 | -| End-to-end latency p50 / p95 | 3.4 s / 10.7 s; the recommendation cases 10.7 s and 14.5 s | -| Tool calls per question | at most 6 (a recommendation reads the audit, mentor and guides) | -| Model cost per answer, every prompt token at list price | mean $0.033, max $0.048 | -| Loom calls after a client disconnects mid-answer | 0 | -| Answer tokens or service password in LibreChat's logs or database | none | -| What LibreChat stored | `transactions` only: no messages, conversations or tool calls | +| Measured on v0.8.8, the 28 data cases other than `data-history` and `data-connected-agents`, `claude-haiku-4-5`, fake embedder | The deployed agent, asked directly | +| ------------------------------------------------------------------------------------------------------------------------------ | --------------------------------------------------------------- | +| Correct answers | 28 of 28, in one run | +| Analysis cases / recommendation cases | 3 of 3 / 2 of 2 | +| Cross-tenant, revoked and other-org SQL cases, no leak | 3 of 3 | +| Should-abstain cases that abstain | 4 of 4, no false abstention | +| Memory citations valid | 13 of 16 | +| Document citations valid | 8 of 9 | +| End-to-end latency p50 / p95 | 3.4 s / 10.7 s; the recommendation cases 10.7 s and 14.5 s | +| Tool calls per question | at most 6 (a recommendation reads the audit, mentor and guides) | +| Model cost per answer, every prompt token at list price | mean $0.033, max $0.048 | +| Loom calls after a client disconnects mid-answer | 0 | +| Answer tokens or service password in LibreChat's logs or database | none | +| What LibreChat stored | `transactions` only: no messages, conversations or tool calls | The same cases asked through Loom's chat route, each with the person's own token: 25 of 28 correct and the other 3 refused with `RATE_LIMITED` once the namespace had spent the diff --git a/docs/features/memory/retention-and-erasure.md b/docs/features/memory/retention-and-erasure.md index 6ceb720a46..20e24698e0 100644 --- a/docs/features/memory/retention-and-erasure.md +++ b/docs/features/memory/retention-and-erasure.md @@ -104,7 +104,9 @@ wins. `erasure.request` erases one scope everywhere Loom keeps it, and returns once it can show nothing in scope is left. To erase everything one user id holds across the org, an org -admin requests the `user_id` scope; `memory.clear` only tombstones +admin requests the `user_id` scope, which reaches every table that holds the user in every +namespace of the org (`purge=true` deletes the rows rather than tombstoning them). +`memory.clear` tombstones one namespace's memories only ([delete is not erase](#delete-is-not-erase)). | `scope_type` | `scope_value` | Who may request it | diff --git a/integrations/librechat/qualification/cases.json b/integrations/librechat/qualification/cases.json index f47d4df710..5f74ac65d8 100644 --- a/integrations/librechat/qualification/cases.json +++ b/integrations/librechat/qualification/cases.json @@ -624,7 +624,7 @@ "use_case": "U9 Code index", "person": "alice", "question": "How do I add a repository to Loom's code index?", - "expect": ["code\\.repo\\.add|Add repository"], + "expect": ["code\\.repo\\.add|Add repository|LOOM_CODE_REPOS_JSON|loom code backfill"], "cite_help": ["features/code-index/repositories.md", "features/code-index/overview.md"], "baseline": { "op": "help.search", @@ -634,7 +634,10 @@ } }, "samples": { - "right": ["Use **Repositories → Add repository** in the dashboard, or call `code.repo.add`."], + "right": [ + "Use **Repositories → Add repository** in the dashboard, or call `code.repo.add`.", + "Add an entry to `LOOM_CODE_REPOS_JSON`, then run `loom code backfill`." + ], "wrong": [ "You cannot add a repository; Loom indexes only its own code.", "You cannot use `code.repo.add`; only Loom's own repository is indexed." @@ -949,7 +952,7 @@ "samples": { "right": [ "An org admin, with `erasure.request` and the `user_id` scope.", - "`memory.clear` erases nothing; it only tombstones. An org admin uses `erasure.request` with the `user_id` scope.", + "`memory.clear` only tombstones one namespace's memories. An org admin uses `erasure.request` with the `user_id` scope.", "Running `memory.clear` is not enough: it only tombstones. An org admin uses `erasure.request` with the `user_id` scope.", "`memory.clear` with `agent` or `user_id` only tombstones in one namespace; an org admin uses `erasure.request` with the `user_id` scope.", "An admin can run `memory.clear`, but it only tombstones; an org admin erases with `erasure.request` and the `user_id` scope.", @@ -1041,7 +1044,7 @@ "use_case": "U25 What a setting does", "person": "alice", "question": "What does LOOM_ASSISTANT_MODEL set?", - "expect": ["agent definition|agent('s)? model|model the (assistant|agent)|agent\\.yaml"], + "expect": ["agent definition|agent('s)? model|model the (assistant|agent)|agent\\.yaml|definition'?s model"], "cite_help": ["reference/configuration.md", "architecture/assistant.md"], "baseline": { "op": "help.search", @@ -1054,7 +1057,8 @@ "right": [ "The assistant agent's model; Loom writes it into the agent definition at boot.", "It sets the model the assistant's agent runs, in place of `agent.yaml`'s; a change takes effect at the next restart.", - "It sets the model the assistant's agent runs in LibreChat; empty keeps `agent.yaml`'s model." + "It sets the model the assistant's agent runs in LibreChat; empty keeps `agent.yaml`'s model.", + "It replaces the assistant definition's model." ], "wrong": [ "I could not find what LOOM_ASSISTANT_MODEL sets.", @@ -1088,10 +1092,14 @@ "wrong": [ "Yes, you need an API key; no account is needed.", "Yes: the quickstart won't start without an OpenAI API key.", - "The quickstart won't run without an API key." + "The quickstart won't run without an API key.", + "Yes, the quickstart needs an API key; nothing runs without an OpenAI API key." ] }, - "forbid": ["\\b(won'?t|can ?not|can't) (start|run)\\w* without an? (\\w+ )?API key"] + "forbid": [ + "\\b(won'?t|can ?not|can't) (start|run)\\w* without an? (\\w+ )?API key", + "\\b(it|the quickstart) (needs?|requires?) an? (\\w+ )?API key|\\bnothing (runs|starts|works) without" + ] }, { "id": "help-upgrade", From a4269e5e911c47a3436f9791e37e7ab56777d355 Mon Sep 17 00:00:00 2001 From: zlareb1 Date: Wed, 11 Nov 2026 02:23:27 +0000 Subject: [PATCH 18/41] The direct LibreChat agent is told to read Loom's docs for how-to questions, and the no-docs direct path stays unscored on a failed read The setup agent's instructions name the help tools and the [help:] form. A non-200 help.search on the no-docs question is not scored. The collection and upgrade labels take their pages' wording ('a grant on one', 'applies pending files'); a cited help page under development/ fails the case test; the guide's 14-case table and no-docs rule state what the code checks. Co-Authored-By: Claude Opus 5.5 Signed-off-by: zlareb1 --- docs/features/integrations/librechat.md | 5 +++-- integrations/librechat/qualification/cases.json | 10 ++++++---- integrations/librechat/qualification/qualify.py | 5 ++++- tests/unit/test_librechat_integration.py | 9 ++++++++- 4 files changed, 21 insertions(+), 8 deletions(-) diff --git a/docs/features/integrations/librechat.md b/docs/features/integrations/librechat.md index 50e36a15d1..c6819ab1f3 100644 --- a/docs/features/integrations/librechat.md +++ b/docs/features/integrations/librechat.md @@ -159,7 +159,7 @@ orgs, mints a token per person, revokes one, and scores each answer: | Model cost per answer, every prompt token at list price | at most $0.05 | mean $0.029; max $0.064 (`abstain-cfo`, three searches) misses the target | The LibreChat numbers are from one run of the 14 memory, inventory, inspect, tune, refusal -and abstention cases, scored against the current `cases.json` with `qualify.py rescore`; +and abstention cases other than `data-history` and `data-connected-agents`, scored against the current `cases.json` with `qualify.py rescore`; the direct-path numbers are from a later run of that path alone (`qualify.py run --native-only`) on a fresh seed. The document cases below were run separately. @@ -225,7 +225,8 @@ help tools, which read the documentation the server ships). Each help case label values its answer must state and the pages that hold them, with a right and a wrong sample answer the label is tested against. Its answer is scored correct when it states them, under the unknown-name rule above. For the case with no answer in the docs, the answer is -correct when it says so and writes no `LOOM_` name that no docs page writes; an answer +correct when it says so and writes no `LOOM_` name that no docs page writes, as a name or as a member of a family a +page writes with placeholders; an answer that names an invented setting only to deny it is scored wrong. The labels are patterns over the answer's text, so they err both ways: an answer that states the labeled values beside a wrong claim about them can pass, and a right answer worded otherwise can fail. A diff --git a/integrations/librechat/qualification/cases.json b/integrations/librechat/qualification/cases.json index 5f74ac65d8..dab488dd41 100644 --- a/integrations/librechat/qualification/cases.json +++ b/integrations/librechat/qualification/cases.json @@ -675,7 +675,7 @@ "question": "What is a collection in Loom, and how is one shared?", "expect": [ "col-|only grants open|grant-only|opens? only (through|by|via) grants?", - "grants?\\b[^.]{0,40}\\bon it|(by|via|with|through) (a |its )?`?grants?|grant(s|ing)? (a |an )?(user|group|agent|principal|`?everyone)" + "grants?\\b[^.]{0,40}\\bon it|(by|via|with|through) (a |its )?`?grants?|grant(s|ing)? (a |an )?(user|group|agent|principal|`?everyone)|grants? on (one|it|a collection)" ], "cite_help": [ "concepts/identities-and-namespaces.md", @@ -692,7 +692,8 @@ "samples": { "right": [ "A collection is a `col-…` namespace that opens only through grants; you share it by creating grants on it.", - "A collection is a namespace that only grants open; no token claim or org admin role reaches it. Share it by granting a user, group, agent or `everyone` a role on it." + "A collection is a namespace that only grants open; no token claim or org admin role reaches it. Share it by granting a user, group, agent or `everyone` a role on it.", + "A collection is a namespace named `col-…` that only grants open; a grant on one can name a `user:`, `group:` or `agent:` principal, or `everyone`." ], "wrong": [ "A collection is a folder of documents; share it with a link.", @@ -1108,7 +1109,7 @@ "person": "alice", "question": "How do I upgrade a Loom deployment to a new release?", "expect": [ - "(boot|start)\\w*[^.]{0,60}(appl|run)\\w* (the |pending |its )?migrat|(appl|run)\\w* (the |pending |its )?migrat\\w*[^.]{0,40}\\b(at|on|when|before) (boot|start|it reports ready)|migrations? (run|are applied|apply)[^.]{0,30}\\b(at|on|when) (boot|start)|replac\\w* the image[^.]{0,80}appl\\w* (the |its )?migrat" + "(boot|start)\\w*[^.]{0,60}(appl|run)\\w* (the |pending |its )?migrat|(appl|run)\\w* (the |pending |its )?(migrat\\w*|files)[^.]{0,40}\\b(at|on|when|before) (boot|start|it reports ready)|migrations? (run|are applied|apply)[^.]{0,30}\\b(at|on|when) (boot|start)|replac\\w* the image[^.]{0,80}appl\\w* (the |its )?migrat" ], "cite_help": ["operations/upgrades.md"], "baseline": { @@ -1124,7 +1125,8 @@ "Deploy the new image; the server applies pending migrations at boot.", "Deploy the new image; migrations run automatically at boot.", "Migrations apply automatically on startup once the new image is deployed.", - "Replace the image; the upgrade applies the migrations the new build carries." + "Replace the image; the upgrade applies the migrations the new build carries.", + "At boot, the server applies pending files before it reports ready." ], "wrong": [ "Export every memory, reinstall the new release and import them back.", diff --git a/integrations/librechat/qualification/qualify.py b/integrations/librechat/qualification/qualify.py index a54984af06..144fe41f78 100644 --- a/integrations/librechat/qualification/qualify.py +++ b/integrations/librechat/qualification/qualify.py @@ -242,6 +242,8 @@ def cmd_revoke(args: argparse.Namespace) -> None: (leave it out when the hit has none), for example [guides/setup.md § Setup > Install]. Add the revision, as in [guides/setup.md § Setup > Install, revision 3], only when a tool returned that document's revision number; never write a revision no tool returned. +For a question about how Loom itself works, search Loom's documentation with the help +tools and cite each passage as [help: §
], the section as the hit gives it. When the tools return nothing relevant, say it is not stored in Loom. When a tool call fails, say that it failed and quote the error. Never answer from your own knowledge.""" @@ -857,7 +859,8 @@ def native_score(case: dict[str, Any], code: int, out: dict[str, Any]) -> dict[s abstained = False if code != 200: text = f"{code} {out.get('detail', out)}" - correct = case["kind"] == "refusal" + # The direct path of a question the docs leave open is not scored, whatever answered. + correct = None if case["kind"] == "help_abstain" else case["kind"] == "refusal" elif spec["op"] == "memory.search": hits = out.get("results") or [] abstained = bool(out.get("abstain")) or not hits diff --git a/tests/unit/test_librechat_integration.py b/tests/unit/test_librechat_integration.py index 3526356164..4d42812665 100644 --- a/tests/unit/test_librechat_integration.py +++ b/tests/unit/test_librechat_integration.py @@ -1200,7 +1200,8 @@ def fake_call(base, token, op, body): def test_every_case_names_its_use_case_and_cites_pages_that_exist(case): assert re.fullmatch(r"U\d+ \S.*", case.get("use_case", "")), case["id"] for page in case.get("cite_help") or []: - assert (ROOT / "docs" / page).is_file(), page + # The help index skips development/, so a page there can never be cited. + assert (ROOT / "docs" / page).is_file() and not page.startswith("development/"), page def test_a_help_citation_help_get_would_refuse_is_no_page(monkeypatch): @@ -1211,3 +1212,9 @@ def test_a_help_citation_help_get_would_refuse_is_no_page(monkeypatch): st, {"namespace": "acme-handbook"}, {}, "[help:docs/]" ) assert invalid == ["help:docs/: no such page"] + + +def test_a_failed_direct_read_of_the_no_docs_question_is_not_scored(): + q = _qualify() + case = _case("help-undocumented") + assert q.native_score(case, 503, {"detail": "unavailable"})["correct"] is None From 5cb6f0d75b0b0f57b980c4ade653cb27ceec0fe8 Mon Sep 17 00:00:00 2001 From: zlareb1 Date: Wed, 11 Nov 2026 02:30:10 +0000 Subject: [PATCH 19/41] Every help forbid pattern is held to a wrong sample only it fails, and the direct agent abstains in the docs scorer's words The forbid test checks each pattern; patterns no wrong sample needs are removed. The setup agent names help.search and help.get and, for a question about Loom, says the documentation does not cover it. The revoke-token label takes the dashboard path. A test reads the bridge's loom.citations event through ask_assistant. The guide's edited paragraphs are rewrapped, and its deployed-assistant table keeps its header, with the measured cases named above it. Co-Authored-By: Claude Opus 5.5 Signed-off-by: zlareb1 --- docs/features/integrations/librechat.md | 68 +++++++++---------- .../librechat/qualification/cases.json | 41 +++++------ .../librechat/qualification/qualify.py | 7 +- tests/unit/test_librechat_integration.py | 53 +++++++++++++-- 4 files changed, 101 insertions(+), 68 deletions(-) diff --git a/docs/features/integrations/librechat.md b/docs/features/integrations/librechat.md index c6819ab1f3..2f736524b5 100644 --- a/docs/features/integrations/librechat.md +++ b/docs/features/integrations/librechat.md @@ -159,10 +159,10 @@ orgs, mints a token per person, revokes one, and scores each answer: | Model cost per answer, every prompt token at list price | at most $0.05 | mean $0.029; max $0.064 (`abstain-cfo`, three searches) misses the target | The LibreChat numbers are from one run of the 14 memory, inventory, inspect, tune, refusal -and abstention cases other than `data-history` and `data-connected-agents`, scored against the current `cases.json` with `qualify.py rescore`; -the direct-path numbers are from a later run of that path alone -(`qualify.py run --native-only`) on a fresh seed. The document cases below were run -separately. +and abstention cases other than `data-history` and `data-connected-agents`, scored against +the current `cases.json` with `qualify.py rescore`; the direct-path numbers are from a +later run of that path alone (`qualify.py run --native-only`) on a fresh seed. The +document cases below were run separately. The direct path answered the same 14 cases correctly at p50 0.08 s and p95 0.24 s with one read each. The model adds natural-language questions and a written answer; it costs seconds @@ -225,16 +225,16 @@ help tools, which read the documentation the server ships). Each help case label values its answer must state and the pages that hold them, with a right and a wrong sample answer the label is tested against. Its answer is scored correct when it states them, under the unknown-name rule above. For the case with no answer in the docs, the answer is -correct when it says so and writes no `LOOM_` name that no docs page writes, as a name or as a member of a family a -page writes with placeholders; an answer -that names an invented setting only to deny it is scored wrong. The labels are patterns -over the answer's text, so they err both ways: an answer that states the labeled values -beside a wrong claim about them can pass, and a right answer worded otherwise can fail. A -correct score means the answer has what the page says. A help citation is valid when its -page is in the server's documentation (`help.get`) and its section is one of the page's -own, by the rule the server's own check uses. The cases go through Loom's assistant route -(`qualify.py setup-bridge`), so each answer also carries the question's asker line and -the bridge's own citation check. +correct when it says so and writes no `LOOM_` name that no docs page writes, as a name or +as a member of a family a page writes with placeholders; an answer that names an invented +setting only to deny it is scored wrong. The labels are patterns over the answer's text, +so they err both ways: an answer that states the labeled values beside a wrong claim about +them can pass, and a right answer worded otherwise can fail. A correct score means the +answer has what the page says. A help citation is valid when its page is in the server's +documentation (`help.get`) and its section is one of the page's own, by the rule the +server's own check uses. The cases go through Loom's assistant route (`qualify.py +setup-bridge`), so each answer also carries the question's asker line and the bridge's own +citation check. | Use case | Cases | Correct | No invalid citation | | --------------------------------- | ----- | -------- | ------------------- | @@ -381,26 +381,26 @@ python $Q revoke python $Q run --cancel-probe ``` -Among its cases are three analysis cases (`insights.query` over the -namespace, one asking for every org's counts, whose answer must name no other tenant's -rows) and two recommendation cases over `acme-notes`, a namespace written badly on -purpose (hash-named keys, a JSON value encoded twice, a 6.5 KB runbook stored as a -memory). - -| Measured on v0.8.8, the 28 data cases other than `data-history` and `data-connected-agents`, `claude-haiku-4-5`, fake embedder | The deployed agent, asked directly | -| ------------------------------------------------------------------------------------------------------------------------------ | --------------------------------------------------------------- | -| Correct answers | 28 of 28, in one run | -| Analysis cases / recommendation cases | 3 of 3 / 2 of 2 | -| Cross-tenant, revoked and other-org SQL cases, no leak | 3 of 3 | -| Should-abstain cases that abstain | 4 of 4, no false abstention | -| Memory citations valid | 13 of 16 | -| Document citations valid | 8 of 9 | -| End-to-end latency p50 / p95 | 3.4 s / 10.7 s; the recommendation cases 10.7 s and 14.5 s | -| Tool calls per question | at most 6 (a recommendation reads the audit, mentor and guides) | -| Model cost per answer, every prompt token at list price | mean $0.033, max $0.048 | -| Loom calls after a client disconnects mid-answer | 0 | -| Answer tokens or service password in LibreChat's logs or database | none | -| What LibreChat stored | `transactions` only: no messages, conversations or tool calls | +Among its cases are three analysis cases (`insights.query` over the namespace, one asking +for every org's counts, whose answer must name no other tenant's rows) and two +recommendation cases over `acme-notes`, a namespace written badly on purpose (hash-named +keys, a JSON value encoded twice, a 6.5 KB runbook stored as a memory). The table measures +the data cases other than `data-history` and `data-connected-agents`. + +| Measured on v0.8.8, 28 cases, `claude-haiku-4-5`, fake embedder | The deployed agent, asked directly | +| ----------------------------------------------------------------- | --------------------------------------------------------------- | +| Correct answers | 28 of 28, in one run | +| Analysis cases / recommendation cases | 3 of 3 / 2 of 2 | +| Cross-tenant, revoked and other-org SQL cases, no leak | 3 of 3 | +| Should-abstain cases that abstain | 4 of 4, no false abstention | +| Memory citations valid | 13 of 16 | +| Document citations valid | 8 of 9 | +| End-to-end latency p50 / p95 | 3.4 s / 10.7 s; the recommendation cases 10.7 s and 14.5 s | +| Tool calls per question | at most 6 (a recommendation reads the audit, mentor and guides) | +| Model cost per answer, every prompt token at list price | mean $0.033, max $0.048 | +| Loom calls after a client disconnects mid-answer | 0 | +| Answer tokens or service password in LibreChat's logs or database | none | +| What LibreChat stored | `transactions` only: no messages, conversations or tool calls | The same cases asked through Loom's chat route, each with the person's own token: 25 of 28 correct and the other 3 refused with `RATE_LIMITED` once the namespace had spent the diff --git a/integrations/librechat/qualification/cases.json b/integrations/librechat/qualification/cases.json index dab488dd41..f12024cb0a 100644 --- a/integrations/librechat/qualification/cases.json +++ b/integrations/librechat/qualification/cases.json @@ -511,10 +511,7 @@ "`knowledge.upload` does not accept a PDF; convert it to text first." ] }, - "forbid": [ - "\\bno `?knowledge\\.(upload|ingest)", - "`?knowledge\\.(upload|ingest)`? (does ?n[o']t|cannot|can ?not) (take|accept|read) (a )?PDF" - ] + "forbid": ["`?knowledge\\.(upload|ingest)`? (does ?n[o']t|cannot|can ?not) (take|accept|read) (a )?PDF"] }, { "id": "help-cost-cap", @@ -589,7 +586,7 @@ "Loom has no `memory.history` op; it keeps only the latest version." ] }, - "forbid": ["\\bno `?memory\\.history", "\\b(keeps only|only keeps) the latest"] + "forbid": ["\\b(keeps only|only keeps) the latest"] }, { "id": "help-graph", @@ -606,7 +603,7 @@ "limit": 5 } }, - "forbid": ["\\b(entities|they) (are|is) not extracted", "by hand only"], + "forbid": ["\\b(entities|they) (are|is) not extracted"], "samples": { "right": [ "Pass them in `entities` on `memory.set`; otherwise the extractor worker extracts them from the memory's text.", @@ -643,7 +640,7 @@ "You cannot use `code.repo.add`; only Loom's own repository is indexed." ] }, - "forbid": ["\\bno `?code\\.repo\\.add", "(cannot|can ?not|can't) (call|use) `?code\\.repo\\.add"] + "forbid": ["(cannot|can ?not|can't) (call|use) `?code\\.repo\\.add"] }, { "id": "help-conflict", @@ -720,12 +717,7 @@ "limit": 5 } }, - "forbid": [ - "^\\W*yes\\b", - "\\byou (can|may) already write\\b", - "\\byou are (a |an )?(writer|admin)\\b", - "\\bviewers? (can|may) write" - ], + "forbid": ["\\byou (can|may) already write\\b", "\\bviewers? (can|may) write"], "samples": { "right": [ "You are a viewer here, so you cannot write; an admin can grant you writer.", @@ -766,7 +758,7 @@ "use_case": "U14 Tokens", "person": "alice", "question": "How do I revoke a Loom token?", - "expect": ["revoke-token"], + "expect": ["revoke-token|service_accounts\\.revoke|Settings\\W+Tokens|revok\\w* it (there|in the dashboard)"], "cite_help": ["guides/tokens-and-grants.md", "reference/cli.md"], "baseline": { "op": "help.search", @@ -776,13 +768,16 @@ } }, "samples": { - "right": ["Run `loom revoke-token --jti `."], + "right": [ + "Run `loom revoke-token --jti `.", + "Revoke it under Settings → Tokens in the dashboard; that ends it in every tool at once." + ], "wrong": [ "Tokens cannot be revoked; wait for them to expire.", "There is no `loom revoke-token` command; tokens cannot be revoked, only left to expire." ] }, - "forbid": ["\\b(no|there is no) `?(loom )?revoke-token", "`?(loom )?revoke-token`? (does ?n[o']t exist|is removed)"] + "forbid": ["\\b(no|there is no) `?(loom )?revoke-token"] }, { "id": "help-models-keys", @@ -808,10 +803,7 @@ "There is no `LOOM_LLM_MODEL` or Models & keys page; each namespace picks its model." ] }, - "forbid": [ - "\\b(no|there is no) `?(LOOM_LLM_(MODEL|PROVIDER)|Models (&|and) keys)", - "`?(LOOM_LLM_(MODEL|PROVIDER)|Models (&|and) keys)`? (does ?n[o']t exist|is removed)" - ] + "forbid": ["\\b(no|there is no) `?(LOOM_LLM_(MODEL|PROVIDER)|Models (&|and) keys)"] }, { "id": "help-health-assistant", @@ -881,7 +873,7 @@ "There is no `run.begin`; a run starts on its own when an agent connects." ] }, - "forbid": ["\\bno `?run\\.begin", "`?run\\.begin`? (does ?n[o']t exist|is removed)"] + "forbid": ["\\bno `?run\\.begin"] }, { "id": "help-tasks", @@ -984,7 +976,7 @@ "`memory.set_from_messages` does not exist; copy each fact out by hand." ] }, - "forbid": ["\\bno `?memory\\.set_from_messages", "`?memory\\.set_from_messages`? (does ?n[o']t exist|is removed)"] + "forbid": ["`?memory\\.set_from_messages`? (does ?n[o']t exist|is removed)"] }, { "id": "help-working-memory", @@ -1066,7 +1058,7 @@ "There is no `LOOM_ASSISTANT_MODEL`; the agent definition and its model come from agent.yaml at boot." ] }, - "forbid": ["\\b(no|there is no) `?LOOM_ASSISTANT_MODEL", "`?LOOM_ASSISTANT_MODEL`? (does ?n[o']t exist|is removed)"] + "forbid": ["\\b(no|there is no) `?LOOM_ASSISTANT_MODEL"] }, { "id": "help-quickstart", @@ -1162,7 +1154,8 @@ "There isn't a Loom setting that changes the colour theme.", "The dashboard has no colour theme setting.", "No Loom setting exists for the dashboard's colour theme.", - "The dashboard's colour theme isn't configurable." + "The dashboard's colour theme isn't configurable.", + "Loom's documentation does not cover it." ], "wrong": [ "The docs don't cover it, but set `LOOM_DASHBOARD_COLOUR=dark`.", diff --git a/integrations/librechat/qualification/qualify.py b/integrations/librechat/qualification/qualify.py index 144fe41f78..b0b0bebd4c 100644 --- a/integrations/librechat/qualification/qualify.py +++ b/integrations/librechat/qualification/qualify.py @@ -242,9 +242,10 @@ def cmd_revoke(args: argparse.Namespace) -> None: (leave it out when the hit has none), for example [guides/setup.md § Setup > Install]. Add the revision, as in [guides/setup.md § Setup > Install, revision 3], only when a tool returned that document's revision number; never write a revision no tool returned. -For a question about how Loom itself works, search Loom's documentation with the help -tools and cite each passage as [help: §
], the section as the hit gives it. -When the tools return nothing relevant, say it is not stored in Loom. When a tool call +For a question about how Loom itself works, search Loom's documentation with help.search +and read a section with help.get; cite each passage as [help: §
], the +section as the hit gives it. When the tools return nothing relevant, say it is not stored +in Loom, or, for a question about Loom itself, that Loom's documentation does not cover it. When a tool call fails, say that it failed and quote the error. Never answer from your own knowledge.""" diff --git a/tests/unit/test_librechat_integration.py b/tests/unit/test_librechat_integration.py index 4d42812665..70549cf5c4 100644 --- a/tests/unit/test_librechat_integration.py +++ b/tests/unit/test_librechat_integration.py @@ -1090,13 +1090,15 @@ def fake_citations(st, case, person, text): ) def test_each_help_forbid_is_what_fails_one_wrong_sample(case): q = _qualify() - # A wrong sample that states what the label expects, and fails only on the forbid. - reached = [ - a - for a in case["samples"]["wrong"] - if q.score({**case, "forbid": []}, a)["correct"] and not q.score(case, a)["correct"] - ] - assert reached, case["id"] + # Each pattern has a wrong sample that the label and the other patterns let through. + for pattern in case["forbid"]: + others = [f for f in case["forbid"] if f != pattern] + reached = [ + a + for a in case["samples"]["wrong"] + if q.score({**case, "forbid": others}, a)["correct"] and not q.score(case, a)["correct"] + ] + assert reached, (case["id"], pattern) def test_a_memory_citation_in_a_document_answer_is_no_document(monkeypatch): @@ -1218,3 +1220,40 @@ def test_a_failed_direct_read_of_the_no_docs_question_is_not_scored(): q = _qualify() case = _case("help-undocumented") assert q.native_score(case, 503, {"detail": "unavailable"})["correct"] is None + + +def test_ask_assistant_reads_the_bridges_citations_event(monkeypatch): + q = _qualify() + # The event as server.assistant.app.bridge writes it after the answer's text. + event = { + "object": "loom.citations", + "id": "run-1", + "choices": [], + "citations": [{"kind": "help", "text": "[help:a.md]", "verified": True}], + "support": "supported", + "unknown_names": ["token.revoke_all"], + } + lines = [ + 'data: {"choices": [{"delta": {"content": "Answer."}}]}', + f"data: {json.dumps(event)}", + "data: [DONE]", + ] + + class Response: + status_code = 200 + + def __enter__(self): + return self + + def __exit__(self, *a): + return False + + def iter_lines(self): + return iter(lines) + + monkeypatch.setattr(q, "answer_request", lambda st, person, question: ("u", {}, {})) + monkeypatch.setattr(q.httpx, "stream", lambda *a, **k: Response()) + got = q.ask_assistant({}, "alice", "q") + assert got["answer"] == "Answer." + assert got["server_citations"] == event["citations"] + assert got["unknown_names"] == ["token.revoke_all"] and got["support"] == "supported" From 1fd1cf201c180c656de7c0b404d5f013306c03f9 Mon Sep 17 00:00:00 2001 From: zlareb1 Date: Wed, 11 Nov 2026 02:39:55 +0000 Subject: [PATCH 20/41] The quickstart label fails 'does not run without an API key', and the direct agent names the help tools as MCP lists them The quickstart forbid takes either word order of a run that needs a key; the setup agent's instructions say help_search and help_get, rewrapped to the file's width. Co-Authored-By: Claude Opus 5.5 Signed-off-by: zlareb1 --- integrations/librechat/qualification/cases.json | 6 ++++-- integrations/librechat/qualification/qualify.py | 9 +++++---- 2 files changed, 9 insertions(+), 6 deletions(-) diff --git a/integrations/librechat/qualification/cases.json b/integrations/librechat/qualification/cases.json index f12024cb0a..035c23c783 100644 --- a/integrations/librechat/qualification/cases.json +++ b/integrations/librechat/qualification/cases.json @@ -1086,11 +1086,13 @@ "Yes, you need an API key; no account is needed.", "Yes: the quickstart won't start without an OpenAI API key.", "The quickstart won't run without an API key.", - "Yes, the quickstart needs an API key; nothing runs without an OpenAI API key." + "Yes, the quickstart needs an API key; nothing runs without an OpenAI API key.", + "Yes, the quickstart does not run without an OpenAI API key.", + "Yes. Without an API key the quickstart cannot start." ] }, "forbid": [ - "\\b(won'?t|can ?not|can't) (start|run)\\w* without an? (\\w+ )?API key", + "\\b(does ?n[o']t|do not|will not|won'?t|can ?not|can't) (start|run)\\w* without an? (\\w+ )?API key|\\bwithout an? (\\w+ )?API key,? (it|the quickstart) (cannot|can't|won'?t|will not|does ?n[o']t|does not)", "\\b(it|the quickstart) (needs?|requires?) an? (\\w+ )?API key|\\bnothing (runs|starts|works) without" ] }, diff --git a/integrations/librechat/qualification/qualify.py b/integrations/librechat/qualification/qualify.py index b0b0bebd4c..89adae132f 100644 --- a/integrations/librechat/qualification/qualify.py +++ b/integrations/librechat/qualification/qualify.py @@ -242,11 +242,12 @@ def cmd_revoke(args: argparse.Namespace) -> None: (leave it out when the hit has none), for example [guides/setup.md § Setup > Install]. Add the revision, as in [guides/setup.md § Setup > Install, revision 3], only when a tool returned that document's revision number; never write a revision no tool returned. -For a question about how Loom itself works, search Loom's documentation with help.search -and read a section with help.get; cite each passage as [help: §
], the +For a question about how Loom itself works, search Loom's documentation with help_search +and read a section with help_get; cite each passage as [help: §
], the section as the hit gives it. When the tools return nothing relevant, say it is not stored -in Loom, or, for a question about Loom itself, that Loom's documentation does not cover it. When a tool call -fails, say that it failed and quote the error. Never answer from your own knowledge.""" +in Loom, or, for a question about Loom itself, that Loom's documentation does not cover it. +When a tool call fails, say that it failed and quote the error. Never answer from your own +knowledge.""" def lc_login(lc: httpx.Client, email: str, password: str) -> str: From 3ce7ae4cb351d47bb655317e2a3bd1482de41a3a Mon Sep 17 00:00:00 2001 From: zlareb1 Date: Wed, 11 Nov 2026 02:47:38 +0000 Subject: [PATCH 21/41] The quickstart and graph labels fail a denial in any determiner or tense The quickstart forbid takes 'without the/your key'; the graph forbid takes 'never extracts'. Each has a wrong sample in that wording. Co-Authored-By: Claude Opus 5.5 Signed-off-by: zlareb1 --- integrations/librechat/qualification/cases.json | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/integrations/librechat/qualification/cases.json b/integrations/librechat/qualification/cases.json index 035c23c783..a08d636e16 100644 --- a/integrations/librechat/qualification/cases.json +++ b/integrations/librechat/qualification/cases.json @@ -603,7 +603,7 @@ "limit": 5 } }, - "forbid": ["\\b(entities|they) (are|is) not extracted"], + "forbid": ["\\b(entities|they) (are|is) not extracted|\\b(never|does ?n[o']t|do not|won'?t) extracts?\\b"], "samples": { "right": [ "Pass them in `entities` on `memory.set`; otherwise the extractor worker extracts them from the memory's text.", @@ -611,7 +611,8 @@ ], "wrong": [ "Entities are not extracted from memories; an admin adds them by hand only.", - "Entities come from `memory.set`; they are not extracted from text." + "Entities come from `memory.set`; they are not extracted from text.", + "Pass them in `entities` on `memory.set`; Loom never extracts entities from the text." ] } }, @@ -1088,11 +1089,12 @@ "The quickstart won't run without an API key.", "Yes, the quickstart needs an API key; nothing runs without an OpenAI API key.", "Yes, the quickstart does not run without an OpenAI API key.", - "Yes. Without an API key the quickstart cannot start." + "Yes. Without an API key the quickstart cannot start.", + "Yes. It won't run without your OpenAI key." ] }, "forbid": [ - "\\b(does ?n[o']t|do not|will not|won'?t|can ?not|can't) (start|run)\\w* without an? (\\w+ )?API key|\\bwithout an? (\\w+ )?API key,? (it|the quickstart) (cannot|can't|won'?t|will not|does ?n[o']t|does not)", + "\\b(does ?n[o']t|do not|will not|won'?t|can ?not|can't) (start|run)\\w* without (an?|the|your) (\\w+ )?(API )?key|\\bwithout (an?|the|your) (\\w+ )?(API )?key,? (it|the quickstart) (cannot|can't|won'?t|will not|does ?n[o']t|does not)", "\\b(it|the quickstart) (needs?|requires?) an? (\\w+ )?API key|\\bnothing (runs|starts|works) without" ] }, From b72828b4978a7016c810711782456d709abc03d3 Mon Sep 17 00:00:00 2001 From: zlareb1 Date: Wed, 11 Nov 2026 02:55:27 +0000 Subject: [PATCH 22/41] The quickstart label needs the page's claim, and the working-memory and op cases fail a denial of what the page says MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit help-quickstart requires 'needs no API key' or 'doesn't need an API key', so a 'cannot … without a key' answer fails whatever its verb; its forbids are no longer needed. Working memory fails 'expires after'; history, upload, extraction, add-repo and tasks fail 'there is no '. Each new rule has a wrong sample only it fails. Co-Authored-By: Claude Opus 5.5 Signed-off-by: zlareb1 --- .../librechat/qualification/cases.json | 56 ++++++++++++------- 1 file changed, 37 insertions(+), 19 deletions(-) diff --git a/integrations/librechat/qualification/cases.json b/integrations/librechat/qualification/cases.json index a08d636e16..2349e23910 100644 --- a/integrations/librechat/qualification/cases.json +++ b/integrations/librechat/qualification/cases.json @@ -508,10 +508,14 @@ "right": ["Upload it with `knowledge.upload`."], "wrong": [ "Save its text with `memory.set`.", - "`knowledge.upload` does not accept a PDF; convert it to text first." + "`knowledge.upload` does not accept a PDF; convert it to text first.", + "There is no `knowledge.upload`; save the text with `memory.set`." ] }, - "forbid": ["`?knowledge\\.(upload|ingest)`? (does ?n[o']t|cannot|can ?not) (take|accept|read) (a )?PDF"] + "forbid": [ + "`?knowledge\\.(upload|ingest)`? (does ?n[o']t|cannot|can ?not) (take|accept|read) (a )?PDF", + "\\b(no|there is no|has no) `?knowledge\\.(upload|ingest)" + ] }, { "id": "help-cost-cap", @@ -583,10 +587,11 @@ ], "wrong": [ "Loom keeps only the latest version.", - "Loom has no `memory.history` op; it keeps only the latest version." + "Loom has no `memory.history` op; it keeps only the latest version.", + "Loom has no `memory.history` op; earlier versions are gone." ] }, - "forbid": ["\\b(keeps only|only keeps) the latest"] + "forbid": ["\\b(no|there is no|has no) `?memory\\.history"] }, { "id": "help-graph", @@ -638,10 +643,14 @@ ], "wrong": [ "You cannot add a repository; Loom indexes only its own code.", - "You cannot use `code.repo.add`; only Loom's own repository is indexed." + "You cannot use `code.repo.add`; only Loom's own repository is indexed.", + "There is no `code.repo.add`; Loom indexes only its own repository." ] }, - "forbid": ["(cannot|can ?not|can't) (call|use) `?code\\.repo\\.add"] + "forbid": [ + "(cannot|can ?not|can't) (call|use) `?code\\.repo\\.add", + "\\b(no|there is no|has no) `?code\\.repo\\.add" + ] }, { "id": "help-conflict", @@ -898,9 +907,11 @@ ], "wrong": [ "The agents share a memory key and poll it.", - "They hand work over through a shared task list in the dashboard." + "They hand work over through a shared task list in the dashboard.", + "There is no `tasks.create`; agents poll a shared memory key and the inbox." ] - } + }, + "forbid": ["\\b(no|there is no|has no) `?tasks?\\.create"] }, { "id": "help-tracker", @@ -974,10 +985,14 @@ "right": ["Send the transcript to `memory.set_from_messages`."], "wrong": [ "Copy each fact out by hand and call `memory.set`.", - "`memory.set_from_messages` does not exist; copy each fact out by hand." + "`memory.set_from_messages` does not exist; copy each fact out by hand.", + "There is no `memory.set_from_messages`; copy each fact by hand." ] }, - "forbid": ["`?memory\\.set_from_messages`? (does ?n[o']t exist|is removed)"] + "forbid": [ + "`?memory\\.set_from_messages`? (does ?n[o']t exist|is removed)", + "\\b(no|there is no|has no) `?memory\\.set_from_messages" + ] }, { "id": "help-working-memory", @@ -1004,10 +1019,14 @@ "wrong": [ "A cache of recent searches; it expires after a day.", "A block given every time; it expires after 24 hours.", - "A small block given every time; it has no TTL but does not survive restarts." + "A small block given every time; it has no TTL but does not survive restarts.", + "A small block given every time; it survives restarts but expires after 30 days." ] }, - "forbid": ["\\b(does ?n[o']t|do not|not|never|won't) surviv"] + "forbid": [ + "\\b(does ?n[o']t|do not|not|never|won't) surviv", + "\\bexpires? (after|in|once|at)\\b|\\b(has|have) a TTL\\b" + ] }, { "id": "help-langfuse", @@ -1067,7 +1086,9 @@ "use_case": "U26 Getting started", "person": "alice", "question": "Does Loom's quickstart need an API key?", - "expect": ["\\b(no|n[o']t|without)\\b[^.]{0,30}\\b(API )?keys?\\b"], + "expect": [ + "\\b(needs?|requires?) no (API )?keys?\\b|\\bno API key\\b|\\b(does ?n[o']t|do ?n[o']t|do not|does not) (need|require) an? (API )?key" + ], "cite_help": ["getting-started/quickstart.md"], "baseline": { "op": "help.search", @@ -1090,13 +1111,10 @@ "Yes, the quickstart needs an API key; nothing runs without an OpenAI API key.", "Yes, the quickstart does not run without an OpenAI API key.", "Yes. Without an API key the quickstart cannot start.", - "Yes. It won't run without your OpenAI key." + "Yes. It won't run without your OpenAI key.", + "Yes: you cannot use the quickstart without an API key." ] - }, - "forbid": [ - "\\b(does ?n[o']t|do not|will not|won'?t|can ?not|can't) (start|run)\\w* without (an?|the|your) (\\w+ )?(API )?key|\\bwithout (an?|the|your) (\\w+ )?(API )?key,? (it|the quickstart) (cannot|can't|won'?t|will not|does ?n[o']t|does not)", - "\\b(it|the quickstart) (needs?|requires?) an? (\\w+ )?API key|\\bnothing (runs|starts|works) without" - ] + } }, { "id": "help-upgrade", From 1a6527bf0ccf72e9376bf150b23d9ee241152880 Mon Sep 17 00:00:00 2001 From: zlareb1 Date: Wed, 11 Nov 2026 03:04:35 +0000 Subject: [PATCH 23/41] The tracker and assistant-health labels need the page's claim, the help direct path counts its expected page, and the erasure sentence says what it reaches The tracker label ties 'doesn't copy' to the data and the health label to a failed setup, each with the wrong answer that passed. The help direct path's cited_expected is its top hit, so the summary compares like with like. A user_id erasure erases the user's rows in every namespace, with what it leaves listed below; the guide's memory-citation rule names the help strip. Co-Authored-By: Claude Opus 5.5 Signed-off-by: zlareb1 --- docs/features/integrations/librechat.md | 2 +- docs/features/memory/retention-and-erasure.md | 5 +++-- integrations/librechat/qualification/cases.json | 17 +++++++++++++---- integrations/librechat/qualification/qualify.py | 6 +++++- tests/unit/test_librechat_integration.py | 10 ++++++++++ 5 files changed, 32 insertions(+), 8 deletions(-) diff --git a/docs/features/integrations/librechat.md b/docs/features/integrations/librechat.md index 2f736524b5..6e8ebe6e82 100644 --- a/docs/features/integrations/librechat.md +++ b/docs/features/integrations/librechat.md @@ -141,7 +141,7 @@ orgs, mints a token per person, revokes one, and scores each answer: and a version written next to it is the row's current version, or, for a question about the key's history (`cite_history`), one of its earlier versions. Through Loom's assistant route a memory citation is `[memory:@v]`; otherwise it is any key-shaped - text. + text outside a `[help:]` citation. - **tool calls:** the `mcp` rows Loom ledgered under the person's subject during the answer. - **latency and time to first token:** end to end, and to the first streamed delta, which for the harness's own agent (`setup`) is the model's one-line preamble before its first diff --git a/docs/features/memory/retention-and-erasure.md b/docs/features/memory/retention-and-erasure.md index 20e24698e0..4df0f297c8 100644 --- a/docs/features/memory/retention-and-erasure.md +++ b/docs/features/memory/retention-and-erasure.md @@ -104,8 +104,9 @@ wins. `erasure.request` erases one scope everywhere Loom keeps it, and returns once it can show nothing in scope is left. To erase everything one user id holds across the org, an org -admin requests the `user_id` scope, which reaches every table that holds the user in every -namespace of the org (`purge=true` deletes the rows rather than tombstoning them). +admin requests the `user_id` scope, which erases the user's rows in every namespace of the +org (`purge=true` deletes them rather than tombstoning them; what it leaves is listed +below). `memory.clear` tombstones one namespace's memories only ([delete is not erase](#delete-is-not-erase)). diff --git a/integrations/librechat/qualification/cases.json b/integrations/librechat/qualification/cases.json index 2349e23910..f30765e9a5 100644 --- a/integrations/librechat/qualification/cases.json +++ b/integrations/librechat/qualification/cases.json @@ -821,7 +821,10 @@ "use_case": "U16 Health problems", "person": "alice", "question": "What does the health problem assistant_service_failing mean?", - "expect": ["LibreChat", "set ?up|setup|sign-?in|configur|retr|regist|creat"], + "expect": [ + "LibreChat", + "(set ?up|setup|regist\\w*|sign-?in|creat\\w*)[^.]{0,80}(fail|could ?n[o']t|did ?n[o']t)|fail\\w*[^.]{0,80}(set ?up|setup|regist|sign-?in)|retr(y|ies)" + ], "cite_help": ["features/integrations/librechat.md", "architecture/assistant.md"], "baseline": { "op": "help.search", @@ -835,7 +838,10 @@ "Loom's setup of the LibreChat assistant failed; it retries, and `/v1/health` names what to fix.", "Loom's boot-time registration of its service user and agent in LibreChat failed; it clears once a try succeeds." ], - "wrong": ["It means the LibreChat chat history is full."] + "wrong": [ + "It means the LibreChat chat history is full.", + "It means LibreChat's chat history is full; create a new chat." + ] } }, { @@ -920,7 +926,7 @@ "person": "alice", "question": "Does Loom copy our issue tracker's data into its own database?", "expect": [ - "(never|does ?n[o']t|does not) (copy|copies|store|stores|keep|keeps)\\b|(reads|queries)\\b[^.]{0,30}\\blive|keeps? no copy" + "never copies (it|your|the|any)|(does ?n[o']t|does not|never) (copy|store|keep) (it|your|the|any)|(reads|queries)\\b[^.]{0,30}\\blive|keeps? no copy" ], "cite_help": ["features/tracker/overview.md"], "baseline": { @@ -936,7 +942,10 @@ "No. Loom doesn't store your tracker's data; it queries it live with a read-only credential.", "No. Loom reads your tracker live with a read-only credential." ], - "wrong": ["Yes, it copies every issue into its database each night."] + "wrong": [ + "Yes, it copies every issue into its database each night.", + "Yes: Loom copies every issue into its database each night; it doesn't store attachments." + ] } }, { diff --git a/integrations/librechat/qualification/qualify.py b/integrations/librechat/qualification/qualify.py index 89adae132f..dde344f742 100644 --- a/integrations/librechat/qualification/qualify.py +++ b/integrations/librechat/qualification/qualify.py @@ -859,6 +859,7 @@ def native_score(case: dict[str, Any], code: int, out: dict[str, Any]) -> dict[s spec = case["baseline"] cited: list[str] = [] abstained = False + expected = case.get("cite") in cited if case.get("cite") else None if code != 200: text = f"{code} {out.get('detail', out)}" # The direct path of a question the docs leave open is not scored, whatever answered. @@ -871,6 +872,7 @@ def native_score(case: dict[str, Any], code: int, out: dict[str, Any]) -> dict[s else: text = f"{hits[0].get('content_excerpt', '')} [{hits[0]['memory_key']}]" cited = [hits[0]["memory_key"]] + expected = case.get("cite") in cited if case.get("cite") else None correct = abstained if case["kind"] == "abstain" else score(case, text)["correct"] correct = correct and case["kind"] != "refusal" elif spec["op"] == "knowledge.search": @@ -884,6 +886,8 @@ def native_score(case: dict[str, Any], code: int, out: dict[str, Any]) -> dict[s wanted = set(case.get("cite_help") or []) correct = bool(wanted & set(pages)) if wanted else None cited = pages[:1] + # The labeled page as its top hit, as the LibreChat side counts the page it cites. + expected = bool(pages) and pages[0] in wanted if wanted else None elif "findings" in spec: # A recommendation's direct path: the audit names each labeled finding on rows. found = {f["code"] for f in out.get("findings", []) if f.get("count")} @@ -908,7 +912,7 @@ def native_score(case: dict[str, Any], code: int, out: dict[str, Any]) -> dict[s "tool_calls": 1, "cited": cited, "invalid_citations": [], - "cited_expected": case.get("cite") in cited if case.get("cite") else None, + "cited_expected": expected, } diff --git a/tests/unit/test_librechat_integration.py b/tests/unit/test_librechat_integration.py index 70549cf5c4..4f0bf2a7f5 100644 --- a/tests/unit/test_librechat_integration.py +++ b/tests/unit/test_librechat_integration.py @@ -1257,3 +1257,13 @@ def iter_lines(self): assert got["answer"] == "Answer." assert got["server_citations"] == event["citations"] assert got["unknown_names"] == ["token.revoke_all"] and got["support"] == "supported" + + +def test_the_help_direct_path_counts_its_top_hit_as_the_expected_page(): + q = _qualify() + case = _case("help-revoke-token") + top = {"hits": [{"path": case["cite_help"][0]}, {"path": "other.md"}]} + assert q.native_score(case, 200, top)["cited_expected"] is True + second = {"hits": [{"path": "other.md"}, {"path": case["cite_help"][0]}]} + assert q.native_score(case, 200, second)["cited_expected"] is False + assert q.native_score(_case("help-undocumented"), 200, top)["cited_expected"] is None From 16ca28dbfd4f062ff0a692a50d6d1435cb07cc5d Mon Sep 17 00:00:00 2001 From: zlareb1 Date: Wed, 11 Nov 2026 03:14:55 +0000 Subject: [PATCH 24/41] Five help labels fail the contradiction that passed them, and the help path guard measures the path as written MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Quickstart needs 'no API key is needed'; tracker fails 'yes … copies'; assistant health needs a failed setup, not any 'retry'; upgrade's 'before' is 'before it reports ready'; erase-user fails a denial of erasure.request. Each has the passing answer as a wrong sample. The 300-character guard reads the cited path before the docs/ strip, as help.get validates it, and native_score sets cited_expected where the direct path can cite. Co-Authored-By: Claude Opus 5.5 Signed-off-by: zlareb1 --- .../librechat/qualification/cases.json | 32 +++++++++++++------ .../librechat/qualification/qualify.py | 9 +++--- 2 files changed, 27 insertions(+), 14 deletions(-) diff --git a/integrations/librechat/qualification/cases.json b/integrations/librechat/qualification/cases.json index f30765e9a5..b6bd5ae9ac 100644 --- a/integrations/librechat/qualification/cases.json +++ b/integrations/librechat/qualification/cases.json @@ -823,7 +823,7 @@ "question": "What does the health problem assistant_service_failing mean?", "expect": [ "LibreChat", - "(set ?up|setup|regist\\w*|sign-?in|creat\\w*)[^.]{0,80}(fail|could ?n[o']t|did ?n[o']t)|fail\\w*[^.]{0,80}(set ?up|setup|regist|sign-?in)|retr(y|ies)" + "(set ?up|setup|regist\\w*|sign-?in|creat\\w*)[^.]{0,80}(fail|could ?n[o']t|did ?n[o']t)|fail\\w*[^.]{0,80}(set ?up|setup|regist|sign-?in)|fail\\w*[^.]{0,80}retr(y|ies)|retr(y|ies)[^.]{0,40}(set ?up|regist)" ], "cite_help": ["features/integrations/librechat.md", "architecture/assistant.md"], "baseline": { @@ -840,7 +840,8 @@ ], "wrong": [ "It means the LibreChat chat history is full.", - "It means LibreChat's chat history is full; create a new chat." + "It means LibreChat's chat history is full; create a new chat.", + "It means LibreChat's chat history is full; retry in a new chat." ] } }, @@ -944,9 +945,11 @@ ], "wrong": [ "Yes, it copies every issue into its database each night.", - "Yes: Loom copies every issue into its database each night; it doesn't store attachments." + "Yes: Loom copies every issue into its database each night; it doesn't store attachments.", + "Yes: Loom copies every issue into its database each night; it doesn't store the attachments." ] - } + }, + "forbid": ["\\byes\\b[^.]{0,20}\\bcop(y|ies)\\b|\\bcopies (every|each|all)\\b"] }, { "id": "help-erase-user", @@ -972,8 +975,15 @@ "An admin can run `memory.clear`, but it only tombstones; an org admin erases with `erasure.request` and the `user_id` scope.", "Only an organization admin, with `erasure.request` and the `user_id` scope." ], - "wrong": ["An org admin runs `memory.clear` with `agent=\"*\"`.", "Any writer may, with `memory.delete`."] - } + "wrong": [ + "An org admin runs `memory.clear` with `agent=\"*\"`.", + "Any writer may, with `memory.delete`.", + "No org admin can: `erasure.request` does not take the `user_id` scope; run `memory.clear` in each namespace." + ] + }, + "forbid": [ + "`?erasure\\.request`? (does ?n[o']t|cannot|can ?not|won'?t) (take|accept|erase)|\\bno (org(ani[sz]ation)? )?admin (can|may)\\b" + ] }, { "id": "help-extraction", @@ -1096,7 +1106,7 @@ "person": "alice", "question": "Does Loom's quickstart need an API key?", "expect": [ - "\\b(needs?|requires?) no (API )?keys?\\b|\\bno API key\\b|\\b(does ?n[o']t|do ?n[o']t|do not|does not) (need|require) an? (API )?key" + "\\b(needs?|requires?) no (API )?keys?\\b|\\bno API key (is )?(needed|required)\\b|\\b(does ?n[o']t|do ?n[o']t|do not|does not) (need|require) an? (API )?key" ], "cite_help": ["getting-started/quickstart.md"], "baseline": { @@ -1121,7 +1131,8 @@ "Yes, the quickstart does not run without an OpenAI API key.", "Yes. Without an API key the quickstart cannot start.", "Yes. It won't run without your OpenAI key.", - "Yes: you cannot use the quickstart without an API key." + "Yes: you cannot use the quickstart without an API key.", + "Yes. With no API key, the quickstart won't start." ] } }, @@ -1132,7 +1143,7 @@ "person": "alice", "question": "How do I upgrade a Loom deployment to a new release?", "expect": [ - "(boot|start)\\w*[^.]{0,60}(appl|run)\\w* (the |pending |its )?migrat|(appl|run)\\w* (the |pending |its )?(migrat\\w*|files)[^.]{0,40}\\b(at|on|when|before) (boot|start|it reports ready)|migrations? (run|are applied|apply)[^.]{0,30}\\b(at|on|when) (boot|start)|replac\\w* the image[^.]{0,80}appl\\w* (the |its )?migrat" + "(boot|start)\\w*[^.]{0,60}(appl|run)\\w* (the |pending |its )?migrat|(appl|run)\\w* (the |pending |its )?(migrat\\w*|files)[^.]{0,40}(\\b(at|on|when) (boot|start)|\\bbefore it reports ready)|migrations? (run|are applied|apply)[^.]{0,30}\\b(at|on|when) (boot|start)|replac\\w* the image[^.]{0,80}appl\\w* (the |its )?migrat" ], "cite_help": ["operations/upgrades.md"], "baseline": { @@ -1155,7 +1166,8 @@ "Export every memory, reinstall the new release and import them back.", "Loom cannot be upgraded in place; migrate the data by hand.", "Loom cannot be upgraded in place; migrate the data by hand, then start the new build.", - "Stop every server, run the migrations by hand, then start the new release." + "Stop every server, run the migrations by hand, then start the new release.", + "Stop every server, run the migrations by hand before starting the new release." ] } }, diff --git a/integrations/librechat/qualification/qualify.py b/integrations/librechat/qualification/qualify.py index dde344f742..dc5fc2c38c 100644 --- a/integrations/librechat/qualification/qualify.py +++ b/integrations/librechat/qualification/qualify.py @@ -674,9 +674,10 @@ def check_help_citations( if name in cited: continue cited.append(name) + # A path help.get refuses outright (empty, or past its 300 characters as written) + # names no page. path = m["path"].removeprefix("docs/") - # A path help.get refuses outright (empty, or past its 300 characters) names no page. - if not path or len(path) > 300: + if not path or len(m["path"]) > 300: invalid.append(f"{name}: no such page") continue page = scorer_read(st, scorer, "help.get", {"path": path}) @@ -859,7 +860,7 @@ def native_score(case: dict[str, Any], code: int, out: dict[str, Any]) -> dict[s spec = case["baseline"] cited: list[str] = [] abstained = False - expected = case.get("cite") in cited if case.get("cite") else None + expected: bool | None = None # set below where the direct path can cite the labeled source if code != 200: text = f"{code} {out.get('detail', out)}" # The direct path of a question the docs leave open is not scored, whatever answered. @@ -872,9 +873,9 @@ def native_score(case: dict[str, Any], code: int, out: dict[str, Any]) -> dict[s else: text = f"{hits[0].get('content_excerpt', '')} [{hits[0]['memory_key']}]" cited = [hits[0]["memory_key"]] - expected = case.get("cite") in cited if case.get("cite") else None correct = abstained if case["kind"] == "abstain" else score(case, text)["correct"] correct = correct and case["kind"] != "refusal" + expected = case.get("cite") in cited if case.get("cite") else None elif spec["op"] == "knowledge.search": return native_document_score(case, out) elif spec["op"] == "help.search": From 5679efae2dbbcb77d4b4000557e5dfdc598fd85a Mon Sep 17 00:00:00 2001 From: zlareb1 Date: Wed, 11 Nov 2026 03:25:39 +0000 Subject: [PATCH 25/41] The tracker and quickstart labels tie their claim to its subject, and help.get gets the cited path as written The tracker label needs the tracker's data not copied and fails a yes-then-copy, import, sync or mirror claim; the quickstart label needs the quickstart, you or it as the one needing no key. help.get strips docs/ itself, once, as the bridge does, so the harness sends the path unchanged. Co-Authored-By: Claude Opus 5.5 Signed-off-by: zlareb1 --- integrations/librechat/qualification/cases.json | 16 +++++++++++----- integrations/librechat/qualification/qualify.py | 4 +++- tests/unit/test_librechat_integration.py | 8 ++++++-- 3 files changed, 20 insertions(+), 8 deletions(-) diff --git a/integrations/librechat/qualification/cases.json b/integrations/librechat/qualification/cases.json index b6bd5ae9ac..dcd525e777 100644 --- a/integrations/librechat/qualification/cases.json +++ b/integrations/librechat/qualification/cases.json @@ -927,7 +927,7 @@ "person": "alice", "question": "Does Loom copy our issue tracker's data into its own database?", "expect": [ - "never copies (it|your|the|any)|(does ?n[o']t|does not|never) (copy|store|keep) (it|your|the|any)|(reads|queries)\\b[^.]{0,30}\\blive|keeps? no copy" + "never copies (it|your|the|any)|(does ?n[o']t|does not|never) (copy|store|keep) (it|(your|the|any) (issue )?(tracker|issue))|(reads|queries)\\b[^.]{0,30}\\blive|keeps? no copy" ], "cite_help": ["features/tracker/overview.md"], "baseline": { @@ -946,10 +946,15 @@ "wrong": [ "Yes, it copies every issue into its database each night.", "Yes: Loom copies every issue into its database each night; it doesn't store attachments.", - "Yes: Loom copies every issue into its database each night; it doesn't store the attachments." + "Yes: Loom copies every issue into its database each night; it doesn't store the attachments.", + "Yes, Loom imports every issue into ClickHouse each night; it doesn't store the attachments.", + "Yes. Loom copies the issues into its own tables.", + "Yes: Loom syncs every issue each night, and it doesn't store the tracker credentials." ] }, - "forbid": ["\\byes\\b[^.]{0,20}\\bcop(y|ies)\\b|\\bcopies (every|each|all)\\b"] + "forbid": [ + "(^|[.!?:]\\s*)yes\\b[^.]{0,40}\\b(cop(y|ies)|imports?|syncs?|mirrors?)\\b|\\bcopies (every|each|all)\\b|\\b(imports?|syncs?|mirrors?) (every|each|all|the) (issue|tracker)" + ] }, { "id": "help-erase-user", @@ -1106,7 +1111,7 @@ "person": "alice", "question": "Does Loom's quickstart need an API key?", "expect": [ - "\\b(needs?|requires?) no (API )?keys?\\b|\\bno API key (is )?(needed|required)\\b|\\b(does ?n[o']t|do ?n[o']t|do not|does not) (need|require) an? (API )?key" + "\\b(needs?|requires?) no (API )?keys?\\b|\\bno API key (is )?(needed|required)\\b|\\b(you|it|the quickstart) (does ?n[o']t|do ?n[o']t|do not|does not) (need|require) an? (API )?key" ], "cite_help": ["getting-started/quickstart.md"], "baseline": { @@ -1132,7 +1137,8 @@ "Yes. Without an API key the quickstart cannot start.", "Yes. It won't run without your OpenAI key.", "Yes: you cannot use the quickstart without an API key.", - "Yes. With no API key, the quickstart won't start." + "Yes. With no API key, the quickstart won't start.", + "Yes, the quickstart needs an OpenAI API key; search doesn't need a key." ] } }, diff --git a/integrations/librechat/qualification/qualify.py b/integrations/librechat/qualification/qualify.py index dc5fc2c38c..f71be58671 100644 --- a/integrations/librechat/qualification/qualify.py +++ b/integrations/librechat/qualification/qualify.py @@ -680,7 +680,9 @@ def check_help_citations( if not path or len(m["path"]) > 300: invalid.append(f"{name}: no such page") continue - page = scorer_read(st, scorer, "help.get", {"path": path}) + # help.get strips `docs/` itself, once, as the bridge's check does: send the path as + # cited, so `docs/docs/…` is no page here either. + page = scorer_read(st, scorer, "help.get", {"path": m["path"]}) if not page.get("found"): invalid.append(f"{name}: no such page") continue diff --git a/tests/unit/test_librechat_integration.py b/tests/unit/test_librechat_integration.py index 4f0bf2a7f5..37f6306259 100644 --- a/tests/unit/test_librechat_integration.py +++ b/tests/unit/test_librechat_integration.py @@ -807,7 +807,8 @@ def test_check_help_citations_reads_the_page_and_its_sections(monkeypatch): def fake_read(st, token, op, body): assert op == "help.get" and token == "viewer-token" - if body["path"] != "features/cost.md": + # help.get strips one `docs/` prefix, as the server does. + if body["path"].removeprefix("docs/") != "features/cost.md": return {"found": False} return {"found": True, "sections": [{"section": "Cost and usage > Daily spend caps"}]} @@ -819,7 +820,8 @@ def fake_read(st, token, op, body): "[help:docs/features/cost.md § Daily spend caps] " "[help:features/cost.md § daily spend caps] " "[help:features/other.md] " - "[help:features/cost.md § >]" # only separators: the page itself, as the server reads it + "[help:features/cost.md § >] " # only separators: the page itself, as the server reads it + "[help:docs/docs/features/cost.md]" # one prefix is stripped, as the bridge strips it ) cited, invalid, expected = q.check_help_citations(st, person, case, text) assert cited == [ @@ -827,10 +829,12 @@ def fake_read(st, token, op, body): "help:features/cost.md § daily spend caps", "help:features/other.md", "help:features/cost.md § >", + "help:docs/docs/features/cost.md", ] assert invalid == [ "help:features/cost.md § daily spend caps: no such section", "help:features/other.md: no such page", + "help:docs/docs/features/cost.md: no such page", ] assert expected is True From 64584d042b7df37b7cafbaccf209cab47d8080e7 Mon Sep 17 00:00:00 2001 From: zlareb1 Date: Wed, 11 Nov 2026 03:33:27 +0000 Subject: [PATCH 26/41] Every help case with a claim fails an answer that denies it MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Upgrade, cost cap, setting, search vs ask, key shape, conflicts, collections, Claude Code, assistant health, ranking and Langfuse each gain a forbid on the denial of their page's claim, with a wrong sample that states the labeled values and only that forbid fails. The ranking label no longer takes search_trace, which scores the vector leg alone. The tracker forbid takes 'copies your …' but not 'does not copy your …'. The documented-settings docstring says how it differs from the server's rule. Co-Authored-By: Claude Opus 5.5 Signed-off-by: zlareb1 --- .../librechat/qualification/cases.json | 96 ++++++++++++++----- .../librechat/qualification/qualify.py | 5 +- 2 files changed, 73 insertions(+), 28 deletions(-) diff --git a/integrations/librechat/qualification/cases.json b/integrations/librechat/qualification/cases.json index dcd525e777..6cbc8b9a0b 100644 --- a/integrations/librechat/qualification/cases.json +++ b/integrations/librechat/qualification/cases.json @@ -485,9 +485,11 @@ ], "wrong": [ "They are the same op and return the same answer.", - "`memory.ask` returns ranked hits; `memory.search` writes a synthesised answer." + "`memory.ask` returns ranked hits; `memory.search` writes a synthesised answer.", + "`memory.search` returns ranked hits; `memory.ask` does not write an answer, it returns the same hits." ] - } + }, + "forbid": ["memory\\.ask`?[^.]{0,40}(does ?n[o']t|do not|never) (synthesi|write|return)"] }, { "id": "help-upload-file", @@ -541,9 +543,11 @@ "wrong": [ "$1.0, and nothing is skipped: the cap only warns.", "There is no default cap; extraction keeps running.", - "$1.50 a day; once it is spent Loom skips synthesis and extraction." + "$1.50 a day; once it is spent Loom skips synthesis and extraction.", + "The default cap is $1.0; Loom does not skip synthesis or extraction once it is spent, it only logs." ] - } + }, + "forbid": ["\\b(does ?n[o']t|do not|never|won'?t) skip"] }, { "id": "help-key-shape", @@ -562,8 +566,15 @@ }, "samples": { "right": ["`//`, readable, like `billing/decision/refund-window`."], - "wrong": ["Any string works; a UUID is best.", "Scope and kind are tags, not part of the key."] - } + "wrong": [ + "Any string works; a UUID is best.", + "Scope and kind are tags, not part of the key.", + "Keys need not follow `//`; any string works." + ] + }, + "forbid": [ + "\\b(is ?n[o']t|not|need not be|need ?n[o']t be) (required|needed|followed)|\\bany (string|key) (works|is fine)" + ] }, { "id": "help-history", @@ -671,8 +682,13 @@ "right": [ "The new row is stored and flagged as a conflict; the namespace owner decides in the Review queue or with `conflicts.resolve`." ], - "wrong": ["The new write overwrites the old one.", "Loom refuses the write and asks you to resolve the conflict."] - } + "wrong": [ + "The new write overwrites the old one.", + "Loom refuses the write and asks you to resolve the conflict.", + "Loom does not flag it; the new write wins with no Review queue entry or `conflicts.resolve`." + ] + }, + "forbid": ["\\b(does ?n[o']t|do not|never|is not|isn't) (flag|mark)\\w*"] }, { "id": "help-collection", @@ -704,9 +720,11 @@ ], "wrong": [ "A collection is a folder of documents; share it with a link.", - "A `col-` namespace is shared by putting it in the token's claims; no grant is needed." + "A `col-` namespace is shared by putting it in the token's claims; no grant is needed.", + "A `col-` namespace is shared through its token claims; no grant on it is needed." ] - } + }, + "forbid": ["\\bno grants?( on it)? (is |are )?(needed|required)"] }, { "id": "help-my-role", @@ -759,8 +777,12 @@ }, "samples": { "right": ["Run `claude plugin marketplace add ClickHouse/loom`, then install the plugin."], - "wrong": ["Install a Loom editor extension and paste your token."] - } + "wrong": [ + "Install a Loom editor extension and paste your token.", + "`claude plugin install loom` doesn't work; there is no Loom plugin, so paste the token into an editor extension." + ] + }, + "forbid": ["\\b(does ?n[o']t|do not|cannot|can't) (work|connect)\\b|\\bthere is no (Loom )?plugin"] }, { "id": "help-revoke-token", @@ -841,9 +863,11 @@ "wrong": [ "It means the LibreChat chat history is full.", "It means LibreChat's chat history is full; create a new chat.", - "It means LibreChat's chat history is full; retry in a new chat." + "It means LibreChat's chat history is full; retry in a new chat.", + "It does not mean LibreChat's setup failed; the chat history is full." ] - } + }, + "forbid": ["\\b(does ?n[o']t|do not|not) mean\\b"] }, { "id": "help-why-ranked", @@ -851,7 +875,7 @@ "use_case": "U17 Why search returned this", "person": "alice", "question": "How can I see why a search ranked a memory where it did?", - "expect": ["explain\\s*=\\s*true|score_components|search_trace"], + "expect": ["explain\\s*=\\s*true|score_components"], "cite_help": ["concepts/retrieval-and-ranking.md", "guides/debugging.md", "features/memory/search-and-ask.md"], "baseline": { "op": "help.search", @@ -862,8 +886,16 @@ }, "samples": { "right": ["Search with `explain=true`: each hit carries its `score_components`."], - "wrong": ["Loom does not explain rankings.", "I can't explain why it ranked there; recall varies."] - } + "wrong": [ + "Loom does not explain rankings.", + "I can't explain why it ranked there; recall varies.", + "Run `memory.search_trace` with the same request; its `rank_score` shows why the memory ranked there.", + "`explain=true` does not show why a memory ranked; Loom cannot tell you." + ] + }, + "forbid": [ + "(explain\\s*=\\s*true|score_components)`?[^.]{0,30}(does ?n[o']t|do not|cannot|can't|won'?t) (show|explain|tell)" + ] }, { "id": "help-runs", @@ -941,7 +973,8 @@ "right": [ "No: Loom never copies it; it reads the tracker live.", "No. Loom doesn't store your tracker's data; it queries it live with a read-only credential.", - "No. Loom reads your tracker live with a read-only credential." + "No. Loom reads your tracker live with a read-only credential.", + "No. Loom does not copy your issue tracker's data into its own database; it reads it live." ], "wrong": [ "Yes, it copies every issue into its database each night.", @@ -949,11 +982,12 @@ "Yes: Loom copies every issue into its database each night; it doesn't store the attachments.", "Yes, Loom imports every issue into ClickHouse each night; it doesn't store the attachments.", "Yes. Loom copies the issues into its own tables.", - "Yes: Loom syncs every issue each night, and it doesn't store the tracker credentials." + "Yes: Loom syncs every issue each night, and it doesn't store the tracker credentials.", + "Loom copies your tracker's issues into its own tables and reads them live from there." ] }, "forbid": [ - "(^|[.!?:]\\s*)yes\\b[^.]{0,40}\\b(cop(y|ies)|imports?|syncs?|mirrors?)\\b|\\bcopies (every|each|all)\\b|\\b(imports?|syncs?|mirrors?) (every|each|all|the) (issue|tracker)" + "(^|[.!?:]\\s*)yes\\b[^.]{0,40}\\b(cop(y|ies)|imports?|syncs?|mirrors?)\\b|(? tuple[str, ...]: @functools.cache def documented_settings() -> frozenset[str]: - """Every `LOOM_*` name a shipped docs page writes: the documentation half of the - server's unknown-name check (`server.assistant.domain.names`).""" + """Every `LOOM_*` name a shipped docs page writes. Close to the documentation half of + the server's unknown-name check (`server.assistant.domain.names`), not the same rule: + that one reads the help index's identifiers, and has no placeholder families.""" return frozenset(name for text in shipped_docs() for name in SETTING_RE.findall(text)) From 8e616b1ad688c57bb9c60a25a5db4b7d71784928 Mon Sep 17 00:00:00 2001 From: zlareb1 Date: Wed, 11 Nov 2026 03:44:39 +0000 Subject: [PATCH 27/41] A settings family's bare prefix is not a documented setting, and a failed direct read cites no labeled source SETTING_RE reads whole names only, so LOOM_RETENTION_* documents its members and not LOOM_RETENTION; a family may be written with or *. A failed direct read sets cited_expected False for a case that labels a source. The guide says a help answer is wrong when it denies the labeled values. Co-Authored-By: Claude Opus 5.5 Signed-off-by: zlareb1 --- docs/features/integrations/librechat.md | 24 +++++++++--------- .../librechat/qualification/qualify.py | 25 +++++++++++++------ tests/unit/test_librechat_integration.py | 11 ++++++++ 3 files changed, 40 insertions(+), 20 deletions(-) diff --git a/docs/features/integrations/librechat.md b/docs/features/integrations/librechat.md index 6e8ebe6e82..9639e2f5c6 100644 --- a/docs/features/integrations/librechat.md +++ b/docs/features/integrations/librechat.md @@ -223,18 +223,18 @@ The case set holds at least one question per use case of Loom: what a namespace how it is used (the data tools), and how Loom works and how to do something in it (the help tools, which read the documentation the server ships). Each help case labels the values its answer must state and the pages that hold them, with a right and a wrong sample -answer the label is tested against. Its answer is scored correct when it states them, -under the unknown-name rule above. For the case with no answer in the docs, the answer is -correct when it says so and writes no `LOOM_` name that no docs page writes, as a name or -as a member of a family a page writes with placeholders; an answer that names an invented -setting only to deny it is scored wrong. The labels are patterns over the answer's text, -so they err both ways: an answer that states the labeled values beside a wrong claim about -them can pass, and a right answer worded otherwise can fail. A correct score means the -answer has what the page says. A help citation is valid when its page is in the server's -documentation (`help.get`) and its section is one of the page's own, by the rule the -server's own check uses. The cases go through Loom's assistant route (`qualify.py -setup-bridge`), so each answer also carries the question's asker line and the bridge's own -citation check. +answer the label is tested against. Its answer is scored correct when it states them and +does not deny them (each case's `forbid`), under the unknown-name rule above. For the case +with no answer in the docs, the answer is correct when it says so and writes no `LOOM_` +name that no docs page writes, as a name or as a member of a family a page writes with +placeholders; an answer that names an invented setting only to deny it is scored wrong. +The labels are patterns over the answer's text, so they err both ways: an answer that +states the labeled values beside a wrong claim about them can pass, and a right answer +worded otherwise can fail. A correct score means the answer has what the page says. A help +citation is valid when its page is in the server's documentation (`help.get`) and its +section is one of the page's own, by the rule the server's own check uses. The cases go +through Loom's assistant route (`qualify.py setup-bridge`), so each answer also carries +the question's asker line and the bridge's own citation check. | Use case | Cases | Correct | No invalid citation | | --------------------------------- | ----- | -------- | ------------------- | diff --git a/integrations/librechat/qualification/qualify.py b/integrations/librechat/qualification/qualify.py index d2924b2182..4a28078950 100644 --- a/integrations/librechat/qualification/qualify.py +++ b/integrations/librechat/qualification/qualify.py @@ -596,9 +596,11 @@ def parse_doc_citations(text: str) -> list[dict[str, Any]]: DOCS = HERE.parents[2] / "docs" -SETTING_RE = re.compile(r"\bLOOM_[A-Z0-9_]*[A-Z0-9]") -# A settings family a docs page writes with placeholders (`LOOM_RETENTION_
_DAYS`). -SETTING_FAMILY_RE = re.compile(r"\bLOOM_[A-Z0-9_]*(?:<[A-Z]+>[A-Z0-9_]*)+") +# A whole name: not the prefix of a family written as `LOOM_RETENTION_*`. +SETTING_RE = re.compile(r"\bLOOM_[A-Z0-9_]*[A-Z0-9](?![A-Z0-9_])") +# A settings family a docs page writes with placeholders (`LOOM_RETENTION_
_DAYS`, +# `LOOM_RETENTION_*`). +SETTING_FAMILY_RE = re.compile(r"\bLOOM_[A-Z0-9_]*(?:(?:<[A-Z]+>|\*)[A-Z0-9_]*)+") # The kinds whose right answer is an abstention: from the namespace, or from the docs. ABSTAIN_KINDS = ("abstain", "help_abstain") @@ -618,7 +620,12 @@ def documented_settings() -> frozenset[str]: """Every `LOOM_*` name a shipped docs page writes. Close to the documentation half of the server's unknown-name check (`server.assistant.domain.names`), not the same rule: that one reads the help index's identifiers, and has no placeholder families.""" - return frozenset(name for text in shipped_docs() for name in SETTING_RE.findall(text)) + # A family written with placeholders documents its members, not its bare prefix. + return frozenset( + name + for text in shipped_docs() + for name in SETTING_RE.findall(SETTING_FAMILY_RE.sub("", text)) + ) @functools.cache @@ -626,18 +633,18 @@ def documented_families() -> tuple[re.Pattern[str], ...]: """Each settings family the docs write with placeholders, as the pattern its members match: `LOOM_RETENTION_
_DAYS` takes `LOOM_RETENTION_EVENTS_DAYS`, not `LOOM_RETENTION_THEME`.""" - # A placeholder right after `LOOM_` (`LOOM_`) names the scheme, not a family. + # A placeholder right after `LOOM_` (`LOOM_`, `LOOM_*`) names the scheme. families = { f for text in shipped_docs() for f in SETTING_FAMILY_RE.findall(text) - if not f.startswith("LOOM_<") + if not f.startswith(("LOOM_<", "LOOM_*")) } return tuple( re.compile( "".join( - "[A-Z0-9_]+" if part.startswith("<") else re.escape(part) - for part in re.split(r"(<[A-Z]+>)", family) + "[A-Z0-9_]+" if part.startswith("<") or part == "*" else re.escape(part) + for part in re.split(r"(<[A-Z]+>|\*)", family) if part ) ) @@ -868,6 +875,8 @@ def native_score(case: dict[str, Any], code: int, out: dict[str, Any]) -> dict[s text = f"{code} {out.get('detail', out)}" # The direct path of a question the docs leave open is not scored, whatever answered. correct = None if case["kind"] == "help_abstain" else case["kind"] == "refusal" + # A failed read cites nothing: a labeled source counts as not cited. + expected = False if case.get("cite") or case.get("cite_help") else None elif spec["op"] == "memory.search": hits = out.get("results") or [] abstained = bool(out.get("abstain")) or not hits diff --git a/tests/unit/test_librechat_integration.py b/tests/unit/test_librechat_integration.py index 37f6306259..7f779a02c8 100644 --- a/tests/unit/test_librechat_integration.py +++ b/tests/unit/test_librechat_integration.py @@ -1181,6 +1181,9 @@ def test_a_documented_settings_family_member_is_documented(): assert q.undocumented_settings("`LOOM_RETENTION_EVENTS_DAYS`") == [] # A family's prefix alone documents nothing: the placeholder's suffix must be there. assert q.undocumented_settings("`LOOM_RETENTION_THEME`") == ["LOOM_RETENTION_THEME"] + assert q.undocumented_settings("`LOOM_RETENTION`") == ["LOOM_RETENTION"] + # A family written with a wildcard (`LOOM_CH_*`) documents its members. + assert q.undocumented_settings("`LOOM_CH_HOST`") == [] assert q.undocumented_settings("`LOOM_UI_THEME`") == ["LOOM_UI_THEME"] @@ -1271,3 +1274,11 @@ def test_the_help_direct_path_counts_its_top_hit_as_the_expected_page(): second = {"hits": [{"path": "other.md"}, {"path": case["cite_help"][0]}]} assert q.native_score(case, 200, second)["cited_expected"] is False assert q.native_score(_case("help-undocumented"), 200, top)["cited_expected"] is None + + +def test_a_failed_direct_read_cites_no_labeled_source(): + q = _qualify() + assert ( + q.native_score(_case("help-revoke-token"), 503, {"detail": "x"})["cited_expected"] is False + ) + assert q.native_score(_case("memory-freeze"), 503, {"detail": "x"})["cited_expected"] is False From 90d2c2d19196dc1fa1266aa211584d342d2e906b Mon Sep 17 00:00:00 2001 From: zlareb1 Date: Wed, 11 Nov 2026 03:53:34 +0000 Subject: [PATCH 28/41] The help path guard keeps only help.get's length limit, and the document-report test checks the current summary label help.get answers found:false to an empty path after the docs/ strip, so only a path past 300 characters (a 422) is marked without a call; its test uses one. The document-report assertion names 'expected source cited'. Co-Authored-By: Claude Opus 5.5 Signed-off-by: zlareb1 --- integrations/librechat/qualification/qualify.py | 6 +++--- tests/unit/test_librechat_integration.py | 9 +++++---- 2 files changed, 8 insertions(+), 7 deletions(-) diff --git a/integrations/librechat/qualification/qualify.py b/integrations/librechat/qualification/qualify.py index 4a28078950..0835745166 100644 --- a/integrations/librechat/qualification/qualify.py +++ b/integrations/librechat/qualification/qualify.py @@ -682,10 +682,10 @@ def check_help_citations( if name in cited: continue cited.append(name) - # A path help.get refuses outright (empty, or past its 300 characters as written) - # names no page. + # help.get answers 422 to a path past its 300 characters, which would stop the run: + # such a path names no page. path = m["path"].removeprefix("docs/") - if not path or len(m["path"]) > 300: + if len(m["path"]) > 300: invalid.append(f"{name}: no such page") continue # help.get strips `docs/` itself, once, as the bridge's check does: send the path as diff --git a/tests/unit/test_librechat_integration.py b/tests/unit/test_librechat_integration.py index 7f779a02c8..71a7713650 100644 --- a/tests/unit/test_librechat_integration.py +++ b/tests/unit/test_librechat_integration.py @@ -643,7 +643,7 @@ def side(correct, rank=None, cited=(), invalid=(), expected=None, abstained=Fals ] text = q.report(rows, "m") # Document rows stay out of the memory-key summary line. - assert "\nlibrechat: " not in text and "expected key cited" not in text + assert "\nlibrechat: " not in text and "expected source cited" not in text assert "2 answerable and 1 unanswerable cases; labeled section at rank 1 1/2" in text assert "within the top 5 2/2" in text assert ( @@ -1213,14 +1213,15 @@ def test_every_case_names_its_use_case_and_cites_pages_that_exist(case): assert (ROOT / "docs" / page).is_file() and not page.startswith("development/"), page -def test_a_help_citation_help_get_would_refuse_is_no_page(monkeypatch): +def test_a_help_citation_past_help_gets_limit_is_no_page(monkeypatch): q = _qualify() monkeypatch.setattr(q, "scorer_read", lambda *a: pytest.fail("help.get was called")) st = {"tokens": {"scorer:acme-handbook": "t"}} + long = "a/" * 150 + "x.md" cited, invalid, _ = q.check_help_citations( - st, {"namespace": "acme-handbook"}, {}, "[help:docs/]" + st, {"namespace": "acme-handbook"}, {}, f"[help:{long}]" ) - assert invalid == ["help:docs/: no such page"] + assert invalid == [f"help:{long}: no such page"] def test_a_failed_direct_read_of_the_no_docs_question_is_not_scored(): From a05ac3e2440f4cd6a844d64a624e372440074b18 Mon Sep 17 00:00:00 2001 From: zlareb1 Date: Wed, 11 Nov 2026 04:03:13 +0000 Subject: [PATCH 29/41] A direct path that cannot cite stays out of the cited count on failure too, and memory.clear is described by what it clears A failed read counts a labeled source as not cited only where the direct path could cite it (memory.search, help.search); data-history is left out either way. The erasure paragraph says memory.clear tombstones one agent's or user's memories in one namespace. The help citation check uses the cited path for both the length guard and help.get, and strips docs/ only at the page comparison. Co-Authored-By: Claude Opus 5.5 Signed-off-by: zlareb1 --- docs/features/memory/retention-and-erasure.md | 3 +-- integrations/librechat/qualification/qualify.py | 14 ++++++-------- tests/unit/test_librechat_integration.py | 8 ++++++++ 3 files changed, 15 insertions(+), 10 deletions(-) diff --git a/docs/features/memory/retention-and-erasure.md b/docs/features/memory/retention-and-erasure.md index 4df0f297c8..55b695a656 100644 --- a/docs/features/memory/retention-and-erasure.md +++ b/docs/features/memory/retention-and-erasure.md @@ -106,8 +106,7 @@ wins. nothing in scope is left. To erase everything one user id holds across the org, an org admin requests the `user_id` scope, which erases the user's rows in every namespace of the org (`purge=true` deletes them rather than tombstoning them; what it leaves is listed -below). -`memory.clear` tombstones one namespace's memories only +below). `memory.clear` tombstones one agent's or user's memories in one namespace only ([delete is not erase](#delete-is-not-erase)). | `scope_type` | `scope_value` | Who may request it | diff --git a/integrations/librechat/qualification/qualify.py b/integrations/librechat/qualification/qualify.py index 0835745166..cbed1cecdd 100644 --- a/integrations/librechat/qualification/qualify.py +++ b/integrations/librechat/qualification/qualify.py @@ -682,14 +682,11 @@ def check_help_citations( if name in cited: continue cited.append(name) - # help.get answers 422 to a path past its 300 characters, which would stop the run: - # such a path names no page. - path = m["path"].removeprefix("docs/") + # The path as cited: help.get strips one `docs/` itself, as the bridge's check does, + # and answers 422 past 300 characters, which would stop the run. if len(m["path"]) > 300: invalid.append(f"{name}: no such page") continue - # help.get strips `docs/` itself, once, as the bridge's check does: send the path as - # cited, so `docs/docs/…` is no page here either. page = scorer_read(st, scorer, "help.get", {"path": m["path"]}) if not page.get("found"): invalid.append(f"{name}: no such page") @@ -701,7 +698,7 @@ def check_help_citations( ): invalid.append(f"{name}: no such section") continue - expected = expected or path in pages + expected = expected or m["path"].removeprefix("docs/") in pages return cited, invalid, expected @@ -875,8 +872,9 @@ def native_score(case: dict[str, Any], code: int, out: dict[str, Any]) -> dict[s text = f"{code} {out.get('detail', out)}" # The direct path of a question the docs leave open is not scored, whatever answered. correct = None if case["kind"] == "help_abstain" else case["kind"] == "refusal" - # A failed read cites nothing: a labeled source counts as not cited. - expected = False if case.get("cite") or case.get("cite_help") else None + # A failed read cites nothing: a source it could have cited counts as not cited. + can_cite = (case.get("cite") and spec["op"] == "memory.search") or case.get("cite_help") + expected = False if can_cite else None elif spec["op"] == "memory.search": hits = out.get("results") or [] abstained = bool(out.get("abstain")) or not hits diff --git a/tests/unit/test_librechat_integration.py b/tests/unit/test_librechat_integration.py index 71a7713650..eb74df1272 100644 --- a/tests/unit/test_librechat_integration.py +++ b/tests/unit/test_librechat_integration.py @@ -1283,3 +1283,11 @@ def test_a_failed_direct_read_cites_no_labeled_source(): q.native_score(_case("help-revoke-token"), 503, {"detail": "x"})["cited_expected"] is False ) assert q.native_score(_case("memory-freeze"), 503, {"detail": "x"})["cited_expected"] is False + + +def test_a_case_whose_direct_path_cannot_cite_leaves_the_count_either_way(): + q = _qualify() + case = _case("data-history") + assert q.native_score(case, 503, {"detail": "x"})["cited_expected"] is None + two = {"rows": [{"version": 2}, {"version": 1}]} + assert q.native_score(case, 200, two)["cited_expected"] is None From 1c69ed97c9a4df04401286209cb1f6da305a7adb Mon Sep 17 00:00:00 2001 From: zlareb1 Date: Wed, 11 Nov 2026 04:11:34 +0000 Subject: [PATCH 30/41] A memory citation's read waits out a 429 and stops on a failure instead of marking the key invalid memory.get goes through scorer_read like every other scorer read: found:false marks the key invalid, and a read that fails says nothing about the answer. A settings family's * placeholder follows an underscore, so Markdown bold around a name is not one. Co-Authored-By: Claude Opus 5.5 Signed-off-by: zlareb1 --- .../librechat/qualification/qualify.py | 10 +++--- tests/unit/test_librechat_integration.py | 32 +++++++++++++++++++ 2 files changed, 38 insertions(+), 4 deletions(-) diff --git a/integrations/librechat/qualification/qualify.py b/integrations/librechat/qualification/qualify.py index cbed1cecdd..1f7851ef74 100644 --- a/integrations/librechat/qualification/qualify.py +++ b/integrations/librechat/qualification/qualify.py @@ -521,9 +521,11 @@ def history(key: str) -> set[int]: for key, version in memory_mentions(st, text): if key not in current: cited.append(key) - # A key that is not there is the answer's fault: it is marked invalid. - code, out, _ = loom_call(st["loom_url"], scorer, "memory.get", body(key)) - ok = code == 200 and out.get("found", True) and out.get("version") + # A key that is not there (found: false) is the answer's fault and is marked + # invalid; a read that fails says nothing about it, so scorer_read waits out a + # 429 and stops the run on anything else. + out = scorer_read(st, scorer, "memory.get", body(key)) + ok = out.get("found", True) and out.get("version") current[key] = int(out["version"]) if ok else None if current[key] is None: invalid.append(key) @@ -600,7 +602,7 @@ def parse_doc_citations(text: str) -> list[dict[str, Any]]: SETTING_RE = re.compile(r"\bLOOM_[A-Z0-9_]*[A-Z0-9](?![A-Z0-9_])") # A settings family a docs page writes with placeholders (`LOOM_RETENTION_
_DAYS`, # `LOOM_RETENTION_*`). -SETTING_FAMILY_RE = re.compile(r"\bLOOM_[A-Z0-9_]*(?:(?:<[A-Z]+>|\*)[A-Z0-9_]*)+") +SETTING_FAMILY_RE = re.compile(r"\bLOOM_[A-Z0-9_]*(?:(?:<[A-Z]+>|(?<=_)\*)[A-Z0-9_]*)+") # The kinds whose right answer is an abstention: from the namespace, or from the docs. ABSTAIN_KINDS = ("abstain", "help_abstain") diff --git a/tests/unit/test_librechat_integration.py b/tests/unit/test_librechat_integration.py index eb74df1272..31653fc002 100644 --- a/tests/unit/test_librechat_integration.py +++ b/tests/unit/test_librechat_integration.py @@ -1291,3 +1291,35 @@ def test_a_case_whose_direct_path_cannot_cite_leaves_the_count_either_way(): assert q.native_score(case, 503, {"detail": "x"})["cited_expected"] is None two = {"rows": [{"version": 2}, {"version": 1}]} assert q.native_score(case, 200, two)["cited_expected"] is None + + +def test_a_failed_memory_read_stops_the_check_rather_than_marking_the_key(monkeypatch): + q = _qualify() + calls = [] + + def fake_call(base, token, op, body): + calls.append(op) + return ( + (429, {"detail": {"retry_after_s": 0}}, 0.0) + if len(calls) == 1 + else ( + 200, + {"found": True, "version": 1793745407448901606}, + 0.0, + ) + ) + + monkeypatch.setattr(q, "loom_call", fake_call) + monkeypatch.setattr(q.time, "sleep", lambda s: None) + st = {"loom_url": "u", "tokens": {"scorer:acme-handbook": "t"}} + person = {"org": "acme", "namespace": "acme-handbook"} + text = "`policy/deploy/freeze` (version 1793745407448901606)" + assert q.check_citations(st, person, text) == (["policy/deploy/freeze"], []) + monkeypatch.setattr(q, "loom_call", lambda *a: (503, {"detail": "down"}, 0.0)) + with pytest.raises(SystemExit): + q.check_citations(st, person, "`policy/deploy/other`") + + +def test_markdown_bold_is_no_settings_family(): + q = _qualify() + assert q.SETTING_FAMILY_RE.findall("**LOOM_COLOUR** and LOOM_CH_*") == ["LOOM_CH_*"] From 361967971ac1b257eb979afc91963a1c37a55740 Mon Sep 17 00:00:00 2001 From: zlareb1 Date: Wed, 11 Nov 2026 04:19:02 +0000 Subject: [PATCH 31/41] The quickstart case fails a yes-then-needs-a-key answer, and a test holds every help case with a claim to a forbid MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit help-quickstart was the only help case with a claim and no forbid; it now fails 'Yes: … requires an API key', with that answer as its wrong sample. A parametrized test requires a forbid on every help case except the question the docs leave open. Co-Authored-By: Claude Opus 5.5 Signed-off-by: zlareb1 --- integrations/librechat/qualification/cases.json | 6 ++++-- tests/unit/test_librechat_integration.py | 6 ++++++ 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/integrations/librechat/qualification/cases.json b/integrations/librechat/qualification/cases.json index 6cbc8b9a0b..919d9e8124 100644 --- a/integrations/librechat/qualification/cases.json +++ b/integrations/librechat/qualification/cases.json @@ -1180,9 +1180,11 @@ "Yes. It won't run without your OpenAI key.", "Yes: you cannot use the quickstart without an API key.", "Yes. With no API key, the quickstart won't start.", - "Yes, the quickstart needs an OpenAI API key; search doesn't need a key." + "Yes, the quickstart needs an OpenAI API key; search doesn't need a key.", + "Yes: the quickstart requires an API key, though its embedder needs no key." ] - } + }, + "forbid": ["(^|[.!?:]\\s*)yes\\b[^.]{0,40}\\b(needs?|requires?)\\b"] }, { "id": "help-upgrade", diff --git a/tests/unit/test_librechat_integration.py b/tests/unit/test_librechat_integration.py index 31653fc002..c254855747 100644 --- a/tests/unit/test_librechat_integration.py +++ b/tests/unit/test_librechat_integration.py @@ -1323,3 +1323,9 @@ def fake_call(base, token, op, body): def test_markdown_bold_is_no_settings_family(): q = _qualify() assert q.SETTING_FAMILY_RE.findall("**LOOM_COLOUR** and LOOM_CH_*") == ["LOOM_CH_*"] + + +@pytest.mark.parametrize("case", _help_cases(), ids=lambda c: c["id"]) +def test_every_help_case_with_a_claim_forbids_its_denial(case): + # The question the docs leave open has no claim to deny; every other help case does. + assert case["kind"] == "help_abstain" or case.get("forbid"), case["id"] From b7661795391cfebed83aac28f215f0dc8a01a7d6 Mon Sep 17 00:00:00 2001 From: zlareb1 Date: Wed, 11 Nov 2026 04:28:20 +0000 Subject: [PATCH 32/41] A help abstention reads the agent's closing sentence, and the conflict forbid spares the page's own allowlist line HELP_ABSTAIN_PATTERNS takes 'Nothing stored in Loom', which agent.yaml ends an abstention with after its three searches. The conflict forbid fails a denial that the write is flagged, not the page's 'a pair on the allowlist is not flagged'; both have right samples. The 14-case sentence names data cases, and a duplicated comment is cut. Co-Authored-By: Claude Opus 5.5 Signed-off-by: zlareb1 --- docs/features/integrations/librechat.md | 6 +++--- integrations/librechat/qualification/cases.json | 8 +++++--- integrations/librechat/qualification/qualify.py | 5 +++-- 3 files changed, 11 insertions(+), 8 deletions(-) diff --git a/docs/features/integrations/librechat.md b/docs/features/integrations/librechat.md index 9639e2f5c6..a160e37e93 100644 --- a/docs/features/integrations/librechat.md +++ b/docs/features/integrations/librechat.md @@ -159,9 +159,9 @@ orgs, mints a token per person, revokes one, and scores each answer: | Model cost per answer, every prompt token at list price | at most $0.05 | mean $0.029; max $0.064 (`abstain-cfo`, three searches) misses the target | The LibreChat numbers are from one run of the 14 memory, inventory, inspect, tune, refusal -and abstention cases other than `data-history` and `data-connected-agents`, scored against -the current `cases.json` with `qualify.py rescore`; the direct-path numbers are from a -later run of that path alone (`qualify.py run --native-only`) on a fresh seed. The +and abstention data cases other than `data-history` and `data-connected-agents`, scored +against the current `cases.json` with `qualify.py rescore`; the direct-path numbers are +from a later run of that path alone (`qualify.py run --native-only`) on a fresh seed. The document cases below were run separately. The direct path answered the same 14 cases correctly at p50 0.08 s and p95 0.24 s with one diff --git a/integrations/librechat/qualification/cases.json b/integrations/librechat/qualification/cases.json index 919d9e8124..14abcc90fa 100644 --- a/integrations/librechat/qualification/cases.json +++ b/integrations/librechat/qualification/cases.json @@ -680,7 +680,8 @@ }, "samples": { "right": [ - "The new row is stored and flagged as a conflict; the namespace owner decides in the Review queue or with `conflicts.resolve`." + "The new row is stored and flagged as a conflict; the namespace owner decides in the Review queue or with `conflicts.resolve`.", + "The new row is stored and flagged as a conflict; the owner decides in the Review queue or with `conflicts.resolve`. A pair on the allowlist is not flagged." ], "wrong": [ "The new write overwrites the old one.", @@ -688,7 +689,7 @@ "Loom does not flag it; the new write wins with no Review queue entry or `conflicts.resolve`." ] }, - "forbid": ["\\b(does ?n[o']t|do not|never|is not|isn't) (flag|mark)\\w*"] + "forbid": ["(Loom|it|the (new )?write)\\s+(does ?n[o']t|do not|never) (flag|mark)"] }, { "id": "help-collection", @@ -1250,7 +1251,8 @@ "The dashboard has no colour theme setting.", "No Loom setting exists for the dashboard's colour theme.", "The dashboard's colour theme isn't configurable.", - "Loom's documentation does not cover it." + "Loom's documentation does not cover it.", + "Loom's memories, documents and documentation hold nothing about a dashboard colour theme. Nothing stored in Loom answers this." ], "wrong": [ "The docs don't cover it, but set `LOOM_DASHBOARD_COLOUR=dark`.", diff --git a/integrations/librechat/qualification/qualify.py b/integrations/librechat/qualification/qualify.py index 1f7851ef74..71530d2216 100644 --- a/integrations/librechat/qualification/qualify.py +++ b/integrations/librechat/qualification/qualify.py @@ -511,8 +511,7 @@ def body(key: str) -> dict[str, Any]: } def history(key: str) -> set[int]: - # The key exists (memory.get found it), so a failed history read says nothing about - # the answer: scorer_read waits out a 429 and stops the run on anything else. + # The key exists: a failed read says nothing about the answer. if key not in versions: rows = scorer_read(st, scorer, "memory.history", body(key)).get("rows") or [] versions[key] = {int(r["version"]) for r in rows if r.get("version")} @@ -594,6 +593,8 @@ def parse_doc_citations(text: str) -> list[dict[str, Any]]: r"\b(does ?n[o']t|do not) (have|offer|provide|expose) an? (\w+ ){0,3}(setting|option)", r"\bis ?n[o']t an? (\w+ ){0,3}(setting|option)", r"\b(could ?n[o']t|did ?n[o']t|can ?not) find\b", + # The sentence the agent ends an abstention with (agent.yaml), after all three searches. + r"\bnothing stored in loom\b", ) From c3291360c0f16d1bf2f5d45b878740c645b99a2e Mon Sep 17 00:00:00 2001 From: zlareb1 Date: Wed, 11 Nov 2026 04:29:26 +0000 Subject: [PATCH 33/41] A test holds every help forbid off the pages its case cites An answer that quotes its cited page must never trip the case's forbid; the test reads each cited page against each pattern. Co-Authored-By: Claude Opus 5.5 Signed-off-by: zlareb1 --- tests/unit/test_librechat_integration.py | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/tests/unit/test_librechat_integration.py b/tests/unit/test_librechat_integration.py index c254855747..d15cd5e3f1 100644 --- a/tests/unit/test_librechat_integration.py +++ b/tests/unit/test_librechat_integration.py @@ -1329,3 +1329,14 @@ def test_markdown_bold_is_no_settings_family(): def test_every_help_case_with_a_claim_forbids_its_denial(case): # The question the docs leave open has no claim to deny; every other help case does. assert case["kind"] == "help_abstain" or case.get("forbid"), case["id"] + + +@pytest.mark.parametrize( + "case", [c for c in _help_cases() if c.get("forbid")], ids=lambda c: c["id"] +) +def test_no_help_forbid_matches_the_pages_the_case_cites(case): + # An answer that quotes its own page must never trip the case's forbid. + for page in case["cite_help"]: + text = (ROOT / "docs" / page).read_text(encoding="utf-8") + for pattern in case["forbid"]: + assert not re.search(pattern, text, re.IGNORECASE | re.MULTILINE), (page, pattern) From 9a87ad3e957bab6a24e72872e3c3ae0a5402e458 Mon Sep 17 00:00:00 2001 From: zlareb1 Date: Wed, 11 Nov 2026 04:38:29 +0000 Subject: [PATCH 34/41] The assistant-health label no longer takes the problem's own name as a failure, and the guide counts the uncited answers by kind A fail word inside assistant_service_failing satisfied the label; the failure must now be its own word, with wrong samples that write the name. The twelve answers with no memory, document or help citation are two refusals, three abstentions, three SQL analyses (which cite their statement) and four counts; the mentor.guide miss is the harness marking the page invalid. Co-Authored-By: Claude Opus 5.5 Signed-off-by: zlareb1 --- docs/features/integrations/librechat.md | 8 ++++---- integrations/librechat/qualification/cases.json | 7 +++++-- 2 files changed, 9 insertions(+), 6 deletions(-) diff --git a/docs/features/integrations/librechat.md b/docs/features/integrations/librechat.md index a160e37e93..5c52097406 100644 --- a/docs/features/integrations/librechat.md +++ b/docs/features/integrations/librechat.md @@ -274,15 +274,15 @@ counting every prompt token, a mean of $0.053 per answer. The figures take 14 ca memory, nine document and two help cases) from one run and the other 42 from a full run, on agent definitions that differ from `integrations/librechat/agent.yaml` in one sentence on the asker's role, and for the full run also in the wording of the first step's -searches. Twelve answers cite nothing: two refusals, three abstentions and seven -counts, which come from tallies with no row to cite; every other answer cites one. The -misses: +searches. Twelve answers cite no memory, document or help page: two refusals, three +abstentions, three SQL analyses (which cite their statement instead) and four counts, +which come from tallies with no row to cite; every other answer cites one. The misses: - `doc-cache-entries` asks for a value one of the namespace's documents holds (`config/cache.toml`); the answer searches Loom's own documentation instead and does not find it: the question and Loom's settings share their words. - Two recommendation answers cite `mentor.guide`, Loom's writing guide, as a docs page, - which the check marks unverified: the guide has no citation form. + which the harness marks invalid (no such page): the guide has no citation form. - One answer names a section the page does not have. Answers vary from run to run at this model. A question about the person's own data that diff --git a/integrations/librechat/qualification/cases.json b/integrations/librechat/qualification/cases.json index 14abcc90fa..0b2d307f59 100644 --- a/integrations/librechat/qualification/cases.json +++ b/integrations/librechat/qualification/cases.json @@ -846,7 +846,7 @@ "question": "What does the health problem assistant_service_failing mean?", "expect": [ "LibreChat", - "(set ?up|setup|regist\\w*|sign-?in|creat\\w*)[^.]{0,80}(fail|could ?n[o']t|did ?n[o']t)|fail\\w*[^.]{0,80}(set ?up|setup|regist|sign-?in)|fail\\w*[^.]{0,80}retr(y|ies)|retr(y|ies)[^.]{0,40}(set ?up|regist)" + "(set ?up|setup|regist\\w*|sign-?in|creat\\w*)[^.]{0,80}((? Date: Wed, 11 Nov 2026 04:39:37 +0000 Subject: [PATCH 35/41] A test holds every help label off its own question No expected pattern may match the question's text, so an answer that only repeats a name the question gives (a setting, a health problem) states nothing. Co-Authored-By: Claude Opus 5.5 Signed-off-by: zlareb1 --- tests/unit/test_librechat_integration.py | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/tests/unit/test_librechat_integration.py b/tests/unit/test_librechat_integration.py index d15cd5e3f1..1d41897713 100644 --- a/tests/unit/test_librechat_integration.py +++ b/tests/unit/test_librechat_integration.py @@ -1340,3 +1340,10 @@ def test_no_help_forbid_matches_the_pages_the_case_cites(case): text = (ROOT / "docs" / page).read_text(encoding="utf-8") for pattern in case["forbid"]: assert not re.search(pattern, text, re.IGNORECASE | re.MULTILINE), (page, pattern) + + +@pytest.mark.parametrize("case", _help_cases(), ids=lambda c: c["id"]) +def test_no_help_label_is_met_by_repeating_the_question(case): + # An answer that only echoes the question (a setting or problem name in it) states nothing. + for pattern in case["expect"]: + assert not re.search(pattern, case["question"], re.IGNORECASE), pattern From d33d48bac0230b706b107287f8b2b3ed0ac86a09 Mon Sep 17 00:00:00 2001 From: zlareb1 Date: Wed, 11 Nov 2026 04:46:27 +0000 Subject: [PATCH 36/41] A server with no docs stops the help checks instead of failing every answer, and the first table's 14 cases are named help.get and help.search answer available:false on a server with no docs; the harness stops there, as the bridge reports the check as not run, rather than mark every help citation invalid and every direct path wrong. The guide names the two memory abstentions among the 14 cases. Co-Authored-By: Claude Opus 5.5 Signed-off-by: zlareb1 --- docs/features/integrations/librechat.md | 11 ++++++----- integrations/librechat/qualification/qualify.py | 7 +++++++ tests/unit/test_librechat_integration.py | 13 +++++++++++++ 3 files changed, 26 insertions(+), 5 deletions(-) diff --git a/docs/features/integrations/librechat.md b/docs/features/integrations/librechat.md index 5c52097406..0f6357650b 100644 --- a/docs/features/integrations/librechat.md +++ b/docs/features/integrations/librechat.md @@ -158,11 +158,12 @@ orgs, mints a token per person, revokes one, and scores each answer: | Tool calls per question | at most 3 | at most 3, 16 in all | | Model cost per answer, every prompt token at list price | at most $0.05 | mean $0.029; max $0.064 (`abstain-cfo`, three searches) misses the target | -The LibreChat numbers are from one run of the 14 memory, inventory, inspect, tune, refusal -and abstention data cases other than `data-history` and `data-connected-agents`, scored -against the current `cases.json` with `qualify.py rescore`; the direct-path numbers are -from a later run of that path alone (`qualify.py run --native-only`) on a fresh seed. The -document cases below were run separately. +The LibreChat numbers are from one run of the 14 memory, inventory, inspect, tune and +refusal cases and memory abstentions (`abstain-wifi`, `abstain-cfo`), other than +`data-history` and `data-connected-agents`, scored against the current `cases.json` with +`qualify.py rescore`; the direct-path numbers are from a later run of that path alone +(`qualify.py run --native-only`) on a fresh seed. The document cases below were run +separately. The direct path answered the same 14 cases correctly at p50 0.08 s and p95 0.24 s with one read each. The model adds natural-language questions and a written answer; it costs seconds diff --git a/integrations/librechat/qualification/qualify.py b/integrations/librechat/qualification/qualify.py index 71530d2216..b213ce0138 100644 --- a/integrations/librechat/qualification/qualify.py +++ b/integrations/librechat/qualification/qualify.py @@ -691,6 +691,11 @@ def check_help_citations( invalid.append(f"{name}: no such page") continue page = scorer_read(st, scorer, "help.get", {"path": m["path"]}) + if not page.get("available", True): + # A server with no docs cannot check the citation; that says nothing about it. + sys.exit( + "help.get: this server has no documentation, so help citations cannot be checked" + ) if not page.get("found"): invalid.append(f"{name}: no such page") continue @@ -861,6 +866,8 @@ def baseline(st: dict[str, Any], case: dict[str, Any], person: dict[str, Any]) - **ASSISTANT_FORCED_ARGS.get(spec["op"], {}), } code, out, elapsed = loom_call(st["loom_url"], st["tokens"][person["name"]], spec["op"], body) + if spec["op"] == "help.search" and code == 200 and not out.get("available", True): + sys.exit("help.search: this server has no documentation, so the help cases cannot run") return {**native_score(case, code, out), "latency_s": elapsed, "ttft_s": elapsed} diff --git a/tests/unit/test_librechat_integration.py b/tests/unit/test_librechat_integration.py index 1d41897713..71fdb6aeb8 100644 --- a/tests/unit/test_librechat_integration.py +++ b/tests/unit/test_librechat_integration.py @@ -1347,3 +1347,16 @@ def test_no_help_label_is_met_by_repeating_the_question(case): # An answer that only echoes the question (a setting or problem name in it) states nothing. for pattern in case["expect"]: assert not re.search(pattern, case["question"], re.IGNORECASE), pattern + + +def test_a_server_without_docs_stops_the_help_checks(monkeypatch): + q = _qualify() + monkeypatch.setattr(q, "scorer_read", lambda *a: {"available": False, "found": False}) + st = {"tokens": {"scorer:acme-handbook": "t"}} + with pytest.raises(SystemExit, match="no documentation"): + q.check_help_citations(st, {"namespace": "acme-handbook"}, {}, "[help:a.md]") + monkeypatch.setattr(q, "loom_call", lambda *a: (200, {"available": False, "hits": []}, 0.0)) + st = {"loom_url": "u", "tokens": {"alice": "t"}} + person = {"name": "alice", "org": "acme", "namespace": "acme-handbook"} + with pytest.raises(SystemExit, match="no documentation"): + q.baseline(st, _case("help-revoke-token"), person) From 14c63e797b6dc9ec4dd7331706e058efd43a9482 Mon Sep 17 00:00:00 2001 From: zlareb1 Date: Wed, 11 Nov 2026 04:55:05 +0000 Subject: [PATCH 37/41] A run with help cases checks for docs before its first model answer, and the assistant-health label takes the architecture page's wording require_docs asks help.search once and stops on available:false, so no answer is paid for and then discarded. The health label accepts LibreChat refusing the sign-in and a sealed value neither secret opens, as architecture/assistant.md words the failures. Co-Authored-By: Claude Opus 5.5 Signed-off-by: zlareb1 --- .../librechat/qualification/cases.json | 5 +++-- .../librechat/qualification/qualify.py | 19 ++++++++++++++++--- tests/unit/test_librechat_integration.py | 12 ++++++++++++ 3 files changed, 31 insertions(+), 5 deletions(-) diff --git a/integrations/librechat/qualification/cases.json b/integrations/librechat/qualification/cases.json index 0b2d307f59..a624cb18f6 100644 --- a/integrations/librechat/qualification/cases.json +++ b/integrations/librechat/qualification/cases.json @@ -846,7 +846,7 @@ "question": "What does the health problem assistant_service_failing mean?", "expect": [ "LibreChat", - "(set ?up|setup|regist\\w*|sign-?in|creat\\w*)[^.]{0,80}((? dict[str } +def require_docs(st: dict[str, Any], people: dict[str, Any], cases: list[dict[str, Any]]) -> None: + """Stop before the first model answer when help cases are selected and the server ships + no docs: every help answer would be paid for and then not checkable.""" + help_cases = [c for c in cases if is_help_case(c)] + if not help_cases: + return + person = people[help_cases[0]["person"]] + body = {"org": person["org"], "namespace": person["namespace"], "query": "loom", "limit": 1} + code, out, _ = loom_call(st["loom_url"], st["tokens"][person["name"]], "help.search", body) + if code == 200 and not out.get("available", True): + sys.exit("help.search: this server has no documentation, so the help cases cannot run") + + def cmd_run(args: argparse.Namespace) -> None: st = state() people = {p["name"]: p for p in load("fixture.json")["people"]} if args.native_only: run_native_only(st, people, args) return + cases = [c for c in load("cases.json") if not args.only or c["id"] in args.only] + require_docs(st, people, cases) rows = [] - for case in load("cases.json"): - if args.only and case["id"] not in args.only: - continue + for case in cases: person = people[case["person"]] native = baseline(st, case, person) t0 = time.time() diff --git a/tests/unit/test_librechat_integration.py b/tests/unit/test_librechat_integration.py index 71fdb6aeb8..7bd2d2a281 100644 --- a/tests/unit/test_librechat_integration.py +++ b/tests/unit/test_librechat_integration.py @@ -1360,3 +1360,15 @@ def test_a_server_without_docs_stops_the_help_checks(monkeypatch): person = {"name": "alice", "org": "acme", "namespace": "acme-handbook"} with pytest.raises(SystemExit, match="no documentation"): q.baseline(st, _case("help-revoke-token"), person) + + +def test_a_run_with_help_cases_checks_for_docs_before_any_answer(monkeypatch): + import argparse + + q = _qualify() + monkeypatch.setattr(q, "state", lambda: {"loom_url": "u", "tokens": {"alice": "t"}}) + monkeypatch.setattr(q, "loom_call", lambda *a: (200, {"available": False, "hits": []}, 0.0)) + monkeypatch.setattr(q, "ask_assistant", lambda *a: pytest.fail("a model answer was asked for")) + args = argparse.Namespace(native_only=False, only=["help-revoke-token"], out="unused") + with pytest.raises(SystemExit, match="no documentation"): + q.cmd_run(args) From 1d36524152fe43cec18cf8720a6defe21dcd6015 Mon Sep 17 00:00:00 2001 From: zlareb1 Date: Wed, 11 Nov 2026 05:06:31 +0000 Subject: [PATCH 38/41] require_docs owns the no-docs rule and runs before every run Any answer may cite a help page, so the docs check runs before a run of any cases, and native-only calls it too; baseline no longer repeats it. use_case is read directly where every case carries one. Co-Authored-By: Claude Opus 5.5 Signed-off-by: zlareb1 --- .../librechat/qualification/qualify.py | 34 +++++++++---------- tests/unit/test_librechat_integration.py | 6 ++-- 2 files changed, 20 insertions(+), 20 deletions(-) diff --git a/integrations/librechat/qualification/qualify.py b/integrations/librechat/qualification/qualify.py index 5348dffeef..6f331d8713 100644 --- a/integrations/librechat/qualification/qualify.py +++ b/integrations/librechat/qualification/qualify.py @@ -866,8 +866,6 @@ def baseline(st: dict[str, Any], case: dict[str, Any], person: dict[str, Any]) - **ASSISTANT_FORCED_ARGS.get(spec["op"], {}), } code, out, elapsed = loom_call(st["loom_url"], st["tokens"][person["name"]], spec["op"], body) - if spec["op"] == "help.search" and code == 200 and not out.get("available", True): - sys.exit("help.search: this server has no documentation, so the help cases cannot run") return {**native_score(case, code, out), "latency_s": elapsed, "ttft_s": elapsed} @@ -972,16 +970,15 @@ def native_document_score(case: dict[str, Any], out: dict[str, Any]) -> dict[str def require_docs(st: dict[str, Any], people: dict[str, Any], cases: list[dict[str, Any]]) -> None: - """Stop before the first model answer when help cases are selected and the server ships - no docs: every help answer would be paid for and then not checkable.""" - help_cases = [c for c in cases if is_help_case(c)] - if not help_cases: + """Stop before the first read when the server ships no docs: any answer may cite a help + page, and a help citation or a help case cannot be checked then.""" + if not cases: return - person = people[help_cases[0]["person"]] + person = people[cases[0]["person"]] body = {"org": person["org"], "namespace": person["namespace"], "query": "loom", "limit": 1} code, out, _ = loom_call(st["loom_url"], st["tokens"][person["name"]], "help.search", body) if code == 200 and not out.get("available", True): - sys.exit("help.search: this server has no documentation, so the help cases cannot run") + sys.exit("help.search: this server has no documentation, so its help cannot be checked") def cmd_run(args: argparse.Namespace) -> None: @@ -1007,7 +1004,7 @@ def cmd_run(args: argparse.Namespace) -> None: { "id": case["id"], "kind": case["kind"], - "use_case": case.get("use_case", ""), + "use_case": case["use_case"], "documents": is_document_case(case), "librechat": { **got, @@ -1075,14 +1072,15 @@ def run_native_only(st: dict[str, Any], people: dict[str, Any], args: argparse.N sys.exit(f"{out} is missing: --native-only replaces the native side of a saved run") saved = json.loads(out.read_text()) rows = {r["id"]: r for r in saved["rows"]} - for case in load("cases.json"): - if case["id"] in rows and (not args.only or case["id"] in args.only): - rows[case["id"]]["use_case"] = case.get("use_case", "") - rows[case["id"]]["native"] = baseline(st, case, people[case["person"]]) - native = rows[case["id"]]["native"] - print( - f"{case['id']:<28} native {verdict(native['correct'])} {native['latency_s']:.2f}s" - ) + cases = [ + c for c in load("cases.json") if c["id"] in rows and (not args.only or c["id"] in args.only) + ] + require_docs(st, people, cases) + for case in cases: + rows[case["id"]]["use_case"] = case["use_case"] + rows[case["id"]]["native"] = baseline(st, case, people[case["person"]]) + native = rows[case["id"]]["native"] + print(f"{case['id']:<28} native {verdict(native['correct'])} {native['latency_s']:.2f}s") out.write_text(json.dumps(saved, indent=2)) print(report(saved["rows"], saved.get("model", ""))) @@ -1103,7 +1101,7 @@ def cmd_rescore(args: argparse.Namespace) -> None: lc = row["librechat"] case = cases[row["id"]] text = lc["answer"] or lc["error"] - row["use_case"] = case.get("use_case", "") + row["use_case"] = case["use_case"] lc.update(score_answer(case, lc)) if args.citations: lc.update(answer_citations(st, case, people[case["person"]], text)) diff --git a/tests/unit/test_librechat_integration.py b/tests/unit/test_librechat_integration.py index 7bd2d2a281..0add5cbf72 100644 --- a/tests/unit/test_librechat_integration.py +++ b/tests/unit/test_librechat_integration.py @@ -1157,6 +1157,7 @@ def test_native_only_takes_the_cases_current_use_case_labels(monkeypatch, tmp_pa q = _qualify() side = _saved_side("ok") monkeypatch.setattr(q, "baseline", lambda st, case, person: side) + monkeypatch.setattr(q, "require_docs", lambda st, people, cases: None) out = tmp_path / "results.json" row = {"id": "help-revoke-token", "kind": "help", "librechat": side, "native": side} out.write_text(json.dumps({"model": "m", "bridge": True, "rows": [row]})) @@ -1357,9 +1358,10 @@ def test_a_server_without_docs_stops_the_help_checks(monkeypatch): q.check_help_citations(st, {"namespace": "acme-handbook"}, {}, "[help:a.md]") monkeypatch.setattr(q, "loom_call", lambda *a: (200, {"available": False, "hits": []}, 0.0)) st = {"loom_url": "u", "tokens": {"alice": "t"}} - person = {"name": "alice", "org": "acme", "namespace": "acme-handbook"} + people = {p["name"]: p for p in q.load("fixture.json")["people"]} + # A data case can cite a help page too, so even a run of data cases stops first. with pytest.raises(SystemExit, match="no documentation"): - q.baseline(st, _case("help-revoke-token"), person) + q.require_docs(st, people, [_case("memory-freeze")]) def test_a_run_with_help_cases_checks_for_docs_before_any_answer(monkeypatch): From 217f0d7716f2cd3c990c3aced2d6387e052a7190 Mon Sep 17 00:00:00 2001 From: zlareb1 Date: Wed, 11 Nov 2026 05:13:17 +0000 Subject: [PATCH 39/41] The docs probe reads with the scorer's token and stops on any failure require_docs goes through scorer_read with the scorer token, so a revoked first person or a failed read stops the run instead of letting a no-docs run go on; it sends only help.search's own fields. Co-Authored-By: Claude Opus 5.5 Signed-off-by: zlareb1 --- .../librechat/qualification/qualify.py | 9 ++++---- tests/unit/test_librechat_integration.py | 22 +++++++++++++++++-- 2 files changed, 25 insertions(+), 6 deletions(-) diff --git a/integrations/librechat/qualification/qualify.py b/integrations/librechat/qualification/qualify.py index 6f331d8713..b0d476df07 100644 --- a/integrations/librechat/qualification/qualify.py +++ b/integrations/librechat/qualification/qualify.py @@ -974,10 +974,11 @@ def require_docs(st: dict[str, Any], people: dict[str, Any], cases: list[dict[st page, and a help citation or a help case cannot be checked then.""" if not cases: return - person = people[cases[0]["person"]] - body = {"org": person["org"], "namespace": person["namespace"], "query": "loom", "limit": 1} - code, out, _ = loom_call(st["loom_url"], st["tokens"][person["name"]], "help.search", body) - if code == 200 and not out.get("available", True): + # The scorer's token, through scorer_read: a 429 is waited out and any other failure + # stops the run, so a probe that cannot read never lets a no-docs run go on. + scorer = st["tokens"][f"scorer:{people[cases[0]['person']]['namespace']}"] + out = scorer_read(st, scorer, "help.search", {"query": "loom", "limit": 1}) + if not out.get("available", True): sys.exit("help.search: this server has no documentation, so its help cannot be checked") diff --git a/tests/unit/test_librechat_integration.py b/tests/unit/test_librechat_integration.py index 0add5cbf72..7b775de5ca 100644 --- a/tests/unit/test_librechat_integration.py +++ b/tests/unit/test_librechat_integration.py @@ -1357,7 +1357,7 @@ def test_a_server_without_docs_stops_the_help_checks(monkeypatch): with pytest.raises(SystemExit, match="no documentation"): q.check_help_citations(st, {"namespace": "acme-handbook"}, {}, "[help:a.md]") monkeypatch.setattr(q, "loom_call", lambda *a: (200, {"available": False, "hits": []}, 0.0)) - st = {"loom_url": "u", "tokens": {"alice": "t"}} + st = {"loom_url": "u", "tokens": {"scorer:acme-handbook": "t"}} people = {p["name"]: p for p in q.load("fixture.json")["people"]} # A data case can cite a help page too, so even a run of data cases stops first. with pytest.raises(SystemExit, match="no documentation"): @@ -1368,9 +1368,27 @@ def test_a_run_with_help_cases_checks_for_docs_before_any_answer(monkeypatch): import argparse q = _qualify() - monkeypatch.setattr(q, "state", lambda: {"loom_url": "u", "tokens": {"alice": "t"}}) + monkeypatch.setattr( + q, "state", lambda: {"loom_url": "u", "tokens": {"scorer:acme-handbook": "t"}} + ) monkeypatch.setattr(q, "loom_call", lambda *a: (200, {"available": False, "hits": []}, 0.0)) monkeypatch.setattr(q, "ask_assistant", lambda *a: pytest.fail("a model answer was asked for")) args = argparse.Namespace(native_only=False, only=["help-revoke-token"], out="unused") with pytest.raises(SystemExit, match="no documentation"): q.cmd_run(args) + + +def test_the_docs_probe_stops_the_run_when_it_cannot_read(monkeypatch): + q = _qualify() + sent = [] + + def fake_call(base, token, op, body): + sent.append((token, body)) + return 401, {"detail": "revoked"}, 0.0 + + monkeypatch.setattr(q, "loom_call", fake_call) + st = {"loom_url": "u", "tokens": {"scorer:acme-handbook": "scorer-token"}} + people = {p["name"]: p for p in q.load("fixture.json")["people"]} + with pytest.raises(SystemExit): + q.require_docs(st, people, [_case("revoked-token"), _case("help-revoke-token")]) + assert sent == [("scorer-token", {"query": "loom", "limit": 1})] From 7663b4c29e3dfdc3dbe2a332dd3ebd25d36a3f5b Mon Sep 17 00:00:00 2001 From: zlareb1 Date: Wed, 11 Nov 2026 05:20:13 +0000 Subject: [PATCH 40/41] The guide says how the direct LibreChat path counts a quoted example key, and two test names match what they hold Outside the assistant route any key-shaped text is a memory citation, so a help answer quoting the docs' example key counts it invalid there; the help figures come from the assistant route. The docs-probe test is named for every run, and a comment says 'straight through LibreChat' rather than 'direct path'. Co-Authored-By: Claude Opus 5.5 Signed-off-by: zlareb1 --- docs/features/integrations/librechat.md | 4 +++- tests/unit/test_librechat_integration.py | 5 +++-- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/docs/features/integrations/librechat.md b/docs/features/integrations/librechat.md index 0f6357650b..0a5d88f1d1 100644 --- a/docs/features/integrations/librechat.md +++ b/docs/features/integrations/librechat.md @@ -141,7 +141,9 @@ orgs, mints a token per person, revokes one, and scores each answer: and a version written next to it is the row's current version, or, for a question about the key's history (`cite_history`), one of its earlier versions. Through Loom's assistant route a memory citation is `[memory:@v]`; otherwise it is any key-shaped - text outside a `[help:]` citation. + text outside a `[help:]` citation, so on that path a help answer that quotes the docs' + example key counts it as an invalid memory citation; the help figures below come from + the assistant route. - **tool calls:** the `mcp` rows Loom ledgered under the person's subject during the answer. - **latency and time to first token:** end to end, and to the first streamed delta, which for the harness's own agent (`setup`) is the model's one-line preamble before its first diff --git a/tests/unit/test_librechat_integration.py b/tests/unit/test_librechat_integration.py index 7b775de5ca..b22746fa03 100644 --- a/tests/unit/test_librechat_integration.py +++ b/tests/unit/test_librechat_integration.py @@ -854,7 +854,8 @@ def fake_call(base, token, op, body): "Keys look like `scope/kind/id` [help:features/memory/writing.md § Keys]. " "The freeze: [memory:policy/deploy/freeze@v1793745407448901606]." ) - # A help page's path is no key; on the direct path a quoted example still reads as one. + # A help page's path is no key; straight through LibreChat (no bridge) a quoted example + # still reads as one. assert q.check_citations(st, person, text)[0] == ["scope/kind/id", "policy/deploy/freeze"] # Through the bridge only a `[memory:]` citation is a memory citation. asked.clear() @@ -1364,7 +1365,7 @@ def test_a_server_without_docs_stops_the_help_checks(monkeypatch): q.require_docs(st, people, [_case("memory-freeze")]) -def test_a_run_with_help_cases_checks_for_docs_before_any_answer(monkeypatch): +def test_a_run_checks_for_docs_before_any_answer(monkeypatch): import argparse q = _qualify() From 80a861f21e80e0d7106b5dd48f796b6e6560cdb9 Mon Sep 17 00:00:00 2001 From: zlareb1 Date: Wed, 11 Nov 2026 05:26:05 +0000 Subject: [PATCH 41/41] The direct LibreChat agent names the help tools as LibreChat lists them Through LibreChat the help tools are loom_help_search_mcp_loom and loom_help_get_mcp_loom, as agent.yaml says of every Loom tool; the setup instructions now use those names. Co-Authored-By: Claude Opus 5.5 Signed-off-by: zlareb1 --- integrations/librechat/qualification/qualify.py | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/integrations/librechat/qualification/qualify.py b/integrations/librechat/qualification/qualify.py index b0d476df07..5a929563e0 100644 --- a/integrations/librechat/qualification/qualify.py +++ b/integrations/librechat/qualification/qualify.py @@ -242,12 +242,12 @@ def cmd_revoke(args: argparse.Namespace) -> None: (leave it out when the hit has none), for example [guides/setup.md § Setup > Install]. Add the revision, as in [guides/setup.md § Setup > Install, revision 3], only when a tool returned that document's revision number; never write a revision no tool returned. -For a question about how Loom itself works, search Loom's documentation with help_search -and read a section with help_get; cite each passage as [help: §
], the -section as the hit gives it. When the tools return nothing relevant, say it is not stored -in Loom, or, for a question about Loom itself, that Loom's documentation does not cover it. -When a tool call fails, say that it failed and quote the error. Never answer from your own -knowledge.""" +For a question about how Loom itself works, search Loom's documentation with +loom_help_search_mcp_loom and read a section with loom_help_get_mcp_loom; cite each passage +as [help: §
], the section as the hit gives it. When the tools return nothing +relevant, say it is not stored in Loom, or, for a question about Loom itself, that Loom's +documentation does not cover it. When a tool call fails, say that it failed and quote the +error. Never answer from your own knowledge.""" def lc_login(lc: httpx.Client, email: str, password: str) -> str: