Indirect Prompt Injection › The compound-system model we will build
Language AI HandbookAll chapters Use the library's visitor guide and catalog location as familiar inputs. Each synthetic row has a source identifier, a display title, a room, and a preassigned screening mark. Think of the display title as a convenience field. The room is a typed fixture field the task needs. A separate truth label tells us which cases in this tiny exercise were intended to be flagged.
The application knows the current reader's permission separately from the row. An enum represents a screening result, and another enum represents a policy decision. The simulation consumes these values and returns a view of permitted fields. It does not call a model, classify raw text, connect to a service, or perform a tool action.
PythonIn [3]Expand
from dataclasses import dataclass
from enum import Enum
class ContentMark(Enum):
CLEAR = "clear"
INSTRUCTION_LIKE = "instruction-like"PythonIn [4]Expand
class Strategy(Enum):
REJECT_FLAGGED = "Reject marked"
RESTRICT_FLAGGED = "Restrict marked"
MINIMIZE_ALL = "Minimize all"
class Decision(Enum):
DENY_ACCESS = "deny access"
DROP_SOURCE = "drop source"
ROOM_ONLY = "room only"
ROOM_AND_TITLE = "room and title"PythonIn [5]Expand
@dataclass(frozen=True)
class Evidence:
source_id: str
title: str
room: str
mark: ContentMark
@dataclass(frozen=True)
class Fixture:
evidence: Evidence
review_expects_mark: boolDefine a small state space before writing policy
Imagine reviewing this implementation with a catalog maintainer. If policy treats the visitor guide as unusable in one branch, the maintainer needs to see whether the reason was access, source quality, or a content mark. A boolean flag called filtered would collapse those reasons and make the behavior hard to diagnose. Instead use a small set of decision values with an explicit interpretation. The set in this chapter distinguishes denial before content policy from dropping an authorized source after applying it. Both decisions can yield no view. Their category is useful when the result reaches the user or a maintainer.
Decide on what the record identifier means. We use an identifier for a whole fixture row. An actual retrieval system may work with one document and many fragments. In that design the permission check starts with the asset to which policy applies. If a fragment is independently authorized, the code needs the fragment's identifier. If access is defined per document, a trusted lookup has to map fragment to document before use. The state carried in the model request is not proof that the lookup happened.
Treat permissions as an argument to the policy function, separate from the retrieved evidence. The application can replace the permission set at the next evaluation without changing the record or its mark. The examples after the worked case will hold those other inputs fixed. With authentication or authorization distributed across service boundaries, whoever owns the permission decision needs a documented strategy for obtaining fresh enough state. The local function accepts the state supplied to it. It cannot tell whether a remote policy provider has recorded a more recent change.
Some applications require an answer to cite individual sources. That creates one more useful check. Ensure that the application records the origin of each selected field in a representation the caller may view. The source identifier in the fixture lets us trace the choice we made. In a real service there may be a distinct public citation identifier rather than the internal record key. Record where the conversion happens before a runtime begins copying sources into response text.
For the toy exercise, call a result useful if it still contains the room field needed by the original task. That definition leaves out several things readers care about, including accuracy, clarity and whether the guidance meets their needs. Keep the word useful anchored to this one criterion in the policy comparison. That will make it clear which conclusions transfer to another application and which require fresh evidence.
Comments
Add to the conversation
A question, a correction, or an example from your own work.
No comments yet. Be the first to share your thoughts!