fix: harden Korean-only output lock (front+end, explicit script ban)
qwen2.5:7b leaked Chinese/Cyrillic mid-reply despite the OUTPUT_LANGUAGE lock, which was buried mid-prompt. Repeat the lock at the END of the system prompt (recency) and ban specific foreign scripts explicitly.
This commit is contained in:
@@ -1704,6 +1704,12 @@ def run_reply_engine(db: "Database", cfg, tts: Optional[Any],
|
||||
# else: tools are passed via the native tools API parameter — do not include tools_desc
|
||||
# here as well, since that confuses the model and causes it to not use tools properly.
|
||||
|
||||
# Recency reinforcement: repeat the language lock at the very END too.
|
||||
# In a ~5k-token prompt the front-placed rule gets "lost in the middle";
|
||||
# bigger models (qwen2.5:7b) otherwise leak Chinese/Cyrillic mid-reply.
|
||||
if _lang_directive:
|
||||
guidance.append(_lang_directive)
|
||||
|
||||
return "\n".join(guidance)
|
||||
|
||||
messages = [] # type: ignore[var-annotated]
|
||||
|
||||
Reference in New Issue
Block a user