Repository navigation
fix(chat): answer in the question's language, or the one asked for, and rewrite an English answer once - #2062
Merged
Conversation
…iter, and rewrite an English answer once Co-Authored-By: Claude Opus 5.5 <[email protected]>
…the writer, never rewriting it away Co-Authored-By: Claude Opus 5.5 <[email protected]>
… and keep a stopped rewrite's hold "How visible are we in German prompts?" named a language in passing but read as a request, so the writer was told to answer in it and the rewrite was off. "in <language>" now asks only after an answer verb (not before a noun), before "please"/"only", at the start, or ending a message that isn't a question, and the writer's line names the language asked for. A Stop during the rewrite now keeps its budget hold, as a model step does, and ends the run stopped instead of finishing it.
…object, and match capitalized Turkish names
"İngilizce yazılmış promptlar", "Almanca sayfamız cevaplarında" and "Almanca olarak kaç prompt" named a language in passing but read as an ask, as did "a German version of the site" and "in Spanish, please" mid-sentence. A Turkish ask now needs a request verb as a whole word after the language (cevap ver, yaz, anlat, çevir), with no place or owner word between; a version or translation is asked for only after a verb like give or write; "please" counts at the end of the message.
gkhngyk
previously approved these changes
Nov 3, 2026
# Conflicts: # web/src/lib/chat/engine.test.ts # web/src/lib/chat/engine.ts
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.
Summary
Chat answers in the language the person writes in, or in the language they ask for ("answer in English", "İngilizce cevap ver"). This is the owner's rule (2026-10-31, clarified 2026-11-03).
Chat's model test set (W4-35) caught a case that broke it: Claude Haiku 5.5 answered "Bu hafta Perplexity'de neden düştük?" in English. Haiku is the model that answers when it is picked in the menu, and the one that writes Help answers.
Why it happened: the language rule sits at the top of the system prompt. The writer then reads the person's question followed by pages of English data and app notes: read results, the injection note. A small model answers in the language it read last.
Fix (
web/src/lib/chat/language.ts, used byengine.ts):text.replacedevent.[placeholders].What the rewrite costs: only when it fires, which should be rare now that the language is named. It is one call: the answer goes in (about 200–1,500 tokens with the short instruction) and comes back about the same length. That is about $0.001 on Haiku 5.5, about $0.01–0.03 on Sonnet 5.5, under $0.001 on GPT-6 Luna, and about $0.01–0.03 on GPT-6.1 Sol or Gemini 4 Argon. It is charged to the workspace's AI limit like any step. An answer in the right language costs nothing extra; the language line is a few tokens.
Related issue
None. Found by the Chat Wave 4 model test set (W4-35).
Type of change
feat— New featurefix— Bug fixchore— Maintenance / dependenciesdocs— Documentation onlyrefactor— Code change that neither fixes a bug nor adds a featuretest— Adding or updating testsHow to test
cd web && yarn vitest run src/lib/chat/language.test.ts src/lib/chat/events.test.ts src/lib/chat/engine.test.ts -t "language". Covered:No migration. No new environment variables. One new event type (
text.replaced); an older browser skips it and keeps the streamed text. No Help change: the visible behavior is the rule Chat already promised.Checklist
yarn lintpassesyarn typecheckpassesyarn format:checkpasseshelp/(or no user-visible change)CI passed on this branch (f403e97), run on the fork (https://github.com/cihan-gyk/ansvisor/actions/runs/41599163691): schema is up to date; web
format:check, lint, typecheck, all tests andyarn buildpass; server lint,format:checkand all tests pass.🤖 Generated with Claude Code