Skip to main content
Mako includes a lightweight retrieval-augmented generation (RAG) system that gives the model curated knowledge about the Base ecosystem — without relying on the model’s training data alone.

How it works

RAG retrieval flow
Before every inference call, the gateway scans the user’s message for known project keywords. If a match is found, relevant context is injected as a system message — so the model has accurate, up-to-date information without needing a separate retrieval step.

Two retrieval modes

Auto-injection

Keywords in the user’s message trigger context injection automatically, before the model sees the message. Zero latency.

Explicit search

The model can call the knowledge_search tool directly to query the knowledge base on demand.

Auto-injection

The getContextForMessage() function runs on every request:
  1. Scans the user’s message against 85+ keyword triggers built from each project’s keywords array and name
  2. Scores matches by keyword hit count
  3. Injects the top 2 project summaries (~500 tokens) as a system message

Keyword matching rules

Injected format

The model can also call knowledge_search directly when it needs structured information. This uses a weighted scoring system: Returns up to 5 results, each with name, category, summary, details, token, and website. If called with an empty query, it returns all entries (name, category, and summary only) — useful for browsing.

Knowledge entries

Each entry is a JSON file in gateway/src/knowledge/. The gateway loads all entries at startup.

Entry schema

Current entries

The knowledge base ships with 15 curated entries:

Adding a new entry

Create a JSON file in gateway/src/knowledge/ following the schema above. The gateway loads all .json files from this directory at startup — no code changes required, just restart the server.
Choose keywords carefully. Each keyword becomes a trigger for auto-injection, so avoid overly generic terms that would match irrelevant queries.