AIKernel.NET
version: 0.0.2 / status: Refactor / edition: Draft / published: 2026-05-16 / updated: 2026-05-16

Context Isolation Specification

AIKernel strictly isolates information by category before passing it to an LLM. This specification protects attention and maximizes inference capability.


1. Items to Isolate

Do not mix the following into the inference context:

  • examples / samples
  • RAG fragments
  • stylistic instructions
  • past history
  • noisy information

These are primary causes of attention pollution and destroy inference purity.


2. Theoretical Background (Attention Pollution)

From the uploaded documents:

"An LLM's inference capability depends on attention purity. When attention is drawn to surface structures, inference halts and the system falls into surface-mode." — Attention Pollution Theory

Attention is finite; focus it on abstract structure, purpose, and constraints.

Mixing examples, style, RAG fragments, history, or noise leads to:

  • inference halt
  • surface-mode
  • increased hallucination
  • loss of purpose

3. Failure Modes

If context isolation is not enforced, the following failures occur.

3.1 Surface-mode

From uploaded documents:

"LLMs fall into surface-mode when exposed to examples. This means loss of inference capability." — Risks of Surface-Mode Failure

Characteristics:

  • style-only mimicry
  • no inference
  • no structural understanding
  • loss of purpose

3.2 Inference halt

  • structure fails to get attention
  • reasoning depth collapses
  • chain-of-thought breaks

3.3 Increased hallucination

  • Mixing RAG and context breaks factuality

3.4 Broken deterministic replay

  • Mixing history and question destroys reproducibility

4. Isolation Method (3-Context Model)

AIKernel separates information into three contexts.


4.1 OrchestrationContext (for inference)

Contains only information necessary for inference:

  • purpose
  • constraints
  • abstract structure
  • reasoning patterns

Never include examples, style, or RAG.


4.2 ExpressionContext (for expression)

— Applied only after inference completes

ExpressionContext is applied only after inference has finished.

AIKernel treats inference (Orchestration) and expression (Expression) as a physically separated two-step process.

This prevents style, examples, or metaphors from contaminating inference and avoids surface-mode.

ExpressionContext contains:

  • style
  • examples
  • explanatory text
  • metaphors

4.3 MaterialContext (for material)

— Must be structured

RAG fragments and external information in MaterialContext must not be passed raw into OrchestrationContext.

Material processing steps:

  1. Retrieval (RAG / Provider)
  2. Normalization (remove irrelevant data)
  3. Structuring (decompose, abstract, unitize meaning)
  4. Transfer only necessary parts into OrchestrationContext

This differs fundamentally from approaches that pass raw RAG into LLMs. Structuring is central to hallucination suppression.


5. Handling History

— Boundary between Material and Orchestration

History is a major attention polluter and must be handled carefully.


5.1 When history is Material

  • When referencing past facts
  • When history should be treated as external data
  • When history requires abstraction or summarization

In this case, place history in MaterialContext and structure it before transferring to OrchestrationContext.


5.2 When history is Orchestration

  • When it directly affects current purpose or constraints
  • When minimal context is needed to maintain conversational continuity

Even then, do not pass raw history.


5.3 Prohibitions

  • Do not mix raw history into OrchestrationContext
  • Do not pass long unprocessed history to the LLM

AIKernel separates history into "material" and "minimal orchestration context" and avoids mixing them to preserve deterministic replay.


6. Implementation Guarantees in AIKernel

Kernel / Pipeline / Context Isolation are designed to structurally enforce this specification.

  • Kernel separates the three contexts
  • Pipeline marks contexts at each step
  • ProviderRouter does not pass MaterialContext directly
  • LlmController does not mix ExpressionContext into inference

This makes category mixing structurally impossible.


7. Purpose (Why)

Context isolation aims to:

  • maximize inference purity
  • prevent attention pollution
  • avoid surface-mode
  • maximize LLM abstract inference capability
  • guarantee deterministic replay
  • maintain OS-level consistency


Changelog

  • v0.0.0 / v0.0.0.0: Initial draft
  • v0.0.1 (2026-05-06): Version upgrade aligned with documentation guidelines
Source: architecture/2.CONTEXT_ISOLATION_SPEC.md