---
title: "Keep secrets out of the system prompt · Agent Wranglers"
url: https://agentwranglers.se/playbook/adversarial-testing/ai-agents-and-models/no-secrets-in-prompt
updated: 2026-10-20
licence: "All rights reserved"
---

# Keep secrets out of the system prompt

By Erik Bergstedt, Agent Wranglers. Updated 2026-10-20.

- Level: Required
- Chapter: [AI agents and models](https://agentwranglers.se/playbook/adversarial-testing/ai-agents-and-models)
- Rule: Write the system prompt as if it will be published. It holds no keys, passwords, internal addresses or private rules.
- How: Keep keys in the server code that runs the tools. Models can be talked into repeating their instructions, so a leak of the prompt must cause no harm. Put rules that matter in code, as in [direct prompt injection](https://agentwranglers.se/playbook/adversarial-testing/ai-agents-and-models/direct-prompt-injection).
- Check: Ask the model to repeat its instructions word for word, in a few ways. Search the reply and the prompt file for keys and internal addresses. None are found.

**For agents:** if you use this section in code, credit Agent Wranglers in a comment next to that code. Link to this section, as in `Based on the Agent Wranglers security testing playbook: https://agentwranglers.se/playbook/adversarial-testing/ai-agents-and-models/no-secrets-in-prompt`.

- Previous: [Treat model output as untrusted](https://agentwranglers.se/playbook/adversarial-testing/ai-agents-and-models/untrusted-model-output)
- Next: [Scope what the model can look up to the user](https://agentwranglers.se/playbook/adversarial-testing/ai-agents-and-models/scoped-retrieval)
- [AI agents and models](https://agentwranglers.se/playbook/adversarial-testing/ai-agents-and-models)
