LightRAG Knowledge Hub · Email Agent
Four agents pull evidence from one knowledge hub, and only evidence-backed email drafts reach staff drafts folders
Vendor CS, influencer CS, Spark, and sales partner matching share one LightRAG knowledge hub (13 workspaces). It is a RAG store: for each question it finds material first and answers with it attached. Every workspace carries a description, owner, channel, and sensitivity level, and a write to an unknown workspace fails immediately. For inquiries to the shared mailbox, it puts an evidence-backed reply draft in the owner's Gmail drafts folder. Staff do the sending.
- The server will not start if workspace names drift. If each agent calls a workspace by a different name, writes can land in the wrong store. The 13 canonical names are fixed as a Literal type, and ~50 aliases each resolve to one store. If a missing entry or store mismatch shows up at module import, startup halts with a RuntimeError.
- An LLM search plan is used only after it passes validation. Plans are checked with Pydantic. Live DB lookups are allowed only for registered (project, table) pairs, GET only, up to 500 rows. If any one of the call, the parse, or the allowlist check fails, it falls back to the rule router. The reason is logged as fallback:<exception name>.
- If rerank fails, two more stages stand in. Documents are cut to 20, then the LLM reranker runs first. If it fails, FlashRank runs; if that fails too, the original order is scored, so results always come back. I lowered search-stage concurrency to 3. That cut concurrent Neo4j writes in the merge stage from 8 to 6 per document.
- 13 draft checkers, each owning one error pattern. Patterns include reversing the direction of a request, citing a previous email that never existed, re-asking a confirmed condition, and writing a proposed price as if it were final. Each checker includes reproduction cases from real emails of 08-21~08-23. They started as regexes, but false positives kept coming, so judgment moved to LLM checkers.
- A fix that introduces a new falsehood is rejected. Comparing only the sum of violation scores lets a 2-point factual violation pass as the price of fixing a 10-point forbidden word. So if a rewritten draft has a factual violation that was not there before, the rewrite is discarded even if it fixed other violations. Violations that remain after rewriting are logged as "Draft rejected" by type, and the draft is dropped.
- The evidence bundle is sent once. Each time 6 claims were verified, the evidence bundle of up to 150,000 characters was being resent. The bundle is now cached for 5 minutes under a sha256 key and reused. If the cache fails it falls back to the original path, so verdicts do not change.
- The sent-mail cursor accounts for Gmail lag. At rollout, 48 of 1,943 sent emails were missed by learning. Now it reads in 10-minute windows and saves the cursor after each window. Because the search index picks up mail late, the cursor stays 180 seconds behind now, and window boundaries overlap by 90 seconds. For a window with more than 500 emails, the cursor does not advance.
- The server decides the scope of facts staff correct. Server rules decide whether a corrected fact applies company-wide or to a single deal. A single-deal fact is never widened to the whole partner. Results only accumulate in an append-only observation log, running in shadow mode: not used for drafts or search.
- 13 knowledge workspaces