docs/en/guides/10-prompt-guide.md
This document introduces OpenViking's current prompt template system, with a focus on:
This document only covers templates under openviking/prompts/templates/ plus a small set of configuration items related to template loading.
OpenViking's current prompts fall into two main groups:
openviking/prompts/templates/<category>/*.yamlopenviking/prompts/templates/memory/*.yamlFrom a usage perspective, these templates mainly serve the following processing stages:
| Category | Representative template | Main purpose | Effective stage | External capability affected |
|---|---|---|---|---|
vision | vision.image_understanding | Image, page, and table understanding | Resource parsing and scanned-document understanding | Image parsing, PDF page understanding, table extraction results |
parsing | parsing.context_generation | Document structure splitting and semantic node generation | Resource ingestion and parsing | Document chapter structure, node summaries, image summaries |
semantic | semantic.document_summary | File-level and directory-level summaries | Semantic indexing | File summaries, directory overviews, downstream retrieval quality |
retrieval | retrieval.intent_analysis | Retrieval intent analysis and query planning | Pre-retrieval analysis | Search query planning and context recall direction |
compression | compression.memory_extraction | Memory extraction, merging, compression, and summarization | Session commit / memory pipeline | Long-term memory extraction, session compression, memory merge results |
memory | profile | Memory type definitions | Memory persistence and updates | The organization and final content of different memory types |
processing | processing.tool_chain_analysis | Extracting experience from interactions or resource background | Post-processing and experience distillation | Strategy extraction, tool-chain experience, interaction learning results |
indexing | indexing.relevance_scoring | Candidate relevance evaluation | Retrieval and indexing support | Relevance scoring quality |
skill | skill.overview_generation | Skill information distillation | Skill resource processing | Skill retrieval summaries |
test | test.skill_test_generation | Automatic test case generation | Test and validation support | Skill test case generation |
A regular prompt template usually contains the following fields:
metadata:
id: "semantic.document_summary"
name: "Document Summary"
description: "Generate summary for documentation files"
version: "1.0.0"
language: "en"
category: "semantic"
variables:
- name: "file_name"
type: "string"
description: "Input file name"
required: true
template: |
...
output_schema:
...
llm_config:
...
Field meanings:
metadata
id usually corresponds to the file path, for example semantic.document_summaryvariables
name, type, description, default, required, and max_lengthtemplate
output_schema
llm_config
When writing a regular prompt, follow these guidelines:
metadata.id consistent with the template category and purposetemplate match the definitions in variablesmax_length or upstream truncationmemory/*.yaml files are not regular prompt text templates. They define memory types. The example below is only a schematic structure showing common fields. Whether a built-in template includes content_template, or whether its directory uses a subdirectory, depends on the specific memory type.
memory_type: "profile"
description: "User profile memory"
fields:
- name: "content"
type: "string"
description: "Profile content"
merge_op: "patch"
filename_template: "profile.md"
content_template: |
...
directory: "viking://user/{{ user_space }}/memories/..."
enabled: true
operation_mode: "upsert"
Field meanings:
memory_type
description
fields
filename_template
content_template
directory
enabled
operation_mode
upsertWhen writing a memory schema, focus on:
The sections below list all current templates by category. Each entry explains which processing stage it belongs to and which external capabilities it mainly affects.
When reading this section, a simple rule helps:
Purpose and Key inputsPurpose and Key fieldsThese prompts are mainly used for session compression, memory extraction, memory merging, and field compression. They are a core part of long-term memory quality.
compression.dedup_decision
candidate_content, candidate_abstract, candidate_overview, existing_memoriescompression.field_compress
field_name, content, max_lengthcompression.memory_extraction
summary, recent_messages, user, feedback, output_languagecompression.memory_merge
existing_content, new_content, category, output_languagecompression.memory_merge_bundle
abstract, overview, and content in one callexisting_abstract, existing_overview, existing_content, new_abstract, new_overview, new_content, category, output_languagecompression.structured_summary
latest_archive_overview, messagesThis category is mainly used to support retrieval or indexing workflows with relevance judgments.
indexing.relevance_scoring
query, candidateThese YAML files define the structure of different memory types. They are not single-inference prompts. Together, they determine how user memories and agent memories are stored, updated, and used by later retrieval.
cases
case_name, problem, solution, contententities
category, name, contentevents
event_name, goal, summary, rangesidentity
name, creature, vibe, emoji, avatarpatterns
pattern_name, pattern_type, contentpreferences
user, topic, contentprofile
contentskills
skill_name, total_executions, success_count, fail_count, best_for, recommended_flowsoul
core_truths, boundaries, vibe, continuitytools
tool_name, static_desc, call_count, success_time, when_to_use, optimal_paramsThese prompts are mainly used to convert raw resource content into structured nodes, chapters, summaries, or image overviews that are easier to retrieve and understand.
parsing.chapter_analysis
start_page, end_page, total_pages, contentparsing.context_generation
title, content, children_info, instruction, context_type, is_leafparsing.image_summary
contextparsing.semantic_grouping
items, threshold, modeThese prompts are mainly used to distill strategies or experience from interaction records, tool chains, and resource background. They are used for post-processing and knowledge accumulation rather than direct one-turn user answering.
processing.interaction_learning
interactions_summary, effective_resources, successful_skillsprocessing.strategy_extraction
reason, instruction, abstractprocessing.tool_chain_analysis
tool_callsThese prompts are mainly used to understand user intent before retrieval and decide the query plan and context type.
retrieval.intent_analysis
compression_summary, recent_messages, current_message, context_type, target_abstractThese prompts are mainly used to generate file-level and directory-level summaries and are an important part of semantic indexing.
semantic.code_ast_summary
file_name, skeleton, output_languagesemantic.code_summary
file_name, content, output_languagesemantic.document_summary
file_name, content, output_languagesemantic.file_summary
file_name, content, output_languagesemantic.overview_generation
dir_name, file_summaries, children_abstracts, output_languageThese prompts are mainly used to compress Skill content into summaries suitable for retrieval and reuse.
skill.overview_generation
skill_name, skill_description, skill_contentThese prompts are mainly used to help generate test cases.
test.skill_test_generation
skills_infoThese prompts are mainly used for image, page, table, and multimodal document analysis, and directly affect image parsing and scanned-document understanding.
vision.batch_filtering
document_title, image_count, images_infovision.image_filtering
document_title, contextvision.image_understanding
abstract, overview, and detail_textinstruction, contextvision.page_understanding
instruction, page_numvision.page_understanding_batch
page_count, instructionvision.table_understanding
instruction, contextvision.unified_analysis
title, instruction, reason, content_preview, image_count, images_section, table_count, tables_sectionOpenViking supports two main customization patterns:
Before going into the specific methods, you can use the following table to judge change risk:
| Change type | Risk level | Notes |
|---|---|---|
| Changing prompt wording, adding examples, adjusting tone | Low | Usually only changes model behavior style and does not change the caller contract |
| Changing output style, extraction preference, or summary granularity | Medium | Changes result distribution and should be revalidated against the target capability |
| Changing variable names, output structure, or memory field names | High | Easy to break compatibility with callers or parsing logic |
Changing directory, filename_template, or merge_op | Very high | Directly changes memory storage location, organization, and update behavior |
Applicable when:
Available configuration:
prompts.templates_dirOPENVIKING_PROMPT_TEMPLATES_DIRLoad priority:
OPENVIKING_PROMPT_TEMPLATES_DIRprompts.templates_dir in ov.confopenviking/prompts/templates/In other words, regular prompt customization works by checking the custom directory first and falling back to the built-in template when the same relative path is not found.
Recommended approach:
Example directory:
custom-prompts/
├── compression/
│ └── memory_extraction.yaml
├── retrieval/
│ └── intent_analysis.yaml
└── semantic/
└── document_summary.yaml
Example configuration:
{
"prompts": {
"templates_dir": "/path/to/custom-prompts"
}
}
Or:
export OPENVIKING_PROMPT_TEMPLATES_DIR=/path/to/custom-prompts
Impact examples:
compression.memory_extraction
retrieval.intent_analysis
semantic.document_summary
Applicable when:
Available configuration:
memory.custom_templates_dirLoading behavior:
memory.custom_templates_dir is configured, schemas in that directory are loaded afterwardExample directory:
custom-memory/
├── project_decisions.yaml
└── user_preferences_ext.yaml
Example configuration:
{
"memory": {
"custom_templates_dir": "/path/to/custom-memory"
}
}
Recommendations when extending memory schemas:
memory/*.yaml filesdirectory and filename_template are easy to search and maintainImpact examples:
project_decisions
preferences
tools
The following changes are the most likely to break existing workflows:
directory, which changes retrieval scopefilename_template, which changes how historical files are organizedmerge_op, which changes how existing memories are updatedIf your goal is only to improve quality, these are usually the safer first moves:
A conservative approach is:
After modifying a prompt, validate it at two levels: whether the template was actually picked up, and whether the capability output changed as expected.
Checklist:
For a regular prompt, focus on:
For a memory schema, focus on:
The most effective validation is capability-focused:
vision template, re-parse images, tables, or scanned PDFs and check whether the results changedsemantic or parsing template, re-import documents or files and check whether summaries and structure changedretrieval template, rerun the relevant search and check whether query planning and recall behavior changedcompression template, re-trigger session commit or memory processing and check whether extraction and merge results changedmemory schema, inspect the final persisted memory files, directories, and field structureSymptoms and first things to check:
| Symptom | First thing to check |
|---|---|
| Results do not change at all after modification | The custom directory is not active, or the file path does not match |
| The model reports missing variables | Template variable names do not match what callers provide |
| Returned content format is broken | The prompt output format changed, but downstream parsing still expects the old structure |
| A new memory type never appears | memory.custom_templates_dir is not active, or the schema was not loaded correctly |
| Retrieval quality gets worse | The retrieval, semantic, or compression prompt was changed too aggressively |
Built-in prompt template directory:
openviking/prompts/templates/
It contains:
compression/: compression, extraction, and mergingindexing/: relevance evaluationmemory/: memory type definitionsparsing/: structure analysis and semantic node generationprocessing/: experience and strategy extractionretrieval/: retrieval intent analysissemantic/: file and directory summariesskill/: Skill summariestest/: test case generationvision/: image, page, and table understandingThe main configuration items related to prompt customization are:
| Configuration item | Purpose |
|---|---|
prompts.templates_dir | Override directory for regular prompt templates |
OPENVIKING_PROMPT_TEMPLATES_DIR | Environment variable for the override directory of regular prompt templates |
memory.custom_templates_dir | Directory for custom memory schemas |
If your goal is:
If you are not sure which layer to modify, ask yourself:
"Am I changing the model's instruction, or the structure of the final memory file?"
That question is usually enough to help decide whether you should modify a regular prompt or a memory schema.