How to Plan the Context for an AI Assistant, Section by Section

How to Plan the Context for an AI Assistant, Section by Section

Published by: Digital Campaign

Why the context matters more than the prompt

When an AI assistant gives a vague or wrong answer, the cause is often in the context it was given. It may not know its role. A key rule may sit halfway down a long block of text. Reference facts may run straight into the instructions, so the model cannot tell them apart. Writing the context as one long prompt makes these problems hard to see and harder to fix.

A better habit is to plan the context in named sections: what the system is for, who the model is, the rules, the facts, some examples, and the format you want back. Each part can then be written, reviewed and changed on its own. Our guide to building a reliable AI prompt framework explains the thinking behind this approach.

This guide shows how to do it with Context Architect, a free tool in Digital Campaign Labs. It runs in your browser, never connects to an AI model and saves nothing, so you can work on internal instructions safely. You will build a customer assistant, catch two common mistakes, fit it to a smaller model and export the result.

A worked example: a customer assistant for an online shop

Open the tool in a second tab and follow along. Every number below is what the tool shows for its own example.

  1. Start from the template. At the top of the tool, choose Customer assistant from the Template list and press Use this template. It is selected when the page opens, so you may see it already. You get seven sections in this order: System instructions, Role and objectives, Policies and constraints, Knowledge and reference data, Examples, Conversation memory and Output contract. The memory section is empty and switched off.
  2. Check the settings. Under Settings, the name is Customer assistant, the Context window is 128000 tokens and the Response allowance is 20000 tokens. The window is the most the model can hold at once, prompt and answer together. The allowance is room kept free for the answer. Leave the Token counter on OpenAI o200k_base (GPT-4o family), which gives exact counts for that family of models.
  3. Read the budget. On the Checks step, the Budget section says: 228 of 128,000 tokens used (0%), with 20,000 kept for the response and 107,772 free. The table lists each section with its tokens:
    • System instructions: 41
    • Role and objectives: 29
    • Policies and constraints: 33
    • Knowledge and reference data: 52
    • Examples: 45
    • Conversation memory: Off
    • Output contract: 28
    Each one is under 0.1% of the window. The knowledge section is the largest, which is normal: facts tend to grow faster than rules. The Checks panel says No problems found.
  4. Try a different counter. If your assistant will run on Claude, Gemini or another model whose tokeniser is not public, choose Estimate for other models, including Claude. The estimate uses one token for every four characters. The total becomes about 263 tokens, and every figure now starts with About. The gap between 228 and 263 is a reminder that the same text costs a different amount on different models. Switch back to o200k_base for the next steps.
  5. Make a common mistake on purpose. In the Knowledge and reference data section, add a new line at the end and paste in the refund rule from the policies: Do not promise refunds or discounts: explain the policy and offer to pass the request on. Then tick Include in the prompt under Conversation memory. Two checks appear at once:
    • A note that Conversation memory is empty, with the advice to fill it in, switch it off or delete it.
    • A warning that Knowledge and reference data repeats text from Policies and constraints. Repeated text costs tokens and can give a rule more weight than you meant.
    The knowledge section grows from 52 to 70 tokens, so the repeat costs 18 tokens. Press Go to section beside the warning to jump to the text, delete the line, and untick memory again. The checks clear.
  6. Fit the context to a smaller model. Suppose the assistant will run on a small, cheap model with an 8,000-token window. Set the Context window to 8000 and the Response allowance to 1000. The budget now reads 228 of 8,000 tokens used (3%), with 1,000 kept for the response and 6,772 free. A warning appears: the response allowance is 13% of the window, and below 15% long answers may be cut short. Raise the allowance to 1200 and the warning clears, leaving 6,572 tokens free.
  7. Check the order. Models tend to pay most attention to the start and end of a long context. The template already puts the role near the top and the output contract last, close to where the model starts writing. If you add a section, it goes to the end, so use Move up to put it in the right place.
  8. Export the result. Under Export, choose Markdown (the prompt) or XML (the prompt). The preview shows exactly what the model will receive: only the sections that are switched on and have content, in order, each with its title as a heading or tag. Press Download to save customer-assistant.md, or Copy to paste it into your platform. Then choose JSON (to import again later) and download that too, because closing the page clears your work.

Using it on your own work

Start from the template closest to your task. As well as the customer assistant, there is a data extraction template, an agent with tools, and a blank set with one empty section of each kind. You do not need all eight kinds. A simple assistant may only need a role, some knowledge and an output contract.

Set the window and allowance to match the model you plan to use, and pick the counter that matches it. Then paste in your real material. The budget is where most surprises show up. A price list, a product catalogue or a long policy document can be thousands of tokens, and the table makes it plain which section is eating the space.

Use the switch on each section to test without it. If your assistant works as well with the examples switched off, you have saved their tokens on every request. If it gets worse, you know the examples earn their place.

If your output contract asks for JSON, the tool checks that the example is valid. In the data extraction template, adding a stray comma after the last field raises an error straight away, because a model may copy the mistake into every answer.

Keep the JSON export with the rest of your project files. Next time, choose it under Import a saved context (JSON) and carry on where you left off.

What you gain from planning context this way

The benefits show up in the decisions people can make with a planned context, and in who can make them.

  • Product owners can sign off an assistant's behaviour by reading the role, policies and output contract, without wading through examples and reference data. A review that took an afternoon can fit into a short meeting.
  • Compliance and legal teams can check the rules in one place and see that each one appears once. The repeated text check catches the copy that crept into another section and gave a rule extra weight.
  • Developers know before they deploy whether the context and the answer fit the model's window, and how much room is left for user messages and retrieved documents. That avoids answers cut off in production and the support tickets that follow.
  • Budget holders can see which section costs the most on every request. On a busy assistant, trimming a bloated knowledge section is a direct saving on each call.
  • Teams moving between models can compare counts across counters and adjust the allowance before switching, as the move from 128,000 to 8,000 tokens showed in the example.

Because nothing leaves the browser, the tool is also safe for internal prompts that contain pricing, process detail or other material you would not paste into an online service. If you are planning AI work across a whole organisation, our AI and automation strategy service can help set the standards these contexts should meet.

When it is not the right tool

  • Judging quality. The checks are fixed rules that give the same answer every time. They find a missing role or a repeated line, but they cannot tell you whether your instructions are clear or your examples are good. Test the exported prompt with real questions on the real model.
  • Exact counts for every model. Only the two OpenAI counters are exact. For Claude, Gemini and others, the figures are estimates, so leave some margin.
  • Running or versioning prompts. It does not send anything to a model, and it saves nothing between visits. For live testing, version history or team editing, use your AI platform or keep the JSON files in source control.
  • Very large reference sets. The limit is 5 MB of text and 100 sections. If your knowledge base is bigger than that, it belongs in a search or retrieval system, and the context should describe how to use it.
  • The full prompt your system sends. Your platform may add a little text between sections or wrap messages in its own format, so treat the total as a close guide.

For more on why a well planned context makes AI systems dependable, read how context engineering is transforming AI reliability.

Try it yourself

The quickest way to learn the approach is to run the example above, then replace the shop's facts with your own. Open Context Architect, start from the Customer assistant template, and see how your sections, checks and budget compare.