Context engineering is the discipline of systematically managing the full information ecosystem available to an AI agent — selecting, compressing, ordering, and delivering the right content to the context window at the right time.

Andrej Karpathy (2025) coined the canonical definition: “the delicate art and science of filling the context window with just the right information for the next step.” Where prompt engineering focuses on crafting a single instruction or query, context engineering addresses the architecture of everything the model sees: task descriptions, retrieved documents, tool definitions, memory, execution history, few-shot examples, and compaction strategies.

Context Engineering vs. Prompt Engineering

  • Prompt engineering — one-off crafting of a single input message or instruction template
  • Context engineering — systematic design of the entire information payload across all context window slots

Karpathy frames this as a scope shift: if prompt engineering was about writing a magical sentence, context engineering is about writing the full screenplay. This distinction matters operationally: as agents become long-running and multi-step, prompt-level adjustments are insufficient — the information architecture must be actively managed across sessions.

Five Dimensions of Context Quality

Synthesizing across the HumanLayer and martinfowler framing (Horthy 2026; Boeckeler 2026):

  • Selection — what information to include and what to exclude; irrelevant content degrades performance
  • Compression — reducing token usage without losing signal; compaction prevents context saturation
  • Ordering — sequencing matters; attention degrades for information buried in the middle of long contexts
  • Isolation — partitioning context using sub-agents prevents contamination across independent tasks
  • Format — structured vs. prose presentation affects how reliably the model interprets the payload

Context Engineering in Harness Engineering

The two terms have an unresolved definitional boundary across sources:

  • Horthy (2026): harness engineering is a subset of context engineering — the part focused on configuring coding agent harnesses
  • Boeckeler (2026): context engineering is one of three components within harness engineering, alongside architectural constraints and entropy management

In practice, both framings agree on the core activity: continuously improving what the agent can see through codebase-embedded knowledge files, dynamic tool access, memory accumulation, and compaction strategies.

Academic Framing

Mei et al. (2025) provide a formal taxonomy decomposing context engineering into:

  • Context retrieval and generation — sourcing relevant content
  • Context processing — transforming and filtering for relevance
  • Context management — memory systems, compaction, state tracking

These combine into production system patterns: RAG pipelines, tool-integrated reasoning, and multi-agent coordination.

Zhang et al. (2025) extend this with Agentic Context Engineering — treating contexts as evolving playbooks that self-improve through generation, reflection, and curation cycles, preventing “context collapse” (iterative rewriting that erodes important details).

Sources

  • Karpathy, Andrej (2025). “Context Engineering.” X (Twitter). June 2025. Available: https://x.com/karpathy/status/1937902205765607626

    • Canonical definition: “the delicate art and science of filling the context window with just the right information for the next step”; coined/popularized the term as the successor discipline to prompt engineering
  • Mei, Lingrui, Jiayu Yao, Yuyao Ge, Yiwei Wang, Baolong Bi, et al. (2025). “A Survey of Context Engineering for Large Language Models.” arXiv:2507.13334. July 2025. Available: https://arxiv.org/abs/2507.13334

    • Comprehensive academic taxonomy of context engineering across 1,400+ papers; decomposition into retrieval, processing, and management components
  • Zhang, Qizheng, Changran Hu, Shubhangi Upasani, et al. (2025). “Agentic Context Engineering: Evolving Contexts for Self-Improving Language Models.” arXiv:2510.04618. October 2025. Available: https://arxiv.org/abs/2510.04618

    • Introduces ACE framework: contexts as evolving playbooks; addresses brevity bias and context collapse; +10.6% improvement on agent benchmarks
  • Horthy, Dex (2026). “Skill Issue: Harness Engineering for Coding Agents.” HumanLayer Blog. Available: https://www.humanlayer.dev/blog/skill-issue-harness-engineering-for-coding-agents

    • Positions harness engineering as a subset of context engineering; five dimensions for coding agents; AGENTS.md, MCP, skills, sub-agents, hooks as context engineering techniques
  • Boeckeler, Birgitta (2026). “Harness Engineering.” Exploring Generative AI, Martin Fowler’s Blog. Available: https://martinfowler.com/articles/exploring-gen-ai/harness-engineering.html

    • Context engineering as first of three harness components; continuously enhanced knowledge base; iterative improvement loop when agents encounter gaps

Note

This content was drafted with assistance from AI tools for research, organization, and initial content generation. All final content has been reviewed, fact-checked, and edited by the author to ensure accuracy and alignment with the author’s intentions and perspective.