Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix system message handling to preserve user-configured system prompts #1764

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

IAmStoxe
Copy link

Problem

Previously, when a preprompt was provided, it would completely replace any user-configured system message instead of being prepended to it.

Solution

  • Added explicit detection of existing system messages
  • When a system message exists and preprompt is defined, prepend preprompt to the existing content
  • When a system message exists and no preprompt is defined, preserve the user's message unchanged
  • When no system message exists, create one with either preprompt or empty string
  • Maintained handling for models that don't support system roles

Testing

Scenario User System Prompt Preprompt Result
1 ❌ No ❌ No System message with empty content is created
2 ❌ No ✅ Yes System message with preprompt content is created
3 ✅ Yes ❌ No User's system prompt is preserved unchanged
4 ✅ Yes ✅ Yes Preprompt + "\n\n" + User's system prompt

Breaking Changes

None - this change preserves all existing functionality while fixing the prompt handling logic.

Previously, when a preprompt was provided, it would completely replace any user-configured system message instead of being prepended to it.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant