Implementation:24kchengYe MemoMind Directive Model
| Knowledge Sources | |
|---|---|
| Domains | Prompt_Engineering, LLM_Engineering |
| Last Updated | 2026-10-28 00:00 GMT |
Overview
Pydantic model for user-defined hard rules injected into LLM system prompts, serving as the data structure for the directive injection pattern.
Description
The Directive Pydantic model represents a user-defined rule that constrains agent behavior. Unlike mental models (auto-consolidated from memories), directives are manually created and always active. They are injected into the reflect agent's system prompt at two positions (top and end) with priority ordering.
A directive carries:
- content: the rule text ("Always respond in formal English")
- priority: higher priority directives are injected first
- is_active: allows disabling without deletion
- tags: for filtering which directives apply to which contexts
Usage
Import this model when you need to create, store, or inject user-defined behavioral rules into LLM prompts. It is used by the reflect agent pipeline for directive loading and injection.
Code Reference
Source Location
- Repository: MemoMind
- File: engine/hindsight_api/engine/directives/models.py
- Lines: L9-37
Signature
class Directive(BaseModel):
id: UUID = Field(description="Unique identifier")
bank_id: str = Field(description="Bank this directive belongs to")
name: str = Field(description="Human-readable name")
content: str = Field(description="The directive text to inject into prompts")
priority: int = Field(default=0, description="Higher priority directives are injected first")
is_active: bool = Field(default=True, description="Whether this directive is currently active")
tags: list[str] = Field(default_factory=list, description="Tags for filtering")
created_at: datetime = Field(default_factory=lambda: datetime.now(timezone.utc))
updated_at: datetime = Field(default_factory=lambda: datetime.now(timezone.utc))
class Config:
from_attributes = True
Import
from hindsight_api.engine.directives.models import Directive
I/O Contract
Inputs
| Name | Type | Required | Description |
|---|---|---|---|
| id | UUID | Yes | Unique identifier |
| bank_id | str | Yes | Bank this directive belongs to |
| name | str | Yes | Human-readable name |
| content | str | Yes | Directive text to inject into prompts |
| priority | int | No | Higher priority injected first (default 0) |
| is_active | bool | No | Whether currently active (default True) |
| tags | list[str] | No | Tags for filtering (default empty) |
Outputs
| Name | Type | Description |
|---|---|---|
| directive | Directive | Pydantic model instance with all fields populated |
Usage Examples
Creating and Using Directives
from hindsight_api.engine.directives.models import Directive
from uuid import uuid4
directive = Directive(
id=uuid4(),
bank_id="default",
name="Formal Language",
content="Always respond in formal English. Never use contractions.",
priority=10, # High priority - injected first
tags=["language", "tone"],
)
# Used by build_system_prompt_for_tools to inject into the reflect agent prompt
directives_list = [directive.model_dump()]
system_prompt = build_system_prompt_for_tools(
bank_profile={"name": "Assistant", "mission": ""},
directives=directives_list,
)