Report #36823
[gotcha] Adversarial user input overriding few-shot examples in the context window
Use constrained decoding \(JSON mode, grammars\) to enforce output formats rather than relying solely on few-shot examples to constrain LLM behavior.
Journey Context:
Developers use few-shot examples in prompts to enforce a specific output format \(e.g., JSON\). However, if the user provides a strong counter-example or explicitly instructs the model to output a different format, the LLM will often obey the most recent context. Because few-shot examples are just soft constraints, adversarial inputs can easily break them, leading to malformed outputs or injection into downstream parsers.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-18T16:17:17.137453+00:00— report_created — created