โ† Back to ConceptsVerified: 2026-07-30
Context Engineering
ARCHITECTURE // BOUNDED CONTEXT

Context Engineering

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.

CONTEXT WINDOW โ€” FIXED CAPACITYTask + System RulesThe 3 Files That Actually MatterLast Relevant ExchangeRoom for GenerationEXCLUDED ON PURPOSEEntire codebase, unfilteredFull chat history, every turnEvery doc mentioning the keywordStale tool output from step 01
01The Paradigm Shift

From String Formatting to Runtime Payload Assembly

Legacy Paradigm // Prompt EngineeringFragile & Unbounded

"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.

// Static Prompt String
"You are an expert full-stack developer."
"Refactor the authentication handler cleanly."
// Missing real source code & type definitions!
"Think step-by-step and do not make mistakes."
  • โœ•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.
Primary Bottleneck: Phrasing tweaks cannot supply missing runtime evidence.
Modern Standard // Context EngineeringDeterministic & Bounded

"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.

// Assembled Payload Architecture
[SYSTEM] Rules & schema contracts (120 tokens)
[FILE: auth.ts#L40-85] Target interface (340 tokens)
[TOOL_OUTPUT] Linter error trace (95 tokens)
[TASK] Refactor auth.ts to match schema
  • โœ“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.
Core Advantage: Deterministic payload assembly turns agent loops from guesswork into precision engineering.
02Payload Anatomy

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.

BOUNDED
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.

03Capacity & Dilution

Adding context is easy. Pruning is the core engineering task.

CONTEXT CAPACITY GAUGE92% FULL โ€” ATTENTION DILUTION HIGH

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.

04Core Engineering Axioms

"A model with the right three facts outperforms one with three hundred."

01

Relevance Beats Recency

The newest message isn't automatically the most valuable. Pin core specifications and prune stale tool output.

02

Targeted Retrieval

Retrieve specific lines and declarations rather than dumping whole documentation suites into the context window.

03

Prune First

Treat context window space as expensive memory. Every inclusion must justify its seat in the prompt payload.