Skip to content

Chapter 2.3 — Prompt engineering and context engineering

🎯 Objective

Distinguish prompt engineering (formulating instructions) from context engineering (assembling the correct set of information the model will see).

🧠 Mindset shift

Prompt engineering: how to ask better?
Context engineering: what deserves to enter the context, in what order,
                     in what format, with what confidence and with what budget?

🏗️ Context layers

  1. Normative: system instructions, policies, scope.
  2. Identity and tenant: user, organization, roles, permissions.
  3. Situational: task, parameters, recent history.
  4. Operational: available tools, tool results, checkpoints.
  5. Cognitive: plan, working memory, transient hypotheses.
  6. Grounding: documents, citations, retrieved facts.
  7. Output contract: schema, format, success criteria.

🚨 Context anti-patterns

  • Dumping whole documents into the prompt.
  • Mixing instructions with user data.
  • Huge tool descriptions.
  • Infinite history.
  • Memory without consent.
  • Context without source IDs.
  • Structured output only in the prompt (without a native schema).

🛡️ Prompt caching

  • Reduces cost and latency when there are stable prefixes.
  • Works best with instructions, policies and tool schemas at the start.
  • Caution: poorly designed caching can mask a policy or version change. Include the version in the execution metadata.

📚 References