Building with AILesson 11 of 80

Contents

Building with AI

Lesson 11 of 80. Sign in to keep your place.

Module 2 · Prompting as engineering

A prompt is an interface, not a paragraph

9 min read

The five parts, and where the cache boundary falls1. Role and scope: stableTwo sentences: who this assistant is and, moreimportantly, what it does not do2. The task, as a procedure: stableSteps you could hand to a new colleague, not a wish3. The material: variableThe retrieved passages, the ticket, the code: long,and the reason for the call4. Rules, format and the sentinel: stableIncluding what to output when the material does notcontain the answer5. The user’s question: variable, lastRecall is strongest at the beginning and the end ofa long contextParts one, two and four are byte-identical on every call; parts three and five change. Keeping thestable block above the variable one is what a provider’s prefix cache bills at, and putting thequestion last is what stops it being buried at position 4,000 of 12,000.
Parts one, two and four are byte-identical on every call; parts three and five change. Keeping the stable block above the variable one is what a provider's prefix cache bills at, and putting the question last is what stops it being buried at position 4,000 of 12,000.

Figure 2.1

The shape that survives

Almost every prompt that lasts in production has the same five parts, in roughly this order. The order is not aesthetic; each part is placed where it is for a mechanical reason.

  1. Role and scope. Two sentences. Who this assistant is and, more importantly, what it does not do.
  2. The task, stated as a procedure rather than a wish.
  3. The material: the retrieved documents, the ticket, the code. Long, variable, and the reason for the call.
  4. Rules and format, including what to do when the material does not contain the answer.
  5. The user’s actual question, last.

Parts 1, 2 and 4 are stable across calls. Parts 3 and 5 change. That split is not incidental: it is exactly the boundary that prompt caching bills at, and getting the order wrong can cost you a 90 per cent discount you did not know you were entitled to.

Putting the question last also matters for a second reason. Recall is measurably strongest at the beginning and the end of a long context. The instruction that governs the answer should not be buried at position 4,000 of 12,000.

Behaviour, not adjectives

The most common wasted line in a prompt is an adjective. Be helpful, accurate and concise changes nothing you can measure, because it does not describe an action.

Compare:

Be concise and professional. Do not make things up.

against:

Answer in at most four sentences. If the documents do not contain the answer, reply exactly: NOT_IN_DOCS, and nothing else. Never name a price that does not appear verbatim in the documents.

The second version can be tested. You can count sentences, you can grep for the sentinel, you can check every price in the output against the source. The first version can only be argued about. A rule you cannot write an assertion for is a rule the model will follow inconsistently and you will never notice.

Say what to do when it does not know

This is the single highest-value line in most prompts and the one most often missing. A model with no path to “I cannot answer this” will produce something, because producing text is what it does. The path has to be explicit, and it has to be cheap for the model to take.

Give it a token:

If the retrieved passages do not answer the question, output exactly INSUFFICIENT_CONTEXT. Do not apologise, do not speculate, do not offer a general answer.

A sentinel beats a sentence, because your code can branch on it. INSUFFICIENT_CONTEXT is a control-flow signal; “I’m sorry, I don’t have enough information to answer that” is prose you would have to pattern-match, and the pattern changes every time the model version does.

Then make the fallback good. When your code sees the sentinel it should show the user something useful: the closest documents, a search box, a route to a human. Handled well, an honest refusal raises trust more than a confident guess ever does.

Delimiters, and why they are not decoration

When your prompt contains user-supplied text, mark the boundary explicitly:

Text
<document>
{{ document_text }}
</document>

<question>
{{ user_question }}
</question>

XML-style tags work well because models have seen enormous quantities of tagged text and because they are visually unambiguous. Markdown headings are weaker: a document containing its own ## Instructions heading blends straight into your prompt.

This is partly a correctness measure and partly a security one. Text you did not write is data. Delimiters are the first, weakest layer of keeping it that way: necessary, and nowhere near sufficient, which is the subject of a later module.

Prefill the answer

A technique that is underused and costs nothing. Most APIs let you begin the assistant’s turn yourself, and the model continues from where you stopped.

Python
messages = [
  {"role": "user", "content": prompt},
  {"role": "assistant", "content": "{"},      # it must now continue JSON
]

That one character removes preambles, removes code fences, and forces the shape you want. Prefill with - for a list, with { for an object, with Analysis: to skip the pleasantries. It is more reliable than asking for the same thing in words, because you have removed the option rather than requested it.

Length is not quality

Prompts grow by accretion. Every bug gets a new line, nothing is ever deleted, and after four months the system prompt is 2,000 tokens of contradictory instructions written by six people. Two failures follow.

Instructions conflict (an early line says be thorough, a later one says be brief) and which wins is unpredictable per call. And the whole thing is paid for on every request: 2,000 tokens at $3 per million, a million calls a month, is $6,000 a year for a prompt nobody has read end to end.

So prune deliberately. Delete a rule, run your test cases, see whether anything broke. Most teams discover that a third of their prompt is doing nothing, and that removing it improves compliance with the rules that remain: the model has fewer instructions competing for attention. The best prompt is not the longest one. It is the shortest one that passes.

Every lesson here is open. Your progress is recorded once you pass the Python, from Zero, for AI exam.

Check your understanding

A retrieval assistant sometimes answers questions its documents do not cover, using general knowledge. The prompt already says “only use the provided documents”. What is the most effective addition?

Pick the one you would defend. Your answer stays private.

Next lesson · 9 minExamples that teach, and examples that mislead

Stuck on something?Ask Sayali, your AI tutor

How to cite: Addaly (2026) ‘A prompt is an interface, not a paragraph’, in Building with AI. Edited by M. Mun. Addaly. Available at: https://addaly.com/learn/building-with-ai/the-prompt-is-an-interface (Accessed: 13 October 2026).