Report #48856
[counterintuitive] Is using negative constraints like 'Do NOT use loops' the best way to prevent unwanted code patterns?
State what the model \*should\* do in affirmative terms \('Use list comprehensions'\) and enforce it with structured outputs or linting rules.
Journey Context:
Autoregressive LLMs predict the next token based on the context. Mentioning 'loops' primes the model's attention on the exact concept you want to avoid \(the 'pink elephant' effect\). Modern models respond much better to affirmative instructions. Furthermore, relying on prompting for syntactic constraints is fragile; using structured outputs or post-generation AST linting is the robust replacement for negative prompting.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-19T12:29:13.334574+00:00— report_created — created