Context Engineering & Prompt Design

What goes into each model call: system prompt structure, few-shot selection, JSON schemas, position effects, retrieval versus stuffing, history compaction, tool result trimming and tested prompt versions.

Overview

Why this topic

The model only knows what is in its context window on this call. Context engineering is deciding, for every call, what goes in, in what order, in what form and what stays out. Prompt wording matters, but most production failures come from context: the right fact was not retrieved, a 40,000-token tool result buried the instruction, or yesterday's conversation pushed out today's constraint.

Treat the context as a budget you assemble per call from typed parts, not as a string that grows.

> [!IMPORTANT] More context is not better context. Every irrelevant token costs money and latency, and long, noisy prompts measurably lower answer quality on facts placed in the middle.

Interview questions

  • Walk through how you would structure the system prompt for a customer-support agent with tools.
  • How do you pick and order few-shot examples, and how do you know they help?
  • An answer is wrong even though the right document was in the context. How do you debug it?
  • A long-running agent keeps forgetting constraints the user gave early on. Design the compaction.
  • A tool returns 30,000 tokens of JSON. How do you handle tool results in the context?
  • How do you version and test prompts so a change cannot silently break production?

Sign up free to read the full topic

More Agentic AI topics

Start free on Cariara · Coding problems · System design studio