MoongraphMoongraph

RAG & Retrieval

How the Agent finds context and generates cited answers.

RAG & Retrieval

This page explains how the Agent answers questions using your documents—what happens behind the scenes when you ask a question.

What is RAG

RAG stands for Retrieval-Augmented Generation. Instead of relying only on what the AI model knows, RAG:

  1. Retrieves relevant information from your documents
  2. Provides that information as context to the AI
  3. Generates an answer grounded in your actual data

The result: answers based on your documents, with citations linking back to sources.

The retrieval pipeline

When you ask the Agent a question:

  1. Query analysis — Your question is analyzed to determine what information is needed
  2. Tool selection — The Agent decides which tools to use (chunk search, graph queries, etc.)
  3. Retrieval — Relevant chunks and/or graph data are fetched
  4. Context assembly — Retrieved information is formatted as context
  5. Generation — The AI generates an answer using that context
  6. Citation linking — Claims are connected back to source chunks

What gets retrieved

The Agent can pull from multiple sources:

Document chunks — Text segments from your uploaded documents, found via semantic or lexical search

Graph entities — People, organizations, and other entities extracted into your knowledge graphs

Graph relationships — Connections between entities that help answer relationship questions

Document metadata — Titles, dates, and other document-level information

Search modes

The Agent's primary retrieval tool (retrieve_chunks) supports three modes:

ModeBest forExample
SemanticConceptual queries"What are the key findings about oversight?"
LexicalExact names, quotes, identifiers"Project Blue Book", "Dr. Hynek"
HybridMixed queries (default)"What did John Smith say about the budget?"

The Agent chooses modes automatically but can be directed by your phrasing.

GraphRAG

When a knowledge graph is available, retrieval can also traverse the graph structure:

  • Find entities related to your query
  • Pull in connected entities and relationships
  • Use graph context alongside chunk context

This helps with questions about relationships and connections:

  • "How is Person A connected to Organization B?"
  • "What organizations is this person associated with?"
  • "What events happened at this location?"

Why citations matter

Every claim in an Agent response should link back to a source chunk. Citations let you:

  • Verify the AI's interpretation
  • Read the original context
  • Navigate to the source document
  • Cite sources in your own work

If the Agent can't find supporting evidence, it should say so rather than make unsupported claims.

What affects answer quality

Document quality — Clean text with good structure produces better chunks

Query specificity — More specific questions retrieve more relevant context

Corpus coverage — The Agent can only answer from what's in your documents

Chunk relevance — If the right chunks aren't retrieved, the answer may be incomplete

Limitations

  • No real-time data — The Agent knows what's in your documents at query time
  • Context limits — Very long documents or many results may be truncated
  • Extraction quality — Answers depend on document and chunk quality

On this page