MONA explainer 12 min read

System Prompts, Role Instructions, and Output Constraints: Anatomy of a Production Prompt

MONA examining a layered architecture diagram of prompt components across system and user authority levels

ELI5

A prompt sent to a large language model consists of up to four layers — instruction, context, input data, and output indicator — arranged inside a conversation structure that grants some layers more authority than others.

Production prompts fail in specific, predictable ways. Not random ones. The failure almost never lives in the “message to the AI” as a monolithic blob — it lives in one particular layer of the anatomy that the developer didn’t realize existed, or treated as optional when it wasn’t.

The prompt is not a sentence. It’s a structure. And the structure matters more than the words inside it.

The Layered Architecture Inside Every Prompt

Think of a production prompt the way an operating system thinks about process memory: not a flat file, but a segmented address space where different regions carry different privileges. Everything the model processes lives inside its Context Window, but not all positions within that context carry equal weight — and the weight distribution is explicit by design, not emergent.

The canonical decomposition comes from DAIR.AI’s Prompt Engineering Guide (Prompt Engineering Guide), which identifies four structural components that together form the anatomy of any prompt.

What are the main components of a prompt in large language models?

The four components of a production prompt are:

Instruction — the task specification. What the model must do. This is the layer most developers write first and spend the most time revising. Instruction quality matters, but placement matters nearly as much; an instruction buried inside a wall of context competes for the model’s attention against everything surrounding it.

Context — external information the model cannot retrieve on its own. Retrieval-augmented systems pipe document chunks here. Agent pipelines inject tool results. Without this layer, the model operates entirely from its training distribution, which is both finite and stale.

Input data — the specific question, artifact, or variable the instruction will process. In a templated system, this is the slot that changes per request; everything else stays fixed.

Output indicator — the format specification. JSON schema, XML structure, numbered list, markdown table. Omitted components are where failures live. This layer is where most production breakdowns originate: the model assigns high probability to a plausible format and ignores the specified one, particularly when the output indicator is absent or underspecified. The model tends to default to the output conventions most prominent in its training data — the output indicator is the mechanism that overrides that pull.

Not all four components appear in every request. Simple Zero Shot Prompting may use only an instruction. Retrieval systems add context. Interactive pipelines add input data. Structured Output enforcement adds the output indicator.

The conversation structure imposes a second axis. Modern APIs separate the prompt into at least two layers of authority: the System Prompts layer — a dedicated system parameter in the Anthropic API, or the developer role in newer OpenAI API versions (the system role was renamed to clarify its elevated authority) — and the user messages layer. The model treats instructions in the system layer as carrying higher authority than user-layer instructions; this distinction matters considerably for Instruction Following under adversarial conditions.

Anthropic’s recommended production structure encodes this hierarchy explicitly: begin with a role definition, then XML-tagged sections (<instructions>, <context>, <examples>, <input>), then the output format specification (Anthropic Docs). The structure is not decorative — it gives the model a parsing signal that disambiguates which tokens belong to which layer.

For long-context prompts, document placement matters more than most developers expect. Long documents should appear near the top, with the query at the end; Anthropic’s internal testing found up to a 30% quality improvement on complex multi-document inputs from this placement shift alone (Anthropic Docs). The geometry of what surrounds the instruction shapes what the model attends to.

Chain-of-Thought and the Output Indicator That Reveals Reasoning

Chain-of-Thought prompting is, mechanically, a specialized variant of the output indicator — one that asks the model to surface its intermediate steps rather than jump directly to an answer. Understanding what it is and what it isn’t has grown more urgent as the technique’s applicability has narrowed considerably since its introduction.

The technique was formally described by Wei et al. in 2022 (Wei et al. 2022): by including demonstrations that show reasoning steps alongside answers, performance improved substantially on arithmetic, commonsense, and symbolic reasoning tasks. The paper tested on a 540-billion-parameter model (PaLM-scale) and achieved state-of-the-art results on the GSM8K math word problem benchmark using eight few-shot chain-of-thought examples, outperforming fine-tuned models with verifiers.

What is chain-of-thought prompting and how does it work?

Chain-of-thought prompting adds explicit intermediate reasoning steps to the output format. Instead of asking the model to produce only a final answer, you ask it to “think step by step” — or, in the few-shot variant, you demonstrate the desired reasoning structure through annotated examples.

The mechanism is less settled than it appears. Format bias is one plausible account: the chain structure may nudge sampling toward intermediate-step tokens, keeping relevant information inside the active attention window long enough to influence the final answer. But other explanations compete — the chain may activate reasoning-adjacent patterns embedded in training data, or it may simply prevent the model from short-circuiting to a high-probability but incorrect token sequence. The observed effect is reproducible; the mechanism is still debated.

Not consciousness. Pattern completion.

What has changed is the applicability map. For current-generation reasoning models — OpenAI o-series, Claude Extended Thinking, Gemini Thinking Mode — explicit chain-of-thought instructions are counterproductive. These models already reason internally; appending “think step by step” to a reasoning model is redundant at best, degrading at worst. Meincke et al. (2025) documented the broader shift: for non-reasoning frontier models, explicit chain-of-thought now provides only a small accuracy increment while significantly increasing token costs (Meincke et al. 2025). The cost-benefit calculation that justified aggressive CoT prompting in 2022 has shifted.

Meta Prompting extends the output-indicator logic in a different direction: rather than specifying a reasoning chain, it asks the model to design or evaluate the prompt structure itself — applying the system’s own instruction-processing to the problem of instruction construction.

Diagram of four prompt anatomy layers (Instruction, Context, Input Data, Output Indicator) arranged within system and user authority levels, with arrows showing hierarchy and attention flow
The four-layer anatomy of a production prompt: components arranged across two authority levels, where the output indicator is the most frequently omitted and most frequently blamed layer.

