THU-819: Reply in the conversation's language — prompt directive + eval suite - #1245
Merged
raivieiraadriano92 merged 5 commits intoSep 3, 2026
Conversation
Semgrep Security ScanNo security issues found. |
|
Preview environment destroyed 🧹 Stack |
PR Metrics
Updated Mon, 31 Aug 2026 12:18:36 GMT · run #2859 |
raivieiraadriano92
marked this pull request as ready for review
August 31, 2026 12:19
raivieiraadriano92
deleted the
raivieiraadriano92/thu-819-make-the-model-reply-in-the-conversations-language
branch
September 3, 2026 18:52
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes THU-819.
The UI is localized, but the assistant still answered in whatever language the model defaulted to — usually English — even in a thread the user was writing in Portuguese.
The change
A
# Languagesection in the system prompt: reply in the conversation's language, stay there when foreign-language content shows up mid-thread (a pasted traceback, English search results), switch on an explicit request, and fall back to the app language when a turn establishes none. No detector and no new setting, per the ticket.It sits in the stable half of the prompt, so it costs one cache miss on a language switch and nothing per send. The app language reaches it via
getActiveLocale(), and the fallback language is named by a newenglishLanguageName()inshared/i18n/locales.ts. Both engines get it from the sameprepareAiRequestConfigoutput — legacy viaassembleBuiltInModelInput, Pi viacomposeAppHarnessSystemPrompt— now covered by tests.Also: the prompt's date moves from
toLocaleString('en-US', …)tosourceLocale. It stays English deliberately — it is model-facing context, and localized CLDR output would put ICU-version-dependent text into the prompt. Prompt bodies, widget instructions, and skill instructions are unchanged: we direct output language, we don't translate behaviour-critical text.Eval suite
A
languagecategory insrc/ai/eval/— 8 Chat scenarios, one per claim the directive makes, judged semantically and scoped to the assistant's own prose so quoted English doesn't fail a Portuguese answer. Two new knobs:EVAL_LANGUAGE(pins the run's app language — Bun otherwise resolvesenalways, leaving the fallback untestable) andEVAL_SUITES(run one suite in isolation instead of paying for all ~120 scenarios).EVAL_SUITES=language(app languageen)EVAL_LANGUAGE=ja EVAL_SUITES=languageEVAL_SMOKE=1(regression control)One known failure, left failing
language-fallback-terse-01: a barehm?with the app language set to Japanese gets an English reply, reproducibly. Bare code correctly falls back, so the clause works — it just loses to a Latin-script token that reads as plausible English. Either the scenario is unfair (hm?is an English interjection) or the clause is weak against Latin-script noise. Happy to go either way, but not silently.Notes
evals.ymldoesn't set it, so CI smoke evals may have been failing onINFERENCE_QUOTA_EXCEEDEDsince 003cf59 — I hit it locally, unconfirmed in CI.shared/i18n/was in no test script, so the newlocales.test.tswould never have run. Added totestandtest:5x.type-check,lint,format-check,i18n:checkclean (no catalog churn — every added string is model-facing English). Tests: 4731 pass / 0 fail, plus 258 / 0.