Context as Infrastructure: Knowledge Compilation for Retrieval in Agentic Systems with Harnesses
Abstract: Retrieval-augmented generation is becoming agentic. A search harness writes queries, reads results, reformulates, and decides when to stop. This largely solves accuracy: a harness with only BM25/grep and MiniMax M3 answers 85% of BrowseComp-Plus and 91% on multi-hop FRAMES in our runs, without compiled or vector indexes. It exposes a context problem: an undisciplined loop repeats queries, rereads documents, and fills the window with unused passages. The missing layer is knowledge compilation: a configurable ingestion pipeline where LLMs enrich documents with context no chunk contains alone--navigation hierarchies with claim-evidence leaves, entity graphs, timelines, mind maps, ontologies, wikis, and memory. Compilation is not a better retriever: under a competent harness, structural artifacts gave no detectable accuracy gain on FRAMES, and a PageIndex-style outline degraded at scale. It is a supply layer. A navigation tree whose leaves are claim-evidence pairs--the mechanism we measure--cuts query tokens by 91% when evidence suffices and adds 1.9% when it does not, a 38% average reduction; this implies a 2% break-even sufficiency rate and a measured rate near 43%. A decision gate cuts latency from 140 s to 30 s, though substitution's token saving is bought with retrieval rounds and carries its own latency cost. Other artifacts--ontology, graph, wiki, timeline, mind map, memory--pay off in deployment (governance, integration, onboarding, temporal orientation, continuity) where accuracy benchmarks cannot see them. We describe RAGFlow's pipeline and harness (open source at https://github.com/infiniflow/ragflow), which turns the loop into five disciplined stations and keeps the context entering the model the smallest sufficient set; together they form an agent-native database: a store that hands the agent compiled, governed context instead of a ranked list of passages.
First 10 authors:
Paper Prompts
Sign up for free to create and run prompts on this paper.
Explain it Like I'm 14
1. What is this paper about?
This paper explains how to help AI systems answer questions using large collections of documents.
The main system discussed is called retrieval-augmented generation, or RAG. A RAG system first searches for useful information and then gives that information to a LLM, which writes an answer.
The authors focus on a newer kind of RAG in which an AI “agent” searches repeatedly. It can:
- Write a search query.
- Read the results.
- Decide what information is missing.
- Search again.
- Stop when it has enough evidence.
The paper argues that finding information is no longer the biggest problem. The bigger problem is deciding what information the AI should actually read and remember.
To solve this, the authors propose knowledge compilation. This means preparing documents in advance by creating useful additions such as:
- Short claims connected to exact evidence
- Tables of contents and navigation trees
- Entity-and-relationship graphs
- Timelines
- Ontologies, or organized vocabularies
- Wikis and summaries
- Memory from earlier conversations
The authors describe this as building an agent-native database: a database designed to give an AI carefully prepared and trustworthy context, rather than simply returning a list of search results.
2. What questions does the research ask?
The paper investigates several main questions:
- Can a simple search system using tools such as
grepand BM25 work well when controlled by a capable AI agent? - If searching already works, what is still missing?
- Can prepared information help the AI use fewer words, or tokens, when answering?
- Which kinds of prepared information are actually useful?
- Do navigation trees, graphs, summaries, and other structures improve answer accuracy?
- How can the system avoid repeatedly reading the same information?
- When does the cost of preparing documents become worthwhile?
In simple terms, the authors are asking:
Is it more useful to improve the search engine, or to improve the way information is prepared and delivered to the AI?
Their answer is that both parts matter, but they do different jobs:
- The search harness controls the search process.
- Knowledge compilation prepares useful information ahead of time.
3. How was the research carried out?
Searching with a “harness”
The paper uses a retrieval harness. A harness is like a coach or control system that manages an AI agent while it searches.
The harness decides:
- Which search tools the agent may use
- How many searches it can perform
- Whether it should read more deeply
- Whether it has enough evidence to answer
- When it should stop
The system mainly uses:
- BM25: a traditional method for matching search words with words in documents
grep: a fast tool for finding exact words or patterns in files
Unlike many RAG systems, the authors do not use a vector index. A vector index turns text into numbers so that similar meanings can be matched. The authors say that, in their experiments, adding this kind of search did not improve results and sometimes made them worse.
Preparing documents in advance
The authors create a six-step preparation process:
- Parse: Convert PDFs, web pages, Word files, tables, and other formats into a common form.
- Chunk: Break documents into smaller pieces.
- Enrich: Use an AI model to identify claims, people, events, relationships, or important terms.
- Validate: Check that the generated information really appears in the original document.
- Assemble: Organize the information into trees, graphs, timelines, or other structures.
- Register: Store where each piece came from, which version of the document was used, and whether it passed checking.
This is similar to making a study guide from a textbook. However, the system keeps links back to the exact sentences in the original textbook, so someone can check whether the study guide is correct.
Claim–evidence pairs
The most carefully tested method uses claim–evidence pairs.
A claim–evidence pair contains:
- A short statement of a fact
- The exact sentence or part of the document that supports it
- The location of that sentence in the original source
- Extra information, such as the document date
For example:
| Claim | Evidence |
|---|---|
| The school opened in 1995. | “The school officially opened in September 1995.” |
The AI is not allowed to keep a claim unless it can find the exact supporting words in the source. This helps prevent made-up information.
Testing the system
The authors tested the system on question-answering benchmarks, including:
- BrowseComp-Plus
- FRAMES, which contains questions requiring several steps of reasoning
They compared systems with and without compiled information. They measured:
- Answer accuracy
- Number of tokens used
- Search time
- Whether the system could provide evidence for its answers
They also tested several types of compiled information, including navigation trees, graphs, wikis, timelines, and memory. However, the paper carefully says that many of these were not yet tested in real-world deployments.
4. What did the researchers find?
Simple search can already be surprisingly strong
A search harness using only BM25 and grep, together with the MiniMax M3 LLM, achieved:
- About 85% accuracy on BrowseComp-Plus
- About 91% on the FRAMES benchmark
The authors warn that these two percentages cannot be directly compared because the benchmarks are different.
This result suggests that a smart AI agent using simple search can sometimes perform as well as, or better than, systems using more complicated search indexes.
Compiled evidence reduced the number of tokens
The strongest result came from replacing large document passages with short claim–evidence pairs.
When the prepared evidence was enough to answer the question:
- The system used 91% fewer query tokens.
When the prepared evidence was not enough:
- The system used about 1.9% more tokens, because it had to return to the original document.
Across the full FRAMES test:
- The average token use fell by about 38%.
Tokens are small pieces of text processed by a LLM. Using fewer tokens can make an AI system cheaper and sometimes faster.
The system became much faster with a decision gate
The researchers also added a decision gate. This is a small model that decides whether the AI needs to read a full document passage or whether the prepared evidence is sufficient.
With the gate:
- Average latency fell from about 140 seconds to 30 seconds.
In other words, the system became much quicker because it did not deeply read every passage it found.
Organization alone did not improve accuracy
The researchers found that structures such as:
- Summary trees
- PageIndex-style outlines
- Entity graphs
- Wikis
did not noticeably improve accuracy on the FRAMES benchmark.
In some cases, a document outline even made performance worse when the collection became large.
The reason is that a structure is not automatically evidence. A table of contents may help a person navigate a document, but it does not necessarily provide the answer. The authors therefore distinguish between:
- A carrier, which organizes information
- A payload, which contains actual evidence
A tree with only headings is a carrier. A tree whose leaves contain claim–evidence pairs has useful payload.
Different tools help in different situations
The paper says that different compiled artifacts should not all be judged by the same accuracy test.
For example:
- A timeline may help someone understand the order of events.
- A graph may help connect information from different documents.
- An ontology may make sure that different words, such as “customer” and “client,” are treated as related.
- A wiki may help new employees learn about a topic.
- Memory may help an AI remember earlier conversations.
- A navigation tree may help people find information more easily.
These benefits may not appear in a benchmark that only asks isolated questions. The authors have proposed ways to measure these real-world benefits, but they state that no deployment result has yet met their planned success targets.
The system needs strict rules
The paper also finds that an AI search loop can waste resources by:
- Repeating the same searches
- Reading the same document many times
- Keeping irrelevant passages
- Continuing to search after enough evidence has been found
The harness helps prevent this by:
- Setting search and token limits
- Removing unhelpful tools
- Discarding weak evidence
- Prefetching useful evidence
- Keeping track of sources
- Providing a fallback answer if the process stops unexpectedly
5. Why are these findings important?
The paper changes the way we might think about AI databases.
A traditional database or search engine mainly tries to return documents that might contain an answer. The system described here tries to return the smallest trustworthy set of information needed for the answer.
This is important because LLMs have limited attention. If they receive too much text, they may:
- Miss the important part
- Become confused
- Take longer to answer
- Cost more money to run
- Repeat information unnecessarily
Preparing evidence in advance can make the AI more efficient. It can also make answers easier to check because every claim is linked to its original source.
6. Overall implications and possible impact
The paper suggests that the future of AI information systems may involve two connected layers:
- Knowledge compilation, which prepares and organizes information before questions are asked.
- A retrieval harness, which controls the AI’s search and decides what information enters its context.
This approach could be useful in many settings:
- Schools, for finding reliable information in textbooks and school records
- Businesses, for searching policies, contracts, and support documents
- Law, where every statement needs a traceable source
- Medicine, where evidence and dates must be checked carefully
- Customer service, where the system needs to remember previous conversations
- Research, where information from many documents must be connected
However, the paper does not claim that every type of compilation always improves accuracy. Its strongest evidence supports claim–evidence pairs for reducing token use. Other tools, such as graphs, timelines, and wikis, may be valuable in real organizations, but they need separate testing.
The main message is simple:
A good AI system should not just search for more information. It should prepare trustworthy information, choose only what is needed, and show where each important fact came from.
Practical Applications
Immediate Applications
The paper’s strongest near-term applications are engineering and operational uses that can be implemented with existing BM25/grep search, LLM extraction, validation, and agent harnesses. The reported quantitative results apply primarily to English question answering with the tested models and benchmarks; deployment benefits for other artifacts remain proposed rather than experimentally demonstrated.
- Token-efficient enterprise question answering (software, knowledge management)
- Potential product/workflow: an enterprise assistant that returns answers with source-linked citations while reducing context consumption.
- Evidence from the paper: claim–evidence substitution reduced average query tokens by approximately 38%, with a 91% reduction when the projected evidence was sufficient and a 1.9% increase when it was insufficient.
- Dependencies: reliable span validation, accurate sufficiency gating, source-version tracking, and a fallback to raw text. The reported results should not be assumed to transfer directly to other languages, corpora, or models.
- Latency reduction through decision-gated reading (software infrastructure, customer support, internal search)
- Potential product/workflow: an adaptive support or research assistant that uses cheap evidence checks before invoking expensive model calls.
- Evidence from the paper: measured latency decreased from approximately 140 seconds to 30 seconds with a decision gate.
- Dependencies: the gate must avoid rejecting necessary evidence; latency gains depend on model-hosting overhead, tool-call parallelism, and the proportion of queries that can be answered from compiled evidence.
- Citation, provenance, and audit-ready answer generation (legal, healthcare, finance, government)
- Potential product/workflow: citation binders, compliance review dashboards, source-span highlighting, and automatic audit trails for AI-generated reports.
- Dependencies: exact-span validation is necessary but does not by itself guarantee that the claim is logically entailed by the span. Human review may still be required for high-risk decisions.
- Controlled deployment of agentic retrieval harnesses (software, research tooling)
- Potential product/workflow: a reusable orchestration layer for retrieval agents with token budgets, retrieval-round limits, citation assignment, zero-hit diagnostics, and tool disabling.
- Dependencies: the framework must clearly separate engine-enforced invariants from model judgments. The model can judge relevance and missing information, but the framework should enforce budgets, provenance, and citation formatting.
- Low-cost lexical RAG modernization (software, small and medium-sized organizations)
- Potential product/workflow: a lightweight private-document assistant that operates over file systems, document stores, PDFs, logs, and Markdown without a vector database.
- Dependencies: this is most plausible when documents contain searchable terminology and the agent is competent at query reformulation. Dense retrieval may still be needed for semantic mismatch, multilingual data, noisy OCR, or poorly indexed content. The paper’s claim that dense retrieval can reduce accuracy is empirical and system-specific, not universal.
- Incremental document ingestion and maintenance (enterprise content management, software operations)
- Potential product/workflow: continuous indexing pipelines for policies, manuals, tickets, contracts, and release notes that avoid rebuilding an entire knowledge base after every update.
- Dependencies: stable document identifiers, change detection, artifact versioning, invalidation of stale claims, and tests for cluster or graph consistency.
- Human-friendly corpus navigation (education, research, technical documentation)
- Potential product/workflow: an interactive documentation portal showing topic hierarchies, source-linked claims, related entities, and chronological views.
- Dependencies: structural artifacts alone do not add evidence. The paper found structural artifacts to be accuracy-neutral or, in the case of a PageIndex-style outline at scale, potentially harmful. They should therefore be evaluated for navigation time, maintenance, and user comprehension.
- Session memory for support and productivity assistants (customer support, personal productivity)
- Potential product/workflow: support agents that remember prior troubleshooting steps, or personal assistants that recover earlier decisions without rereading complete conversations.
- Dependencies: explicit user consent, deletion and correction controls, privacy protection, conflict resolution, and safeguards against treating model-generated memories as authoritative facts.
- Policy and workflow prototyping for organizations (policy, education, academia)
- Potential product/workflow: a university policy assistant, a laboratory documentation system, or a public-sector information portal with citations and “as-of” dates.
- Dependencies: institutional review, access-control enforcement, current-source validation, and clear disclaimers that the system supports—not replaces—official interpretation.
Long-Term Applications
These applications require domain-specific evaluation, larger-scale deployment, better ontology and graph maintenance, or evidence that the proposed organizational benefits materialize in production. The paper explicitly reports no completed deployment ledger in which these benefits have met pre-registered targets.
- Governed agent-native databases (enterprise software, regulated industries)
- Potential product/workflow: a database layer combining raw records, claim–evidence units, entity graphs, ontologies, timelines, and access-control labels.
- Dependencies: interoperable artifact schemas, authorization-aware retrieval, lineage preservation, update consistency, and production measurements showing that the richer interface improves outcomes without increasing operational complexity.
- Ontology-mediated integration across enterprise systems (healthcare, finance, manufacturing, government)
- Potential product/workflow: typed retrieval, cross-system question answering, schema mapping, invalid-relation detection, and policy-aware access control.
- Dependencies: domain experts must define classes, properties, constraints, and mappings. Ontologies require governance, versioning, conflict resolution, and adaptation to local terminology. The paper identifies this as commercially promising but provides no controlled deployment result.
- Cross-source compliance and investigation systems (legal, finance, cybersecurity, public administration)
- Potential product/workflow: investigation workbenches that traverse entities, retrieve supporting claims, display joined sources, and preserve an auditable reasoning trail.
- Dependencies: high-quality entity resolution, relation extraction, temporal validity, permissions across sources, and evaluation sets containing genuine multi-source questions. The paper notes that FRAMES did not reveal this benefit because its questions often did not require such joins.
- Temporal intelligence and version-aware decision support (policy, finance, healthcare, operations)
- Potential product/workflow: regulatory-change monitoring, patient or equipment histories, incident timelines, contract-effective-date analysis, and historical policy briefing tools.
- Dependencies: date normalization, event extraction accuracy, explicit “as-of” semantics, stale-version detection, and conflict handling when sources report different dates or revisions.
- Domain-specific LLM wikis with traceable synthesis (education, academia, technical support)
- Potential product/workflow: onboarding portals, research overviews, laboratory knowledge bases, and technical manuals that update when source documents change.
- Dependencies: prevention of summary drift, citation completeness, periodic recompilation, editorial review, and mechanisms ensuring that generated prose never becomes an unverified source for later generations.
- Personalized and persistent AI assistants (daily life, education, workplace productivity)
- Potential product/workflow: assistants that remember commitments, preferred workflows, learning goals, or prior explanations while allowing users to inspect and correct stored memories.
- Dependencies: privacy-preserving storage, user control, memory expiration, protection against sensitive-data leakage, and robust distinction between user facts, model inferences, and temporary context.
- Evidence-aware autonomous systems and robotics (robotics, industrial automation, healthcare operations)
- Potential product/workflow: maintenance robots, warehouse agents, clinical workflow assistants, and industrial control copilots with procedure citations and safety constraints.
- Dependencies: real-time updates, sensor grounding, formal safety validation, deterministic fallback behavior, low-latency retrieval, and strict separation between informational recommendations and executable actions. The paper does not evaluate physical agents, so this application remains speculative.
- Curriculum and research knowledge infrastructures (education, academia)
- Potential product/workflow: literature-review assistants, citation-supported tutoring systems, course knowledge maps, and research dashboards that expose both synthesized explanations and primary evidence.
- Dependencies: scholarly citation accuracy, discipline-specific ontologies, copyright and licensing compliance, assessment of pedagogical effectiveness, and safeguards against presenting contested claims as settled facts.
- Adaptive compilation policies based on workload economics (cloud infrastructure, finance, enterprise IT)
- Potential product/workflow: an ingestion planner that compiles high-volume collections first and leaves low-traffic or low-sufficiency collections uncompiled.
- Dependencies: reliable estimates of the gate acceptance rate and miss penalty. The reported approximately 2% asymptotic break-even sufficiency rate is not sufficient for small pilots; finite deployments must account for compilation cost and expected query volume.
- Standardized evaluation protocols for context infrastructure (academia, policy, industry)
- Potential product/workflow: shadow deployments and A/B test frameworks with collection-level comparisons, pre-registered targets, citation audits, and token/latency ledgers.
- Dependencies: sufficiently representative query sets, non-inferior accuracy requirements, collection-level rather than answer-level analysis, and transparent reporting of null results. The paper’s central methodological implication is that an artifact should not be promoted solely because it improves navigation or appears sophisticated.
Glossary
- Agent-native database: A database designed to provide an agent with structured, governed context rather than merely ranked documents. “the two together form what we call an agent-native database”
- Agentic retrieval: Retrieval performed by an autonomous or semi-autonomous agent that iteratively searches, reads, reformulates queries, and decides when to stop. “In a modern agentic system, retrieval is no longer a single query-to-embedding-to-similarity call.”
- Amortization: The process of recovering a one-time cost through repeated subsequent use. “The cost structure is what keeps the penalty small”
- Anchored deep read: A detailed reading operation tied to a previously identified source location. “Anchored deep read”
- Atomic claim: A single, indivisible proposition that can be independently supported by evidence. “atomic claims with verbatim evidence”
- BM25: A probabilistic lexical information-retrieval ranking algorithm based primarily on term frequency and document frequency. “BM25 and grep are what a harness needs”
- Claim–evidence pair: A normalized claim stored together with the exact source text and location that supports it. “every claim is stored with the verbatim evidence that supports it.”
- Claim-level evidence search: Retrieval that searches compiled claims rather than only raw document passages. “claim-level evidence search”
- Citation binding: The process of associating generated statements with identifiers that point to supporting source evidence. “Citation binding + cost attribution”
- Compilation artifact: A structured, derived representation generated from source documents during knowledge compilation. “produces typed artifacts rather than a single index”
- Context engineering: The deliberate construction, selection, and management of information supplied to a LLM. “Context as infrastructure”
- Context window: The bounded amount of text or tokens that a LLM can process as input at one time. “fills the window with passages that are never used”
- Dense retrieval: Information retrieval using learned vector representations and similarity calculations. “This paper contains no vector index and no dense-retrieval leg”
- Decision gate: A model or rule that decides whether additional reading or processing is necessary. “A decision gate cuts latency from 140\,s to 30\,s”
- Embeddings: Numerical vector representations of text or other objects used to measure semantic similarity. “claims are embedded and clustered hierarchically.”
- Entity–relation graph: A graph representing entities as nodes and their relationships as edges. “Entity--relation graph”
- Evidence projection: The replacement of a retrieved source chunk with a smaller set of compiled evidence units before model processing. “The compiled artifact reduces what is read”
- Fallback composition: The generation of an answer from available information when the normal retrieval or reasoning process terminates abnormally. “composing a fallback answer on abnormal termination”
- FRAMES: A multi-hop question-answering benchmark used in the paper to evaluate retrieval accuracy and token cost. “reaches 91\% on the multi-hop FRAMES benchmark”
- GraphRAG: A retrieval-augmented-generation approach that uses knowledge graphs, often including graph-derived summaries or communities. “It is deliberately not a GraphRAG-style community index”
- Harness: A control framework that manages an agent’s search tools, retrieval loop, evidence handling, budget, and stopping behavior. “We call the component that owns this loop the search harness”
- Knowledge compilation: A query-independent ingestion process that transforms a corpus into typed, versioned, provenance-linked artifacts. “We define knowledge compilation as a query-independent transformation”
- Knowledge graph: A structured representation of entities and their relationships, usually encoded as nodes and edges. “Knowledge graphs extract entities and relations”
- Lexical retrieval: Retrieval based on exact or approximate word and phrase overlap rather than learned semantic vectors. “the retrieval is lexical throughout”
- Lineage: A record of the source documents and locations from which a derived artifact was produced. “preserves a lineage link to the exact spans from which it was derived”
- LLM wiki: A maintained collection of linked articles synthesized from a corpus by a LLM. “an LLM compiling a corpus into a maintained, linked artifact”
- Lost-in-the-middle: A context-processing effect in which LLMs underuse information located in the middle of long inputs. “lost-in-the-middle studies show that models underuse material in long contexts”
- Mind map: A graph-like organization of concepts or entities intended to support navigation and conceptual orientation. “A Mind-map template lays out a document's entities as a navigation graph”
- Multi-hop question answering: Question answering that requires combining evidence from multiple passages, documents, or reasoning steps. “multi-hop QA”
- Ontology: A formal schema defining domain classes, properties, constraints, and mappings between vocabularies. “An ontology is a schema: classes, properties, constraints, and mappings to source vocabularies”
- PageIndex: A document-navigation method that constructs a heading-based outline or table of contents for retrieval and browsing. “PageIndex-style table-of-contents index”
- PageRank: A graph-based ranking algorithm that estimates the importance of nodes from their connections. “At query time a PageRank over the graph ranks chunks”
- Provenance: Information documenting the origin and supporting source of a derived statement or artifact. “the representation is lossy in prose and lossless in provenance”
- RAGFlow: The open-source system described in the paper for knowledge compilation and retrieval-harness operation. “It is the default in RAGFlow.”
- RAPTOR: A hierarchical retrieval method that recursively clusters and summarizes document chunks into a tree. “summary trees that recursively cluster and summarize chunks, as in RAPTOR”
- Recall@: The proportion of relevant items retrieved within the top ranked results. “higher Recall@”
- Retrieval-augmented generation (RAG): A method that supplies retrieved external information to a LLM when generating an answer. “Retrieval-augmented generation is becoming agentic.”
- Schema validation: Checking whether extracted data conforms to the required structure and field constraints. “Check evidence spans against the source, entity types against the ontology, dates against the document, and schema against the template.”
- Session memory: Persistent information extracted from prior interactions for use in later sessions. “Session memory extracts durable facts from session logs”
- Sparse retrieval: Retrieval using sparse representations, typically based on lexical term matching and inverted indexes. “Classical RAG conditioned generation on passages from a sparse or dense retriever”
- Structural compilation: Knowledge compilation that primarily adds organization or navigation structure rather than new evidence. “structural compilation does not improve accuracy under a competent harness”
- Substitution: Replacing a retrieved raw passage with a compiled representation before it is presented to the model. “Evidence substitution (default).”
- Sufficiency rate: The proportion of retrieval cases in which compiled evidence is judged adequate to answer without reading the original chunk. “the gate's acceptance rate---the operational proxy for sufficiency”
- Temporal orientation: The ability to understand the ordering and timing of events in a body of information. “Timeline & Temporal orientation”
- Typed artifact: A derived information object with an explicit semantic type, version, and associated validation or access metadata. “produces typed artifacts rather than a single index”
- Vector index: An index that stores vector representations to support similarity-based retrieval. “without any vector index”
- Zero-hit diagnostics: Tools or procedures for analyzing searches that return no results. “Zero-hit diagnostics”