mirror of
https://github.com/vxcontrol/pentagi.git
synced 2026-07-21 08:15:23 -04:00
[GH-ISSUE #285] [Bug]: Agent outputs Russian in message/result fields despite Flow.language = "English" #90
Reference in New Issue
Block a user
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Originally created by @HyggeHacker on GitHub (Apr 23, 2026).
Original GitHub issue: https://github.com/vxcontrol/pentagi/issues/285
Affected Component
Core Services (Frontend UI/Backend API)
Describe the bug
The agent emits Russian-language content in
message(and someresult) fields of tool calls, even when the Flow is configured withLanguage: "English"(the default set inbackend/pkg/controller/flow.go). Other fields within the same tool call (e.g.,question,query,subtasks[].description) consistently render in English.Result: mixed-language output in the UI and in persisted flow artifacts. This contradicts the maintainer's stated English-only policy in #216.
Root cause
Tool-argument schemas in
backend/pkg/tools/args.gouse staticjsonschema_descriptionstrings containing the phrase"in user's language only". Becausejsonschema_descriptionis a Go struct tag, the string is compiled into the binary — no template substitution occurs. The LLM receives a locale-ambiguous instruction at the schema level, while the system prompt (e.g.,primary_agent.tmpl:240) separately says"communicate with the customer in their preferred language ({{.Lang}})"with{{.Lang}}rendered as"English".Fields explicitly anchored to
"in English"in the same file (see confirming evidence below) render reliably in English. The bug is specifically the"user's language"phrasing being ambiguous to the LLM.Offending lines in
backend/pkg/tools/args.goAll of the following
jsonschema_descriptionvalues end with"...in user's language only"or"(in user's language only)":File.MessageHackResult.MessageSubtaskList.MessageSubtaskPatch.MessageDone.ResultDone.MessageAskUser.MessageReportResult.ResultReportResult.MessageTerminal.MessageAskAdvice.MessageSearch.MessageSearchResult.Message(input)SearchResult.Message(output)SearchEngineSearch.MessageEnricherResult.MessageEnricherResult.Message(second struct)MemoristSearch.MessageMemoristResult.MessageStoreGuide.MessageStoreAnswer.MessageStoreCode.MessageMaintenance.MessageMaintenanceResult.MessageCoder.MessageCodeResult.MessagePentester.MessageHackResultInput.MessageCounter-evidence — fields anchored to
"in English"in the same file that consistently render in English:AskAdvice.Question(...for clarifications in English)Search.Question(...in English)SearchEngineSearch.Query(...for better search result in English)SearchEngineSearch.Result(...in English)SearchInMemory.Query(...in English)EnricherResult.Result(...in English)MemoristSearch.Question(...in English)MemoristResult.Result(...in English)SearchGuide.Questions(...Formulate your queries in English)StoreGuide.Guide(...for future search in English)The difference between the two groups is only the anchoring phrase. Every field phrased
"in English"renders English; a consistent subset of fields phrased"in user's language only"renders Russian.Steps to reproduce
cp .env.example .env, setANTHROPIC_API_KEY,docker compose up -d.admin@pentagi.com / admin, change password on first login.anthropic, default Language (English)."Perform web application reconnaissance on http://testphp.vulnweb.com/".generatorandmemoristagents.System configuration
2ec8ef3), fresh install from latest Docker imagesapi.anthropic.comand via Azure Foundry athttps://{resource}.services.ai.azure.com/anthropic/v1usingx-api-key)claude-sonnet-4-5(generator falls toclaude-opus-4-5perbackend/pkg/providers/anthropic/config.yml)Evidence
From
msglogson a freshly-created Flow where the task description was 100% English:Same agent, same Flow, same English input — mixed output.
From
msgchains.chainfor the generator (flow_id=N,type='generator'), the final tool call's arguments:The
messagefield (schema described as"in user's language only", args.go:44) is Russian. Thesubtasks[].descriptionfield (no locale instruction in its schema) is English.Suggested fix
Two options:
Option A — static English (minimal). Global replace in
backend/pkg/tools/args.go:"...to send to the user in user's language only"→"...to send to the user in English""...(in user's language only)"→"...(in English)"28 field descriptions, contained to one file. Half a day of work. Consistent with the English-only stance in #216.
Option B — runtime locale substitution. Move tool schema construction from the package-level
var registryDefinitionsto a builder function invoked per-Flow atNewFlowToolsExecutortime inbackend/pkg/tools/tools.go, passing the Flow'sLanguageand substituting it into the description strings. Preserves the original intent of the code if multi-language support is ever revisited, at the cost of ~1 day's refactor.Option A is sufficient given #216's stated policy.
Verification