Knowledge System

How UND auto-learns your project and injects relevant knowledge

The Knowledge System ensures that the AI agent knows how to use Unreal Engine APIs correctly for each specific task. Rather than relying solely on the model's training data (which may be outdated or incomplete for UE5 APIs), UND maintains curated knowledge modules and auto-generated project context that get injected into the system prompt when relevant.

This is the difference between an AI that hallucinates deprecated API calls and one that writes correct, production-quality UE5 code on the first attempt.

Two Knowledge Sources

UND maintains two separate knowledge sources, each serving a different purpose:

UE Engine Knowledge

31 built-in markdown modules shipped with the plugin, covering core Unreal Engine 5 APIs, patterns, and best practices. These live in Content/UND/Knowledge/ and are read-only.

Topics include:

  • Blueprint creation and graph construction
  • Blueprint variables, components, and actor lifecycles
  • Gameplay Ability System (GAS)
  • Enhanced Input configuration
  • Animation system and State Trees
  • Material and Niagara particle systems
  • CommonUI and UMG widget patterns
  • Level design and PCG (Procedural Content Generation)
  • Physics, collision, and replication
  • Audio system, landscape, and foliage
  • Data assets and Gameplay Tags
  • Python reflection and project inspection
  • AI behavior and save systems
  • Delegates, events, and the Universal Bridge

Each module has metadata: keywords for matching, tool triggers, profile triggers, a priority score, and a token estimate. This metadata drives the scoring algorithm that decides which modules to inject.

Project Knowledge

Auto-generated modules created by the Project Scanner at editor startup. These are stored in Saved/UND/ProjectKnowledge/ and are specific to your project.

The scanner runs four passes:

BuildProjectOverview -- Reads DefaultEngine.ini to extract GameDefaultMap, GameMode, DefaultPawn, and RHI settings. Scans project headers for UCLASS/USTRUCT declarations. Performs genre detection across 20 genres (RPG, shooter, platformer, racing, strategy, survival, puzzle, and more) using weighted keyword scoring. Detects perspective (VR, first-person, third-person, top-down, side-scroller). Identifies infrastructure features like GAS, Enhanced Input, CommonUI, and StateTree. Lists existing Blueprint assets from the Asset Registry. The result is a description like: "MyProject is a third-person RPG game. Built with GAS and Enhanced Input."

ScanPlugins -- Parses every .uplugin file in the project, extracting module names, dependencies, and C++ classes per plugin.

ScanSourceClasses -- Extracts all UCLASS and USTRUCT declarations from Source/ headers, grouped by module. This gives the AI a map of your project's class hierarchy.

ScanContentAssets -- Maps Content/ directories with asset counts and detects naming conventions (BP_, SM_, MI_, and others).

Scoring Algorithm

When a user sends a message, the Knowledge Manager scores every available module to determine which ones are relevant enough to inject.

Loading diagram...

The scoring works as follows:

SignalScore
Keyword match from user message+1.0 per match
Tool trigger match (e.g., the agent is using execute_python)+5.0
Profile trigger match (e.g., the active agent is "Coder")+3.0
Priority tiebreakerpriority / 100

The system extracts keywords from recent user messages using tokenization that supports camelCase, PascalCase, snake_case splitting, and multi-language terms (including non-Latin scripts). It also considers compound terms by splitting and matching against module keywords.

All modules — both UE Engine and Project — go through the same scoring pipeline. Project modules receive a small relevance bonus (+1.0) to prefer them when tied, but are not force-injected when irrelevant. This ensures the token budget is spent on whichever modules are most useful for the current request.

Modules are then selected using a knapsack-style algorithm that fits as many high-scoring modules as possible within the configured token budget (default: 2,000 tokens). Oversized modules that would exceed the remaining budget are skipped in favor of smaller, high-scoring alternatives.

Injected modules are deduplicated per task — once a module has been injected in a conversation, it will not be injected again in the same task, keeping the context window clean. The dedup set resets when a new user message starts a new topic or when you use /newtask.

Auto-RAG

Alongside knowledge modules, UND runs an Auto-RAG (Retrieval-Augmented Generation) system that injects relevant code snippets from your project on every turn.

The system uses a BM25 inverted index built from your project's source files. The index is constructed in the background at editor startup and supports incremental updates as files change.

How it works:

  1. On each turn, the system extracts a query from the conversation -- the user's message on the first turn, then the AI's latest response on subsequent turns (minimum 30 characters, with fallback to the original user message).
  2. The BM25 index returns the top matching code snippets ranked by term frequency and inverse document frequency.
  3. These snippets are injected into the system prompt as [Auto-Injected Code Context], giving the AI relevant examples from your actual codebase.

Configuration options in Settings:

SettingDefaultDescription
Enable Auto-RAGtrueToggle automatic code snippet injection
Max Results5Maximum code snippets per turn
Token Budget2,000Token budget for Auto-RAG snippets
Max Indexed Documents5,000Maximum chunks in the BM25 index

Custom Knowledge Modules

You can create your own knowledge modules using the save_project_knowledge tool. This is useful for documenting project-specific patterns, API conventions, or architectural decisions that the AI should follow.

The AI agent itself can also create knowledge modules during a conversation -- for example, after learning how a particular system in your project works, it can save that understanding for future sessions.

Custom modules support the same metadata as built-in modules:

  • Keywords -- Terms that trigger injection when they appear in user messages
  • Tool triggers -- Tool names that trigger injection when the agent uses them
  • Profile triggers -- Agent profile names that trigger injection
  • Priority -- Relative importance for tiebreaking (higher = more likely to be selected)
  • Token estimate -- Approximate size for budget calculations

You can also browse, edit, and manage knowledge modules through the Knowledge Panel in the UND editor UI.

Configuration

Knowledge injection settings are available in the UND Settings panel:

SettingDefaultDescription
Enable Knowledge InjectiontrueToggle the entire knowledge injection system
Knowledge Token Budget2,000Maximum tokens allocated for knowledge modules per turn

The knowledge system is designed to be invisible when it works correctly -- the AI simply knows the right APIs and patterns without being told. If you notice the AI using deprecated or incorrect UE5 APIs, check whether the relevant knowledge module exists and has appropriate keywords and triggers configured.