Prompt injection succeeds when an agent treats untrusted content as authority. That framing changes the fix: you do not sanitize a string, you scope the authority.
Where the authority comes from
- The system prompt has the highest trust.
- Tool outputs are data, not instructions.
- User input is the end of intent, not authority over your runtime.
The five guardrails that actually work
- Tool allowlists per role — support can read orders, never refund or export.
- Separate channels — instructions and data travel on different parsed paths; never merge them before policy checks.
- Structured outputs only — tool calls go through schemas; free text never gets executed.
- Human-in-the-loop for escalation — any threshold crossing requires a signed review.
- Evals as CI — your prompt suite belongs in the build, not in a notebook on someone’s laptop.
The checklist we use in production
- Scan retrieved documents for directive phrases before they enter context.
- Render tool output wrapped in provenance tags the model is told to distrust.
- Define a minimum evidence level before a tool call can mutate state.
- Log tool calls, not just prompts, and redact secrets before upload.
- Fail closed: unknown tool, unknown argument, unknown tenant — stop and ask.
If your agent can spend money, delete data or deploy production, assume it will be tested by someone who wants to know whether your trust model is real.