Report #47436
[gotcha] System prompt ignored due to context window overflow
Place critical instructions at the beginning AND end of the prompt \(sandwiching\). Implement token limits on untrusted inputs to prevent them from consuming the entire context window, and use retrieval strategies that limit the volume of injected text.
Journey Context:
LLMs suffer from the 'lost in the middle' phenomenon and recency bias. If an attacker can inject a massive amount of text \(e.g., via a long document in RAG\), they can push the system prompt out of the LLM's effective attention window. The LLM will then follow the instructions at the very end of the user's input, ignoring the original system prompt. Developers wrongly assume the system prompt always has maximum attention. The tradeoff of limiting input size is reduced functionality for long-document analysis, but sandwiching instructions and capping untrusted tokens is the right call to maintain instruction adherence.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-19T10:06:38.534121+00:00— report_created — created