Description
When a user communicates with opencode in a non-English language (e.g., Chinese), the main agent correctly infers the language and responds in the same language. However, when the user invokes a sub-agent (e.g., @general or any task agent) via the task tool, the sub-agent's processing messages, intermediate outputs, and results are all displayed in English. Users who do not understand English are unable to follow what the sub-agent is doing.
This happens because:
- The system prompt passed to sub-agents is hardcoded in English
- The
task.ts tool has hardcoded English strings for background task status messages
- There is no language detection mechanism
- There is no mechanism to pass the user's language preference from the parent session to sub-agent sessions
- There is no i18n/localization infrastructure
Code location
-
packages/opencode/src/tool/task.ts — Background/foreground task messages hardcoded in English:
BACKGROUND_DESCRIPTION (line ~28): "Background mode: background=true launches the subagent asynchronously..."
BACKGROUND_STARTED (line ~34): "The task is working in the background..."
BACKGROUND_UPDATED (line ~41): "Additional context sent to the running background task..."
renderOutput() (line ~78): Generates <task> XML with English summaries
inject() (line ~136): "Background task completed: ..." / "Background task failed: ..."
backgroundResult() (line ~200): "Background task started"
-
packages/opencode/src/session/system.ts — Environment prompts hardcoded in English:
- "You are powered by the model named..."
- "Working directory: ..."
- "Workspace root folder: ..."
-
packages/opencode/src/session/prompt/default.txt — Default system prompt entirely in English
-
packages/opencode/src/session/prompt/anthropic.txt — Anthropic system prompt entirely in English
-
packages/opencode/src/session/prompt.ts — Prompt generation logic without any language awareness
Steps to reproduce
- Start a conversation with opencode in Chinese (or any non-English language)
- Confirm the main agent responds in Chinese
- Type
@general do something in this project or invoke any sub-agent
- Observe that the sub-agent's processing messages, status updates, and results are displayed in English
- A non-English-speaking user cannot understand what the sub-agent is doing
Expected behavior
Sub-agents should respect the user's language preference and respond in the same language as the parent conversation. Options:
- Detect the user's language from the conversation history and pass it to sub-agents
- Add a configurable language/locale setting
- Include a language directive in the system prompt passed to sub-agents (e.g., "The user is communicating in Chinese. Please respond in Chinese.")
- Implement i18n for tool output strings
Environment
- opencode version: latest (observed on v2.x)
- OS: cross-platform (reproducible on Windows, macOS, Linux)
- Sub-agent types affected: all (
@general, @plan, @tool, etc.)
Description
When a user communicates with opencode in a non-English language (e.g., Chinese), the main agent correctly infers the language and responds in the same language. However, when the user invokes a sub-agent (e.g.,
@generalor any task agent) via thetasktool, the sub-agent's processing messages, intermediate outputs, and results are all displayed in English. Users who do not understand English are unable to follow what the sub-agent is doing.This happens because:
task.tstool has hardcoded English strings for background task status messagesCode location
packages/opencode/src/tool/task.ts— Background/foreground task messages hardcoded in English:BACKGROUND_DESCRIPTION(line ~28): "Background mode: background=true launches the subagent asynchronously..."BACKGROUND_STARTED(line ~34): "The task is working in the background..."BACKGROUND_UPDATED(line ~41): "Additional context sent to the running background task..."renderOutput()(line ~78): Generates<task>XML with English summariesinject()(line ~136): "Background task completed: ..." / "Background task failed: ..."backgroundResult()(line ~200): "Background task started"packages/opencode/src/session/system.ts— Environment prompts hardcoded in English:packages/opencode/src/session/prompt/default.txt— Default system prompt entirely in Englishpackages/opencode/src/session/prompt/anthropic.txt— Anthropic system prompt entirely in Englishpackages/opencode/src/session/prompt.ts— Prompt generation logic without any language awarenessSteps to reproduce
@general do something in this projector invoke any sub-agentExpected behavior
Sub-agents should respect the user's language preference and respond in the same language as the parent conversation. Options:
Environment
@general,@plan,@tool, etc.)