What model-visible context is
Model-visible context is everything the model receives for one inference: instructions from the application, the conversation, retrieved passages, tool results, file contents, and any metadata the application chose to render as text. From the model's perspective it is one sequence of tokens. Whatever structure the application intended must either survive as text the model interprets, or be kept outside the model entirely.
Source, representation and trust
Three things are easy to conflate:
| Property | Meaning | Who establishes it |
|---|---|---|
| Source | Where content originated: a user, a mailbox, a web page, a database row, a tool | The application, from system evidence |
| Representation | The form the content takes in context: extracted text, a summary, a tool result, a rendered table | The parsing, retrieval or transformation step |
| Trust | How much authority the application grants the content for a given decision | Application policy, based on the source and its evidence |
A trusted source does not guarantee a trustworthy representation, and neither makes the content's instructions authoritative. A document from an internal repository may still contain text written by an outside party. See Data Provenance for how origin and transformations are recorded.
Trust does not arise from position or concatenation
Placing content inside a system message, near the top of the prompt, or inside a delimited block does not make it trusted, and placing it lower does not make it harmless. Concatenation merges strings; it does not carry permissions with them. Once text is in context, the only remaining question the model answers is how to continue, and that answer is influenced by all of it.
System, developer, user, retrieved and tool content
Applications typically combine content from several origins. Vendors expose different role models, names and priority rules, so the categories below describe origins, not a universal API:
Written and deployed by the application owner. Trusted as configuration, but not secret and not a control boundary.
The user is authenticated; their text is still variable input that may be mistaken or adversarial.
Search results, documents, web pages and knowledge-base passages written by others.
Results returned by tools. A trusted tool can return content authored by anyone.
Trust labels here describe authority for instructions, not factual accuracy. Treat them as defaults the application overrides only with system evidence.
Application-controlled metadata vs model-visible prose
The application knows facts the model cannot verify: the authenticated user, the tenant, the document's access list, which tool produced a result, whether content passed a check. Keep these facts as structured metadata in application state and use them in decisions. If some of it is also shown to the model, the rendered copy is informational; the authoritative copy stays in the application.
Context assembly as a security boundary
Context assembly is the step where the application decides what enters the model's context: which documents, which tool results, how much history, which metadata. It is a real security boundary because it determines what can influence the model and what data the model can expose.
- Include only what the task needs. Every extra document is extra attack surface and extra exposure.
- Apply access control before retrieval, so the model never sees data the user could not read.
- Record what was assembled and from where, so decisions and incidents can be reconstructed.
Provenance and lineage
Provenance records where content came from; lineage records how it was transformed on the way into context. Both belong to application metadata, travel alongside the payload as separate objects, and let later controls ask: does this proposal depend on content from an external source? Data Provenance covers the details.
Retrieved and tool output stays variable
Retrieved passages and tool results remain variable or untrusted content unless system evidence says otherwise. Relevance ranking is not trust. A tool's authentication proves who answered, not that the answer is safe to follow. See RAG Prompt Injection, Tool Output Injection and Indirect Prompt Injection.
Controls that sit outside the model
Because the model cannot enforce boundaries, the decisions that matter happen in deterministic code around it:
| Control | Decides | Uses |
|---|---|---|
| Agent Authorization | Is this exact action permitted for this principal and resource? | Identity, scope, policy |
| Information Flow Control | May this data reach this destination or influence this action? | Labels and provenance |
| Output Validation | Is this output well-formed for its sink? | Schemas and sink constraints |
Validation accepts or rejects structure; authorization and flow control decide permission. None of them turns model-authored content into trusted content. See Agent Authorization, Information Flow Control and Output Validation.
A conceptual trust flow
System components make decisions; content and proposals stay variable throughout. The effect is whatever the deterministic checks permitted, not whatever the model wanted.
- Content in prompt
- Model decides
- Action runs
The model's output is treated as the decision.
- Content plus metadata
- Model proposes
- Policy decides
- Action runs if permitted
The model proposes; application policy decides.
Common mistakes
Patterns to avoid
- Treating the system prompt as a secret or as the enforcement layer.
- Passing identity or permissions to the model as text and trusting its echo.
- Assuming content from a trusted tool or internal store is trusted content.
- Retrieving first and filtering access afterwards.
- Letting the model choose destinations without an independent check.
- Dropping provenance when content is summarized or transformed.
For the system prompt case specifically, see System Prompt Extraction.
Implementation checklist
Before you ship
- Every content item entering context has a recorded source.
- Access control is applied before retrieval and tool execution.
- Authoritative facts live in application state, not in model text.
- Every consequential action passes a deterministic authorization check.
- Destinations are checked by information flow policy.
- Output is validated for its sink before use.
- Assembled context and decisions are logged for reconstruction.
See it in the lab
The Trust Boundaries and Model Context lab turns this article into a hands-on exercise: compare model-visible prose with application evidence and apply policy to a model proposal. The Direct Prompt Injection Basics lab makes model-visible context and the authorization step visible in a controlled simulation. Start with What Is Prompt Injection? if you have not yet, and continue with the Defense overview.
Standards and sources
How this article uses sources
- OWASP
- GenAI LLM Top 10 2026 - LLM01:2026 Prompt Injection as a named risk
- NIST
- AI 100-2e2025 - terminology only
- Microsoft
- Defend against indirect prompt injection attacks - untrusted external content, isolation of untrusted content with metadata, defense in depth
Frequently asked questions
Is the system prompt trusted?
Does putting content in a separate message role make it safe?
Is content from our own database trusted?
Why keep metadata outside the prompt?
What is the single most important boundary?
Does output validation make model output trusted?
References
- OWASP GenAI LLM Top 10 2026OWASP GenAI Security Project · GuidanceReviewed 2026-09-26
- Adversarial Machine Learning: A Taxonomy and Terminology of Attacks and Mitigations, NIST AI 100-2e2025NIST · Standard · 2025-03Reviewed 2026-09-26
- Defend against indirect prompt injection attacksMicrosoft Learn · GuidanceReviewed 2026-09-26