How it works
At startup, the gateway loads JSON files fromgateway/src/knowledge/ into an in-memory index. Each file describes a single project with structured metadata.
Entry format
Two retrieval modes
1. Automatic context injection
Before every inference call, the gateway scans the user’s message against 85+ keyword triggers built from each project’skeywords array and name.
If keywords match, the gateway injects up to 2 project summaries (~500 tokens) as a system message immediately after the main system prompt. This happens before the model sees the message, so the model has relevant context without needing to call any tool.
Matching rules:
- Keywords are matched as whole words (word-boundary regex) to avoid false positives
- Short keywords (≤3 chars) require extra context — either a
$prefix or strict word-boundary matching - Matches are scored by keyword hit count; the top 2 are injected
- Project details are truncated to 600 characters to save tokens
2. Explicit search via knowledge_search
The model can also call knowledge_search directly when it needs project information.
Parameters: query (required)
The search scores entries across multiple fields with weighted relevance:
| Field | Score weight |
|---|---|
| Project name | +10 per match |
| Keywords | +5 per match |
| Category | +3 per match |
| Summary | +2 per match |
| Details | +1 per match |
query is empty, the tool returns all entries (name, category, summary only).
Covered projects
The knowledge base currently includes 15+ entries spanning:- DeFi — Aerodrome, Moonwell, Morpho, Aave
- AI Agents — Virtuals, Venice, Clanker
- Social — Farcaster, Zora
- Infrastructure — Coinbase Wallet, Smart Wallets, Basescan
- Memecoins — Notable memecoins on Base
Adding entries
To add a new project, create a JSON file ingateway/src/knowledge/ following the entry format above. The gateway will load it automatically on the next restart — no code changes needed.