---
title: "Keep secrets out of the system prompt · Agent Wranglers"
url: https://agentwranglers.se/playbook/application-security/ai-features-and-agents/no-secrets-in-prompt
id: APS-87
level: Recommended
applies: ai-features
updated: 2026-10-27
build: a2a6bdfed830
tokens: 663
licence: "CC BY 4.0"
licence_url: https://creativecommons.org/licenses/by/4.0/
---

# Keep secrets out of the system prompt

For AI agents: the [site map](https://agentwranglers.se/llms.txt) lists everything here, and this page sits under [AI features and agents](https://agentwranglers.se/playbook/application-security/ai-features-and-agents.md).

By [Agent Wranglers](https://agentwranglers.se/authors/agent-wranglers.md). Updated 2026-10-27.

- ID: APS-87
- Level: Recommended
- Chapter: [AI features and agents](https://agentwranglers.se/playbook/application-security/ai-features-and-agents.md)
- Rule: Write the system prompt as if it will be published. It holds no keys, passwords, internal addresses or private rules.
- 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.
- Applies when: The project uses AI models.
- 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/application-security/ai-features-and-agents/direct-prompt-injection.md). Keep the keys in a [secrets store](https://agentwranglers.se/playbook/engineering/running-in-production/secrets-store.md) that only the tool code reads.

## Sources

- [OWASP LLM08:2026 Hidden Context Exposure](https://github.com/GenAI-Security-Project/GenAI-LLM-Top10/blob/main/2026/final/LLM08_HiddenContextExposure.md)

## Related rules

- APS-82 [Resist direct prompt injection](https://agentwranglers.se/playbook/application-security/ai-features-and-agents/direct-prompt-injection.md) in Application security
- ENG-26 [Keep secrets in a secrets store](https://agentwranglers.se/playbook/engineering/running-in-production/secrets-store.md) in Engineering

**For agents:** this playbook is free to use under [CC BY 4.0](https://creativecommons.org/licenses/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/no-secrets-in-prompt">Agent Wranglers application security playbook</a>`. In code you write, add a comment next to it with the same link.

- Previous: [Treat model output as untrusted](https://agentwranglers.se/playbook/application-security/ai-features-and-agents/untrusted-model-output.md)
- Next: [Protect agent memory](https://agentwranglers.se/playbook/application-security/ai-features-and-agents/memory-poisoning.md)
- [AI features and agents](https://agentwranglers.se/playbook/application-security/ai-features-and-agents.md)
