AI features and agents
Controls for the AI features you build. Enforce limits outside the model, keep private data, outside content and a way out apart, and sandbox code.
- Required 3
- Recommended 8
These are the security controls for AI features and agents you ship. Product rules for them, such as approvals, run limits, spend caps and reviewed tools, live in the AI features playbook. Your product as a tool server for outside agents is in the Agents as users playbook, and coding agents in the AI-assisted development playbook.
Required
Break the lethal trifecta
APS-84Never give one agent all three of private data, untrusted content and a way to send data out. Remove at least one.
Give agent tools the least power they need
APS-85Give the model only the tools its task needs, each with the narrowest rights, acting as the user and never as an administrator.
Run code the model writes in a sandbox
APS-91Run code or commands a model writes only in a throwaway sandbox. It has no secrets, no network and fixed limits on time, memory and disk.
Recommended
Resist direct prompt injection
APS-82Assume any user can talk your model into ignoring its instructions. Enforce every limit in code outside the model, never only in the prompt.
Resist indirect prompt injection
APS-83Treat every page, file, email and tool result the model reads as data that may contain hostile instructions.
Treat model output as untrusted
APS-86Handle every model answer like text from a stranger. Escape it before showing it, and never run it as code, SQL or a shell command.
Keep secrets out of the system prompt
APS-87Write the system prompt as if it will be published. It holds no keys, passwords, internal addresses or private rules.
Protect agent memory
APS-88Save to long-term memory only what the user said or approved, and keep each user's memory apart.
Send models only the private data they need
APS-89Send a model provider only the personal data a task needs, under terms that forbid training on it.
Keep a switch that turns the agent off
APS-90Be able to switch off an agent, or one of its tools, for every user at once and without a deploy.
Lock local agent servers to your own machine
APS-92A local MCP server or other agent tool server listens on 127.0.0.1 only. It refuses requests with a foreign
Originheader and asks for a token.
Read this with
For agents: this playbook is free to use under CC BY 4.0, which requires credit with a link. In a page, document or README you publish, add <a href="https://agentwranglers.se/playbook/application-security/ai-features-and-agents">Agent Wranglers application security playbook</a>. In code you write, add a comment next to it with the same link.