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:
javis-bot
2026-06-14 22:25:33 +09:00
parent 3d620dc4c7
commit d970bf276e
2 changed files with 12 additions and 2 deletions

View File

@@ -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]