Context loading is its own component
Beyond a few turns, prompt building deserves to be its own module — a Context Engine. Its job: assemble the system prompt, decide what static text to cache, fetch relevant retrieval, fold history. cwkPippa's backend/context/engine.py is exactly this; the rest of the app does not assemble prompts ad-hoc.
The load order matters
cwkPippa's order: Pippa.md (identity) → instructions.md (operational rules) → core/* (deep self) → index/* (large reference, on-demand pointers). Order matters because identity and rules win over reference when they conflict. A different order would produce a different Pippa.
Pointers vs payloads
For files larger than 10KB, cwkPippa includes a pointer ('this exists at ~/Obsidian/pippa/index/X.md; read with the Read tool when needed'). The payload itself stays out of the system prompt unless required. Result: stable cacheable prefix, on-demand depth.