oclaw/runtime/english_output_guard.py
oliver 1366459ee0 feat(ops): enforce English-only replies and localize netx protocol labels
Append english_output_guard when lang=en, strengthen ops/generalist EN role prompts,
pass NETX_TOOL_LANG into netx tools, and map Chinese protocol buckets to English.

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-05-19 23:35:46 +08:00

18 lines
947 B
Python

from __future__ import annotations
ENGLISH_ONLY_OUTPUT_GUARD = """
## English-only output (mandatory)
- Session language is **English**. All user-visible text (titles, tables, bullets, summaries) must be **English only**.
- **Forbidden**: any Chinese / Japanese / Korean characters (CJK) in the reply. Do not paste Chinese from tools, skills, or prior messages.
- Tool and UME alarm fields may be Chinese in the source; **translate or paraphrase into English** before presenting. Keep ASCII identifiers (severity, IP, alarm key, host_name) as-is.
- If a vendor term cannot be translated confidently, use a short English description in brackets, e.g. `[link down alarm]` — still **no CJK**.
""".strip()
def english_output_guard_for_lang(lang: str) -> str:
if str(lang or "").strip().lower().startswith("en"):
return ENGLISH_ONLY_OUTPUT_GUARD
return ""
__all__ = ["ENGLISH_ONLY_OUTPUT_GUARD", "english_output_guard_for_lang"]