Context and prompts: get the answer in one round
A language model knows nothing about your customer, your shop or your policy. It only sees what is in the prompt, and that text is called the context. If the context is thin, the answer is generic or wrong, and in a chat you ask again, and again. In a workflow that does not work: a question answering node runs on its own, nobody is there to say "no, I meant...". An answer that needs a second round is a failed run.
So the aim is a prompt that is complete enough for one pass. This page shows what belongs into it, and how to find out whether it does. For what the model itself can and cannot do, read Local models: what they can and cannot do.
Why rounds pile up​
| What you see | Usual cause | What helps |
|---|---|---|
| The answer is generic or vague | The model was not given the facts | Put the facts into the prompt (see below) |
| It contradicts your documents | It answers from what it learned in training | Say "use only the text below" and give the text |
| It invents details that are nowhere stated | The model fills gaps with plausible text, see hallucination | Tell it what to say when the answer is not in the text |
| The format changes: too long, chatty, a list instead of a word | You did not say how the answer must look | Name the format, length and the exact words |
| It asks a question back | The task was ambiguous or information is missing | State the assumptions; collect missing data before the model step |
| The same input gives different answers | Temperature is high | Use 0 to 0.3 for facts, classification and extraction |
| Part of a long prompt is ignored | Too long, or the important rule is buried in the middle | Shorten it, put the task and the rules at the end, see limits |
| It answers in the wrong language | Nothing says which language | Name the language of the answer |
The parts of a prompt that answers in one round​
Write the prompt in this order. Not every part is needed every time, but if an answer goes wrong, one of them is usually missing.
- Purpose, in one sentence. Who the model is and for whom it works: "You help the support team of an outdoor shop."
- The task, one task only. "Write a reply to the customer e-mail below." Two tasks in one prompt (classify and reply) are better two nodes in a row: each can be tested alone.
- The facts. Everything the answer depends on: the customer's mail with its subject, the return policy, the price
list, the product data. Label them, so the model can tell them apart:
CUSTOMER E-MAIL,POLICY. - The rules. What it must not do and what to do when it does not know: "Use only the policy below. If the policy does not cover the question, answer exactly: NOT COVERED. Do not promise refunds."
- The format. Length, structure, language, tone. For a machine-read answer the exact words: "Answer with one word: invoice, customer or newsletter."
- One or two examples of an input with the answer you want. This is called few-shot prompting: models copy the pattern, which fixes most format problems.
- The input to process, last. Put the changing text at the end, behind a label.
In a node the split looks like this: the system prompt carries purpose, rules and format (they stay the same for every
run), the user prompt carries the task, the facts and the input, with ${variable} placeholders.
You help the support team of an outdoor shop. Use only the POLICY in the message.
If the POLICY does not cover the question, answer exactly: NOT COVERED.
Otherwise write at most four sentences in the language of the e-mail, polite, without promises
beyond the POLICY, and name the passage of the POLICY you used.
POLICY
------
${variable.policy}
------
CUSTOMER E-MAIL
Subject: ${email.subject}
${email.text}
What to put into the context, and what to leave out​
Give the model:
- the facts the answer depends on: policy text, product data, the order, the mail it replies to (with the subject: it often carries the point);
- definitions of your words: what exactly counts as an "invoice", a "complaint", an "urgent" mail;
- the audience and tone: "customers, formal, no emojis";
- the limits: what it must not promise, which topics go to a human;
- the format and, for a machine-read answer, the exact words the next node looks for;
- the language of the answer, and the date if it matters ("today is ...");
- examples of good answers, if the style matters.
Leave out:
- secrets and personal data the answer does not need. What is in the prompt leaves your server when the model is in the cloud, see Generative AI privacy. Use secrets for credentials, never a prompt;
- whole databases or long documents when two paragraphs are the facts. More text costs time, may exceed the context window, and models use information in the middle of a very long prompt less reliably than at its start and end (the paper Lost in the Middle);
- contradicting instructions. If one sentence says "short" and another "explain in detail", the model picks one.
Where the context comes from in a diagram​
| Source | Example |
|---|---|
| Variables of earlier steps | ${email.text}, ${email.subject}, the row of a CSV file |
| An input page | The user types the question or the missing detail before the model is called |
| A fixed text in a variable node | The policy or handbook, see the example Answer from a Document |
| Company data and templates | Name, address, return conditions that every mail shares |
| The answer of an earlier AI step | A summary that the next step uses as its facts |
| The conversation so far | Only for chats (option conversation rounds); switch it off for batch processing |
Large facts do not have to go in whole. A diagram can select first and put only the relevant part into the prompt: a decision on a keyword, a regular expression, a filter on a table, a short summary of a long text made by a first node. This idea is known as retrieval-augmented generation; Cocosplate AI has no search index of its own, but the building blocks for a simple version are there.
Make the answer machine-readable​
When the next node is a decision, ask for one word from a fixed list, use a low temperature and match tolerantly:
Classify the following e-mail as exactly one word: invoice, customer or newsletter.
Answer with that word only.
The decision then tests '${ai.prompt.result}' matches '(?is).*invoice.*' (see
Regular expression): a model that answers "Invoice." or "This is an invoice" still
matches. Add an edge next as the default branch for answers that match nothing. The example
Support Inbox Triage is built like this.
A prompt before and after​
Before, the usual first attempt:
Answer this customer e-mail: ${email.text}
The model does not know the shop. It answers politely and generically, invents a return period, writes in English to a German customer and adds "Let me know if you have questions". Three rounds of correction follow.
After, in one round: the facts (the policy with the real period), the rule for the unknown, the language, the length, and the label that separates policy from mail, as in the system and user prompt above.
Test before you run​
- Develop the prompt in the AI workbench: fill in real values for the variables and look at the processed prompt, the text that is actually sent.
- Test with the worst inputs you have: the angry customer, the empty mail, the mail in another language, the one that is not covered by the policy. A prompt that only works for friendly examples is not finished.
- Run the diagram as a dry run and read the log.
- Change one thing at a time and compare the answers; keep the inputs that failed as a small test set.
- Let a person look at the answers where a mistake costs something, see Approvals by e-mail.
When a second round is right​
A second round is not always a failure. Plan it on purpose when information can only come from a person: collect it first with an input page and call the model afterwards, or build a real chat with the option conversation rounds, as in the example Conversation.
Size: tokens and the context window​
A model reads and writes tokens, pieces of words (roughly three quarters of a word in English; German and other languages usually need more tokens per word). Prompt, facts and answer must fit together into the model's context window. A local model has a smaller window than a large cloud model, and the settings decide how much of it you really get, see Which model for the agent? and local models.
Further reading​
- Prompt engineering (Wikipedia) and the free Prompt Engineering Guide with techniques such as few-shot prompting
- Context engineering by Simon Willison: why the whole context, not only the instruction, decides the answer, and the Context Engineering Guide
- Effective context engineering for AI agents (Anthropic)
- Prompt engineering overview (Claude) and the prompt engineering guide (OpenAI): written for their models, the advice carries over
- Retrieval-augmented generation when the facts are too large for the prompt
- More topics in Further reading