Jump to content

Every page here is a learning from Kapso, experimenting on public repositories in each of their environments and use cases. Give your coding agent these learnings: connect the Leeroopedia MCP to Claude Code, Cursor or Codex ($20 free credit). Powered by Leeroo · founders@leeroo.com

Principle:24kchengYe MemoMind Directive Injection

From Leeroopedia
Knowledge Sources
Domains Prompt_Engineering, LLM_Engineering
Last Updated 2026-10-28 00:00 GMT

Overview

Technique that injects user-defined hard rules (directives) into LLM system prompts at fixed positions to constrain agent behavior with higher priority than default instructions.

Description

Directives are explicit, user-curated rules ("Always respond in formal English", "Never share personal data", "Prefer conservative recommendations") that override the agent's default behavior. Unlike mental models (which are auto-consolidated from memories), directives are manually created and always active.

The injection strategy places directives at two positions in the system prompt:

  1. At the top: immediately after the anti-hallucination rule, so the LLM sees them before any other instruction
  2. At the end: as a final reminder before the agent begins reasoning

Higher-priority directives are injected first, ensuring the most important rules are encountered earliest in the prompt.

Usage

Use this principle when an LLM agent must follow user-specific behavioral constraints that differ from its defaults. It is essential for multi-tenant systems where different users have different behavioral requirements.

Theoretical Basis

# Abstract directive injection (not real implementation)
prompt = [
    "CRITICAL: Only use retrieved information...",
    build_directives_section(directives),  # Injected at top
    "You are a reflection agent...",
    # ... retrieval strategy, reasoning rules ...
    build_directives_reminder(directives),  # Injected at end
]

The dual-position injection leverages the primacy and recency effects in LLM attention: rules at the beginning and end of a prompt receive more attention than those in the middle.

Related Pages

Implemented By

Page Connections

Double-click a node to navigate. Hold to expand connections.
Principle
Implementation
Heuristic
Environment