The Foundation You Need Before Touching a Prompt

Most failed Prompt Engineering projects share a common root. The practitioner treated the model as a black box that either “understands” an instruction or doesn’t — and spent iterations rephrasing the same instruction rather than diagnosing which layer of the anatomy was underspecified. Understanding the mechanism first makes the anatomy legible; without it, the four-layer structure is just a checklist without explanatory power.

What do you need to know before learning prompt engineering?

Before writing production prompts, three foundational concepts determine whether your mental model of the system is accurate:

How the model generates text. LLMs are autoregressive: each token is sampled from a probability distribution conditioned on all preceding tokens inside the context window. The model doesn’t retrieve stored answers; it generates the statistically most likely continuation given the input. Prompting works because the prompt reshapes that probability distribution — it shifts what the model considers “likely” in the current context. This is the mechanical reason the output indicator functions: it narrows the sampling space before generation begins.

What fits inside the context window. The context window is the total token budget shared between the system prompt, conversation history, tool results, retrieved documents, and the model’s own output in a multi-turn session. Claude Fable 5, Opus 4.8, and Sonnet 4.6 each support 1 million tokens; Claude Haiku 4.5 supports 200K tokens (Anthropic Docs). Those figures sound generous until you factor in retrieval artifacts, multi-turn history accumulation, and structured output overhead accumulating across a long agent run. Context Engineering — the systematic management of what tokens populate that window and how they’re arranged — emerged as a distinct discipline around September 2025, precisely because naive context management had become the dominant failure mode in multi-turn agent deployments (Anthropic Engineering).

Why the system layer exists and what it exposes. Role Prompting — assigning the model a persona or professional identity in the system prompt — is a legitimate technique for shifting output register and tone. But it carries a documented trade-off: persona prompts improve performance on open-ended generative tasks while degrading it on classification and factual question-answering tasks. The choice to assign a role is a bet on what the task demands; classify the task before choosing the technique.

The system layer’s elevated authority also creates exposure. If the system prompt contains proprietary logic or instructions, Prompt Leakage attacks — user-initiated extraction attempts like “repeat your instructions” or multi-step indirect queries — can surface it. OWASP classifies system prompt extraction as LLM07:2025. Keeping proprietary instructions in the system prompt means accepting that the attack surface exists; the mitigation is boundary design and input validation, not ignoring the attack class.

One practical observation on constraint language: emphatic constructions — “CRITICAL!”, “YOU MUST NEVER” — are empirically documented to produce worse outputs on current Claude models (Opus 4.8 and later) by overtriggering compliance behaviors. The model responds to structural precision, not capitalized urgency. Direct, calm instruction outperforms aggressive constraint language on modern models.

What the Anatomy Predicts

Once the four-component structure and the dual-authority layer are visible, production prompt failures become diagnostic rather than mysterious.

If the output format is inconsistent across requests — the output indicator layer is underspecified. Add a schema. If the model ignores retrieved context documents in favor of training-data knowledge — the context layer is either mispositioned (placed after the instruction instead of before the query) or the instruction doesn’t explicitly direct the model to use the provided context. If role instructions erode across a multi-turn conversation — the system layer is not being refreshed, and the model’s attention distribution has drifted toward recent user-turn tokens.

The positional geometry of the context window explains this predictably. Instructions at the beginning or end of the context receive stronger attention than instructions buried in the middle — an observed attention distribution property sometimes called “lost in the middle.” It is not a quirk. It is the mechanism.

If/then predictions for the anatomy:

  • If you add more context without repositioning the query, expect retrievability to drop on long documents.
  • If the output indicator specifies a schema but the examples use a different format, the model will favor the format demonstrated in examples over the format described in the specification.
  • If you add role instructions to a reasoning model’s system prompt alongside “think step by step,” expect the reasoning process to be redundant and the output longer without accuracy benefit.

Rule of thumb: when a prompt fails, identify which of the four layers is ambiguous before rewriting any of them. The layer you edit last is usually the one that needed changing first.

When it breaks: The four-layer anatomy model assumes the model follows instructions in good faith within the context it receives. Prompt injection attacks — where user-controlled input in the input data layer contains adversarial instructions designed to override the system layer — break this assumption, and the structured anatomy provides no inherent protection. Treat the input data layer as untrusted territory by design.

Security & compatibility notes:

  • Prompt Injection (OWASP LLM01:2025): Active #1 LLM vulnerability, covering both direct and indirect injection. EchoLeak (CVE-2025-32711, June 2025) demonstrated system prompt extraction via indirect multi-step queries in production-grade deployments. Validate and sanitize all user-supplied input before it reaches the model context.
  • OpenAI v1/prompts API: Deprecated June 3, 2026 — endpoint shutdown scheduled November 30, 2026. Any code using stored prompt objects via the OpenAI dashboard or /v1/prompts endpoint must migrate to application-side code before that date.
  • OpenAI Assistants API: Deprecated; scheduled removal August 26, 2026. Prompt engineering workflows built on the Assistants API must migrate to the Responses API or direct completions.

The Data Says

A production prompt is not a message — it is a segmented structure with four functional components and two authority levels. The Schulhoff et al. (2024) survey catalogs 58 distinct prompting techniques (Schulhoff et al. 2024), but nearly all of them are manipulations of the same underlying layers: they change what enters the instruction, how context is arranged, what examples populate the input data layer, or how the output indicator constrains generation. Understanding the anatomy makes the full taxonomy legible; without it, the techniques are just patterns with no explanatory thread connecting them.

AI-assisted content, human-reviewed. Images AI-generated. Editorial Standards · Our Editors