一键导入
language-injection
LLM Agent 多语言注入规范。在修改 Agent 提示词、添加新的 Agent 端点、处理用户可见的后端消息(message_code)时使用。
用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
菜单
LLM Agent 多语言注入规范。在修改 Agent 提示词、添加新的 Agent 端点、处理用户可见的后端消息(message_code)时使用。
用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
基于 SOC 职业分类
统一错误处理系统。在添加 API 端点、修改错误处理、添加前端 API 调用、编写错误相关测试时使用。
Greeting-triggered self-check — recognise greetings, check Edition version against the upstream tag, scan AI-Memory announcements, and report inside the greeting reply
Coordinates generic project Agency CLI, MCP authorization, M365 consent boundaries, Azure tooling, and Microsoft internal plugin adoption. Use when setting up or auditing Agency profiles, MCP servers, WorkIQ/M365 access, or curated plugins for a project.
Guides on-need adoption of an Agency MCP or Microsoft Foundry capability from the starter's capability catalog. Use when a project asks 'can we use X', 'should we adopt X', or needs to pull a specific tool/profile/Foundry capability without loading the whole surface.
Coordinates Microsoft Fabric MCP access, agents, skills, and curated marketplace plugins for a Fabric-heavy project. Use when setting up or auditing Fabric profiles, notebook-generation plugins, semantic-model review, or Fabric data-security checks.
Coordinates on-need adoption of Microsoft Foundry capabilities (IQ family, Toolboxes, Tool Search, Routines, autopilot agents, Agent Optimizer, Memory, Claude, SDKs) for a project building on Foundry Agent Service. Use when evaluating or adopting a Foundry hosted-agent capability.
| name | language-injection |
| description | LLM Agent 多语言注入规范。在修改 Agent 提示词、添加新的 Agent 端点、处理用户可见的后端消息(message_code)时使用。 |
| lastReviewed | "2026-07-09T00:00:00.000Z" |
Authoritative developer guide: docs/dev-guides/6-i18n-language-injection.md.
Prerequisites: Read
docs/dev-guides/6-i18n-language-injection.mdbefore changing Agent prompts, Agent routes, backend user-visible messages, or frontend i18n strings. If your work introduces new language injection patterns or conventions, update this file and related dev-guides accordingly.
Frontend i18n.language → Accept-Language header → get_language_instruction()
│
build_language_instruction()
(agents/agent_language.py)
│
┌────────────┴────────────┐
▼ ▼
mode="full" mode="compact"
(text-heavy agents) (code-gen agents)
| Module | Role |
|---|---|
agents/agent_language.py | build_language_instruction(lang, mode) — generates prompt fragments; inject_language_instruction() — injects into system prompts; supports 20 languages; returns "" for English |
routes/agents.py → get_language_instruction() | Reads Accept-Language header, delegates to build_language_instruction |
routes/agents.py → _get_ui_lang() | Extracts primary language code from Accept-Language header |
src/app/utils.tsx → fetchWithIdentity() | Sets Accept-Language header on every API request from i18n.language |
src/app/utils.tsx → translateBackend() | Translates backend message_code / content_code using frontend i18n |
# In a Flask route handler:
lang_instruction = get_language_instruction(mode="compact")
lang_suffix = f"\n\n{lang_instruction}" if lang_instruction else ""
messages = [
{"role": "system", "content": "You are a helpful assistant." + lang_suffix},
{"role": "user", "content": user_input},
]
from data_formulator.agents.agent_language import inject_language_instruction
# Simple append (most agents)
system_prompt = inject_language_instruction(system_prompt, language_instruction)
# Insert before a marker (complex prompts)
system_prompt = inject_language_instruction(
system_prompt, language_instruction,
marker="**About the execution environment:**"
)
For fixed strings in Python that appear in the UI, do NOT translate in Python.
Return a message_code and let the frontend translate:
# In an Agent or route handler:
yield {
"type": "error",
"message": "Output DataFrame is empty (0 rows).", # English fallback
"message_code": "agent.emptyDataframe", # frontend i18n key
}
# With parameters:
result = {
"status": "error",
"content": f"Fields not found: {missing}",
"content_code": "agent.fieldsNotFound",
"content_params": {"missing": missing, "available": available},
}
Frontend consumption:
import { translateBackend } from "../app/utils";
const msg = translateBackend(
event.message,
event.message_code,
event.message_params,
);
Translation keys go in src/i18n/locales/{en,zh}/messages.json under messages.agent.*.
| Pattern | Why it's wrong |
|---|---|
os.environ.get("DF_DEFAULT_LANGUAGE") | Process-level — all users get same language; breaks multi-user |
| Global LLM client interceptor | Hidden behavior; can't distinguish full/compact mode; fragile string detection |
New MessageBuilder class | Duplicates agent_language.py; creates parallel conflicting abstractions |
Hardcoded "回答请使用中文" in prompts | Not configurable; skips the mode system; breaks for other languages |
Backend-side translation dict (agent_messages.py) | Forces adding every new language to Python; translations should all live in src/i18n/locales/ |
Hardcoded English UI strings in .tsx without t() | Not translatable; use useTranslation + t('key') |
LANGUAGE_DISPLAY_NAMES in agents/agent_language.py.LANGUAGE_EXTRA_RULES (e.g. simplified vs traditional Chinese).src/i18n/locales/<lang>/ — copy an existing locale folder as template.