Skip to content

feat(i18n): strengthen output-language.md template to enforce language compliance#2005

Merged
tanzhenxin merged 1 commit intoQwenLM:mainfrom
zhangxy-zju:feat/strengthen-output-language-template
Mar 2, 2026
Merged

feat(i18n): strengthen output-language.md template to enforce language compliance#2005
tanzhenxin merged 1 commit intoQwenLM:mainfrom
zhangxy-zju:feat/strengthen-output-language-template

Conversation

@zhangxy-zju
Copy link
Copy Markdown
Collaborator

@zhangxy-zju zhangxy-zju commented Feb 28, 2026

Summary

  • Strengthen the output-language.md template wording from soft preference ("Prefer responding") to mandatory rule ("You MUST always respond"), resolving inconsistent output language in multi-turn conversations
  • This fixes two classes of language inconsistency:
    • LLM mirroring user's input language instead of the configured output language
    • LLM being influenced by mixed-language content from QWEN.md, downloaded Skills, Agents, and Extensions, causing mid-session language switching or Chinese-English mixed responses
  • Add an exception clause allowing users to explicitly override the language for the remainder of a conversation
  • Remove the "When a conflict exists" escape clause that allowed injected context to silently override the language setting
  • Add 3 unit tests validating the new template content

Changes

File Change
packages/cli/src/utils/languageUtils.ts Update generateOutputLanguageFileContent() template
packages/cli/src/utils/languageUtils.test.ts Add 3 tests for new template wording

Before

## Goal
Prefer responding in **${language}** for normal assistant messages and explanations.

## When a conflict exists
If higher-priority instructions (system/developer) require a different behavior, follow them.

After

## Rule
You MUST always respond in **${language}** regardless of the user's input language.
This is a mandatory requirement, not a preference.

## Exception
If the user **explicitly** requests a response in a specific language, switch to the
user's requested language for the remainder of the conversation.

Test Plan

  • npx vitest run src/utils/languageUtils.test.ts — 41 tests pass (3 new)
  • Manual: set output-language.md to English, send Chinese input -> LLM should respond in English
  • Manual: install an English-language Skill/Agent, set output language to Chinese -> LLM should consistently respond in Chinese without mixing English
  • Manual: after language enforcement, say "please reply in English" -> LLM should switch to English for the rest of the session

Linked Issues

Closes #2003

…e compliance

Replace soft "Prefer responding" wording with mandatory "MUST always respond"
rule to improve LLM adherence to configured output language. Add exception
clause allowing users to explicitly override for the remainder of a conversation.
Copy link
Copy Markdown
Collaborator

@tanzhenxin tanzhenxin left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

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.

feat(i18n): weak output-language.md template causes inconsistent LLM output language across multi-turn conversations

4 participants