Prompt Injection & Guardrails Best Practices
This page distills the Prompt Injection & Guardrails section into one standalone checklist - positive, enforceable practices for isolation, validation, filtering, detection, and red-teaming.
Search across all documentation pages
This page distills the Prompt Injection & Guardrails section into one standalone checklist - positive, enforceable practices for isolation, validation, filtering, detection, and red-teaming.
It is meant for design reviews, production-readiness gates, and periodic audits - not as a one-time read.
trace_id, severity, rule ids, redacted snippets, and content_hash.| Anti-pattern | Why it fails |
|---|---|
| "We put do-not-comply text in the system prompt" | Models still follow tool poison |
| Executing raw model JSON without schemas | Injection becomes side effects |
| Scanning only user messages | Indirect injection wins |
| Logging full tool dumps to shared Slack | Re-injection and secret sprawl |
| Red-team once at launch | Regressions on the next model swap |
| Maximum tool belt for demos left in prod | Blast radius stays huge |
The title frames ten core practices; the lettered groups expand them into enforceable checkboxes covering the full section.
No.
You need them before real users, real credentials, or write side effects.
Isolation (B) and validation/least privilege (C), then detection (D), then formal red-team (E).
Point to code, config, CI jobs, or dashboards - for example the tool registry module, schema tests, or alert metric.
No.
Libraries help filters and some validators; isolation, tool design, and ops remain yours.
Demo on a locked profile with mock tools.
Do not disable allowlists on the shared production worker.
Before first production traffic, after material tool or model changes, after incidents, and on a fixed quarterly cadence.
No.
Stronger models can follow sophisticated injections more ably. Mechanical controls still matter.
This section focuses on instruction hijack and linguistic/tool boundaries.
Pair with sandboxes, egress controls, and credential scoping in the agent security section.
Track them as explicit debt with owners and dates - not as quiet failures to ignore.
Yes.
Keep the categories; replace tool classes and severity rules with your standards and link internal runbooks.
How Prompt Injection Attacks Actually Work, then Prompt Injection & Guardrails Basics, then this checklist as a gate.
Stack versions: Pins from the category manifest (verify at build): OpenRouter (~315+ models, July 2026 pricing/fees); LangGraph 1.0+; CrewAI 1.14+; Microsoft Agent Framework 1.0; Vercel AI SDK 6; Pydantic AI (latest); LlamaIndex (latest); OpenAI Agents SDK (latest + MCP); MCP (Linux Foundation governance); A2A (HTTP+SSE+JSON-RPC 2.0); Solana
@solana/web3.js+@solana/spl-token.
Reviewed by Chris St. John·Last updated Jul 16, 2026