LearnQuestion bank

In long chats, the assistant starts ignoring formatting and safety instructions from the system prompt. Why, and how do you fix it?

Applied LLMTechnicalMedium

Theme reported publicly: PolyAI

Answer it yourself first, out loud or on paper, then compare.

Answer

Model answer, written in a candidate's voice

In short

  • Early system rules get diluted as context grows; recent turns and history dominate attention
  • Truncation or summarisation can silently drop the system prompt or constraints
  • Verify token counts, truncation policy, and that the system prompt is sent every turn
  • Re-inject key rules near the end and compact history while preserving constraints
  • Enforce format with structured outputs and validation; test with long-conversation fixtures

In full

It’s usually not one bug but a context-management failure: early system instructions get diluted as the conversation grows, recent user turns and history dominate, and truncation or summarisation can silently drop the system prompt or the constraints inside it. First I’d check the actual request each turn—token counts, the truncation policy, and whether the system prompt is still present—because in a long chat the truncation policy may have dropped them from the request entirely. Then I’d re-inject the few non-negotiable rules near the end, compact history while preserving constraints, and make the output contract machine-checkable with structured outputs plus validation or repair. Finally I’d add long-conversation fixtures to the test suite so formatting and safety regressions are caught before release.

Corrected by an independent AI reviewer.

What a strong answer covers

  • Causes: instructions far back get diluted; history dominates; truncation silently drops the system prompt (bug); user turns override; summaries drop constraints
  • Check token counts, truncation policy, whether the system prompt is actually sent each turn
  • Fixes: re-inject key rules near the end, compact history, enforce format with structured outputs and validation, fixtures with long conversations in the test suite

Common mistakes

  • Making the system prompt longer and louder
  • testing only short conversations