Skip to content

Vault · Construct

Context Engineering: MECW Protection

Added
2026-02-04
Category
Construct
  • AI
  • LLM
  • Architecture

Large context windows do not make every token equally useful. As prompts grow, instructions compete for attention and the current task gets buried. This pattern layers skill injection into three tiers so an agent only loads what it needs for the current task.

When to Use

  • Building AI agents that rely on tool or skill injection
  • Your prompts are getting bloated and model performance is degrading
  • You need a strategy for scaling agent capabilities without blowing through the context budget

The Code

// Progressive Skill Disclosure
// Keep the base prompt small by loading detailed instructions on demand.

type ContextLevel = 'L1_Metadata' | 'L2_Instructions' | 'L3_Technical';

interface SkillContext {
  level: ContextLevel;
  tokenCost: 'low' | 'medium' | 'high';
  loadStrategy: 'always' | 'on-trigger' | 'tool-call';
}

const CONTEXT_LAYERS: Record<ContextLevel, SkillContext> = {
  L1_Metadata: { 
    level: 'L1_Metadata', 
    tokenCost: 'low',        // ~100 tokens/skill
    loadStrategy: 'always'   // Global index in context
  },
  L2_Instructions: { 
    level: 'L2_Instructions', 
    tokenCost: 'medium',     // <5k tokens
    loadStrategy: 'on-trigger' // Lazy-load when task matches
  },
  L3_Technical: { 
    level: 'L3_Technical', 
    tokenCost: 'high',       // Unbounded
    loadStrategy: 'tool-call' // Never in prompt, access via tools
  }
};

Notes

L1 metadata is small enough to keep in the base prompt. Load L2 instructions when the user's intent matches a skill. L3 content can be large, so retrieve it on demand instead of loading it into every prompt.