Why Structure Matters
The longer a prompt gets, the more important its structure becomes. A 200 token prompt can be unstructured and still work. A 2000 token prompt with mixed instructions, context, examples, and input is almost guaranteed to underperform unless its parts are clearly delimited. Structure does three things at once. It makes the prompt parseable for the model, so it can distinguish instructions from data. It makes the prompt readable for your team, so you can maintain it over time. And it makes the output parseable for your code, so you can extract the result reliably. Inside PANTA OS, every assistant has a system prompt that benefits from the structure described on this page. The longer the system prompt, the more important the structure.XML Tags
XML tags are the most flexible structuring tool because they can be nested, named freely, and parsed easily. Most modern models have been trained extensively on XML tagged prompts and respond particularly well to them. There is no canonical set of tag names. Pick names that describe what they contain, and use them consistently across your prompts.- Use consistent tag names. If you call something
<context>once, do not call it<background>later. Consistency reduces the chance of misinterpretation. - Nest where the structure has a natural hierarchy. Multiple documents go inside a
<documents>tag, each as a<document>with an index attribute. - Refer to tags by name in your instructions. “Using the contract in the
<contract>tags above, identify …” is clearer than “Using the contract above, identify …”.
JSON Output Contracts
When the output will be parsed by code, define the schema in the prompt. There are three ways to do this, in increasing order of reliability. The first is a description of the schema in prose:System Prompt Anatomy
The system prompt is the place to put everything that should hold for the entire conversation: the role, the rules, the constraints, the format expectations. A clean system prompt has roughly six sections, in this order:- Role and identity. Who the assistant is, what their expertise is, and who they are talking to.
- Core responsibilities. The tasks the assistant is expected to perform.
- Behavior rules. How the assistant should communicate: tone, formality, length, language.
- Constraints and refusals. What the assistant must not do, and what to do when asked.
- Output format. The default format for responses.
- Examples (optional). Two or three short interactions that demonstrate the rules.
Order of Elements
Within a prompt, order matters more than people expect. Recency bias in models is well documented: instructions placed at the very end of a prompt tend to be followed more reliably than instructions placed in the middle. A few practical guidelines:- Put the role and core rules at the top. They define the frame.
- Put long context in the middle. Documents, transcripts, examples.
- Put the immediate task at the end. “Now, given the document above, produce …” should be the last thing the model reads before it generates.
Delimiters for input
Always delimit the input clearly. The most common choices, in order of preference:- XML tags.
<document>...</document>. The most flexible and best supported across modern models. - Triple backticks.
.... Standard for code and unstructured text. - Triple quotes.
"""...""". The classic delimiter, still works. - Markdown headings.
# Documentfollowed by the content. Less precise but readable.
