Context Engineering is deciding
what actually goes in the box.
A model only sees what is inside its context window. Not what's true, not what's on your hard drive — only what you put in the box before it answers. Everything else might as well not exist.
From String Formatting to Runtime Payload Assembly
"How do I word this cleverly?"
Treats the prompt as a static text string. Relies on persona hacks ("Act as a senior dev"), magic tail-instructions ("Think step-by-step"), and phrasing tweaks. Assumes the model's parametric memory already contains the solution.
- ✕ Parametric Hallucination: Invents non-existent functions because no actual source files were injected into context.
- ✕ Attention Dilution: Stuffing raw 50,000-line chat histories dilutes the model's focus on key constraints.
"What evidence does it need to see?"
Orchestrates exact payload streams: system rule schemas, targeted AST file extractions, active linter output, and pruned conversation state. Treats context space as high-value, expensive RAM.
- ✓ Ground Truth Evidence: Supplies exact, non-hallucinated source code slices right before inference.
- ✓ Pruned Payload Efficiency: 85% lower context overhead with high execution precision on multi-file edits.
Five streams compete for the same context window
System Rules
Persona, output schema, tool policies, and safety constraints. Compact but mandatory.
Retrieved Knowledge
The precise source file or code snippet needed right now — not the entire repository.
CONTEXT
Tool Execution Output
Observation results from recent actions: terminal stdout, API responses, or linter results.
Conversation State
Key user preferences and recent turns, pruned to avoid bloat.
The User Task
Stated clearly at the center. When buried under irrelevant context, attention splits and reasoning degrades.
Adding context is easy. Pruning is the core engineering task.
Every extra log line, every unpruned chat turn, and every "just in case" documentation block pushes relevant information to the edges where attention mechanisms perform worst (Needle in a Haystack degradation). A full context window isn't thorough — it is diluted.
"A model with the right three facts outperforms one with three hundred."
Relevance Beats Recency
The newest message isn't automatically the most valuable. Pin core specifications and prune stale tool output.
Targeted Retrieval
Retrieve specific lines and declarations rather than dumping whole documentation suites into the context window.
Prune First
Treat context window space as expensive memory. Every inclusion must justify its seat in the prompt payload.