Skip to content

Self-evolving Context Database for AI Agents. Unify Agent Memory, Knowledge RAG and Skills.

fix(prompt): prevent mixed-language directory overviews (#3589)

fujiajie66644a50180bf20
diff --git a/openviking/prompts/templates/semantic/overview_generation.yaml b/openviking/prompts/templates/semantic/overview_generation.yaml
index 19fa4206e..266f00930 100644
--- a/openviking/prompts/templates/semantic/overview_generation.yaml
+++ b/openviking/prompts/templates/semantic/overview_generation.yaml
@@ -29,6 +29,8 @@ variables:
template: |
Output Language: {{ output_language }}
+ Write the entire overview consistently in {{ output_language }}; do not mix languages in headings, paragraphs, or list items.
+ Translate or rewrite all source summaries into {{ output_language }}; do not copy source text in another language.
Generate an overview document based on the following directory content:
@@ -60,13 +62,13 @@ template: |
- Include core keywords for easy searching
- Who it's suitable for
- 3. **Quick Navigation** (H2): Decision Tree style
+ 3. **{{ "快速导航" if output_language == "zh-CN" else "Quick Navigation" }}** (H2): Decision Tree style
- Guide with "What do you want to learn?" or "What do you want to do?"
- Use → arrow to point to specific files or directories
- **Use file number references**: such as [1], [2], [3]
- Concise keyword descriptions
- 4. **Detailed Description** (H2): One H3 subsection for each file/subdirectory
+ 4. **{{ "详细说明" if output_language == "zh-CN" else "Detailed Description" }}** (H2): One H3 subsection for each file/subdirectory
- Use the file summaries or subdirectory summaries provided above as description content
Total length: 400-800 words
diff --git a/tests/storage/test_semantic_processor_language.py b/tests/storage/test_semantic_processor_language.py
index 3dda0ef2d..0ec37af99 100644
--- a/tests/storage/test_semantic_processor_language.py
+++ b/tests/storage/test_semantic_processor_language.py
@@ -237,6 +237,22 @@ class TestOverviewGenerationFlow:
in prompt
)
+ def test_chinese_overview_uses_localized_headings(self):
+ prompt = render_prompt(
+ "semantic.overview_generation",
+ {
+ "dir_name": "测试",
+ "file_summaries": "[1] test.md: 测试文档",
+ "children_abstracts": "",
+ "output_language": "zh-CN",
+ },
+ )
+
+ assert "**快速导航** (H2)" in prompt
+ assert "**详细说明** (H2)" in prompt
+ assert "**Quick Navigation** (H2)" not in prompt
+ assert "**Detailed Description** (H2)" not in prompt
+
class LanguageAwareMockVLM:
"""语言感知的 MockVLM,根据 prompt 中的 Output Language 返回对应语言的响应。"""