Skip to content

[bug] Sub-agents always output in English regardless of user's language #33084

@LifetimeVip

Description

@LifetimeVip

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:

  1. The system prompt passed to sub-agents is hardcoded in English
  2. The task.ts tool has hardcoded English strings for background task status messages
  3. There is no language detection mechanism
  4. There is no mechanism to pass the user's language preference from the parent session to sub-agent sessions
  5. There is no i18n/localization infrastructure

Code location

  1. 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"
  2. packages/opencode/src/session/system.ts — Environment prompts hardcoded in English:

    • "You are powered by the model named..."
    • "Working directory: ..."
    • "Workspace root folder: ..."
  3. packages/opencode/src/session/prompt/default.txt — Default system prompt entirely in English

  4. packages/opencode/src/session/prompt/anthropic.txt — Anthropic system prompt entirely in English

  5. packages/opencode/src/session/prompt.ts — Prompt generation logic without any language awareness

Steps to reproduce

  1. Start a conversation with opencode in Chinese (or any non-English language)
  2. Confirm the main agent responds in Chinese
  3. Type @general do something in this project or invoke any sub-agent
  4. Observe that the sub-agent's processing messages, status updates, and results are displayed in English
  5. 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.)

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type
No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions