Step 13 / 20 · Reason · tokens · memory

Context engineering

Instructions, sources and memory, within budget.

For business

What it is

Assembling exactly what the model sees: instructions, the retrieved sources, client facts and relevant history, in the right order and size.

Why it matters

Answer quality depends more on what goes into the prompt than on which model you pay for. Done well, it is also the biggest cost lever.

Risk without it

Overstuffed prompts are slower, pricier and less accurate; missing context produces generic answers.

For engineers

How it works

A template puts stable parts first (role, rules, output format) so they can be prompt-cached, then the variable parts: sources with ids, CRM facts and short memory. A token budget per section decides what is trimmed or summarised.

Typical stack

  • prompt templates in code
  • tokenisers
  • provider prompt caching
  • memory stores

Pitfalls & trade-offs

  • Keep cacheable content first and byte-identical.
  • Label sources with ids so the model can cite them.
  • Version prompts like code and test changes against evals.

In this example

In
rules + 5 chunks
+ CRM + memory
Out
one prompt
within token budget
prefix: cached

Fictional sample · not a client system

Contact

Questions about this?

Book a call Write to hello@paxcode.it