language-injection-conventions

A set of rules for choosing a user's language in prompts sent to a language model and in fixed messages shown by a Python application. It defines where language instructions belong and how new languages are added.

In plain words
What is it for?
Use it when building multilingual AI agents, code-generation endpoints, API routes, or Python-generated UI messages.
Why use it?
It prevents inconsistent translations, duplicate instructions, and accidental language changes in internal calls that users never see.

Cursor rule for Cursor

Install

Getting it into your agent

One page per mod, every tool's command on it. A separate URL per tool would split the same page into five that compete with each other.

agentmods
npx agentmods add rules/microsoft/data-formulator/language-injection-conventions
Clone the repo
git clone --depth 1 https://github.com/microsoft/data-formulator

Made for: Cursor.

Per session 0 Nothing until a file matches its globs; then the whole rule loads.
When invoked 537 The whole file, excluding the scripts and references it only reads on demand.
Security scan A 0 findings. Scan, not verified.
Origin original No closer match found in the catalogue.
Token cost

What it costs to keep this loaded

Counted locally with the o200k_base tokenizer, which is exact for GPT models; Claude uses its own tokenizer and its counts differ. Treat this as one consistent yardstick across the catalogue rather than a bill. Prices are per million input tokens.

ModelPer sessionOnce invoked
Fable 5 $0.00000 $0.00537
Opus 5 $0.00000 $0.00269
Sonnet 5 $0.00000 $0.00107
Haiku 4.5 $0.00000 $0.00054

Measured 2d ago against content hash 11e79d25ce18, method: parsed. Prices are Anthropic first-party input rates as of 2026-08-30, from the pricing page.

Security

Grade A, and why

language-injection-conventions scanned grade A with 0 findings against 26 rules in 11 categories — prompt injection, anti-refusal, data exfiltration, privilege escalation, supply chain, agent snooping, system-prompt leakage, SSRF and excessive agency — measured 2d ago.

A static scan of the body, not an audit. Every finding is printed with the line that produced it so you can judge whether it matters here. A mod is markdown that instructs an agent; that is exactly why what it instructs is worth reading.

Nothing flagged

None of the 26 patterns this scan looks for appear in this file: no shell pipes, no recursive deletes, no credential paths, no hidden text, no instruction-override or anti-refusal phrasing, no agent-config snooping. That is not a guarantee, it is the absence of the things that are checkable.

.cursor/rules/language-injection-conventions.mdc · 44 lines

How it starts

The opening of the file, as written. The whole thing — 44 lines — stays where its author put it; the contents beside it link to each section on GitHub.

Language Injection Conventions

Language flows per-request: Frontend i18n → Accept-Language header → get_language_instruction() → system prompt.

LLM Prompt Language Injection

  1. User-facing LLM output MUST inject language via get_language_instruction(mode=...) in the route handler.
  2. Mode selection: "full" for text-heavy agents, "compact" for code-generation agents and short-text endpoints.
  3. Inject into system prompt only — use inject_language_instruction() from agent_language.py. Never inject into user messages.
  4. Do NOT inject for non-user-facing calls (health checks, internal tool calls).
  5. Do NOT duplicate — if upstream messages already contain language instruction, skip.
  6. Do NOT use env vars, global interceptors, or hardcoded language strings (e.g. "回答请使用中文") — route handlers should use get_language_instruction(mode=...).
  7. New language? Add to LANGUAGE_DISPLAY_NAMES in agents/agent_language.py and add locale files in src/i18n/locales/<lang>/.

Python-Side User-Visible Messages (message_code pattern)

For fixed strings in Python that are shown in the UI (error messages, clarify options, completion summaries), do NOT translate in Python. Instead:

  1. Keep the English string as the default value.
  2. Add a message_code (or content_code, error_code, summary_code) field with a key like "agent.someKey".
  3. Optionally add message_params for interpolation.
  4. The frontend translates using translateBackend(fallback, code, params) from src/app/utils.tsx.
  5. Add the translation key to src/i18n/locales/{en,zh}/messages.json under the agent section.
# ✅ GOOD — backend returns code, frontend translates
yield {
    "type": "error",
    "message": "Output DataFrame is empty (0 rows).",
    "message_code": "agent.emptyDataframe",
}

# ❌ BAD — backend-side translation dict
yield {"message": translate_in_python("empty_df", lang)}

For detailed architecture and anti-pattern explanations, see docs/dev-guides/6-i18n-language-injection.md.

Read the full file on GitHub · 44 lines

Changes

What this file has done since we first saw it

Hashed on every crawl. A supply-chain change to an agent config is a question of when, not whether, so the history is kept rather than the latest state alone.

  1. 2d ago First seen · 44 lines · 0 tokens per session scan A 11e79d25ce18

Subscribe to this mod's changes

language-injection-conventions is a cursor rule published in the GitHub repository microsoft/data-formulator (17,048 stars, last pushed 3d ago), licensed MIT. It costs nothing until one of its globs matches a file; then it loads 537 tokens. A static security scan graded it A with 0 findings. No closer match exists in the catalogue, so it is treated as the original; first seen 2026-08-30.