Skip to content

[Feature] Implement System Rule Re-injection for Long Conversations #1

@JStaRFilms

Description

@JStaRFilms

Description:

Problem:
In long conversations (10+ turns), the LLM can suffer from "context drift," where the initial system prompt is too far back in the context window. This can cause the model to "forget" its core instructions, especially the critical rule about conditional Markdown formatting (~ prefix) and the default to be concise.

Proposed Solution:
To combat this, we will implement a "rule re-injection" mechanism. Instead of resending the entire system prompt, we will inject a concise, special "reminder" message into the context at regular intervals.

Implementation Details:

  1. In hotkey_manager.py, before sending the messages list to the LLM, check the length of the conversation history.
  2. If the number of messages is a multiple of 10 (representing 5 full user/assistant turns), inject a new system message right before the latest user prompt.
  3. The injected message should be a condensed reminder of the core rules, for example:
    {
      "role": "system",
      "content": "[SYSTEM REMINDER: Adhere to core rules. Use Markdown ONLY if prompt starts with ~. Otherwise, PLAIN TEXT ONLY. Be concise by default.]"
    }

Acceptance Criteria:

  • The system correctly injects the reminder message every 5 user turns.
  • In a long conversation test (20+ turns), the AI's adherence to the conditional Markdown rule and conciseness remains consistent.
  • The reminder message does not derail the conversational flow.

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions