Skip to main content
Lola Send uses Markdown-based retrieval-augmented generation (RAG) to ground agent responses in bank-approved knowledge bases. Before generating a response, agents retrieve relevant passages from the knowledge base, reducing hallucination and ensuring answers align with approved documentation.

How it works

Lola Send’s RAG implementation loads Markdown documents from a designated directory and splits them for granular retrieval. When an agent processes a message, it retrieves the most relevant passages from the knowledge base and includes them as context for the AI model — alongside the conversation history and system prompt. This dual approach — tool functions for real-time data (quotes, recipients, operations) and RAG for static knowledge (country lists, fee schedules, payer information) — ensures agents reference verified content for both dynamic and reference data.

Implementation

RAG is implemented as a singleton MarkdownRAG instance shared across all agents:
class MarkdownRAGSingleton:
    _instance = None

    def __new__(cls, *args, **kwargs):
        if cls._instance is None:
            cls._instance = super().__new__(cls)
            cls._instance._initialized = False
        return cls._instance

    def __init__(self, *args, **kwargs):
        if self._initialized:
            return
        self.mdm = MarkdownRAG(*args, **kwargs)
        self.mdm.load()
        self._initialized = True
The singleton loads once at application startup and is shared across all agents via ast.set_rag_retrieval(rag).

Document loading

Documents are loaded from docs/{PROJECT_NAME}.md, where PROJECT_NAME is set via environment variable. The split_table_rows=True option splits table-heavy documents by row, enabling precise retrieval of individual entries (e.g., a specific country’s fee schedule or a single payer’s details).
def get_rag():
    project_name = os.getenv("PROJECT_NAME")
    singleton = MarkdownRAGSingleton(
        "docs",
        file_path=f"{project_name}.md",
        split_table_rows=True
    )
    return singleton.mdm

Per-agent activation

Each agent opts into RAG retrieval explicitly:
ast.set_rag_retrieval(rag)
All five of Lola Send’s agents — onboarding, sender home, blocked, pending CIP, and service unavailable — use the same RAG instance and knowledge base.

Knowledge base configuration

SettingSourcePurpose
PROJECT_NAMEEnvironment variableDetermines which knowledge base file is loaded
Document pathdocs/{PROJECT_NAME}.mdMarkdown file containing the knowledge base
split_table_rowsTrueSplits tables by row for granular retrieval
Different deployments (brands, regions) can use different knowledge bases by changing the PROJECT_NAME environment variable. This enables white-label deployments where each bank has its own approved content.
RAG grounds agent responses in verified content. Combined with tool functions for real-time data, this dual approach minimizes hallucination risk — agents reference approved documentation for static knowledge and live backend services for transactional data.

Security considerations

  • Bank-maintained content: The bank provides and maintains the knowledge base documents. Lola Send retrieves from them but does not modify them.
  • Read-only access: The RAG system loads documents at startup and serves them as retrieval context. Agents cannot write to or alter the knowledge base at runtime.
  • Content isolation: Each deployment’s knowledge base is scoped by PROJECT_NAME. One deployment’s content is not accessible to another.
  • No external retrieval: RAG retrieves from local Markdown files only — it does not fetch content from the internet or external sources.

Configuration and control

ControlDescription
Knowledge base contentThe bank writes and maintains the Markdown documents
PROJECT_NAMESelects the knowledge base per deployment or brand
split_table_rowsControls retrieval granularity for table-heavy documents
Per-agent activationEach agent can be configured with or without RAG retrieval