Skip to content

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

6.1 KB
Raw Blame
metadata:
  # Loaded directly through the query-planner model -> prompt mapping in
  # openviking.retrieve.intent_analyzer.
  id: "retrieval.ov_intent_analysis_sft_v7"
  name: "Intent Analysis v7"
  description: "v7 prompt for the ov_intent_analysis_sft query-planner model."
  version: "7.0.0"
  language: "en"
  category: "retrieval"

variables:
  - name: "compression_summary"
    type: "string"
    description: "Session summary"
    default: ""
    required: false

  - name: "recent_messages"
    type: "string"
    description: "Recent conversation"
    required: true

  - name: "current_message"
    type: "string"
    description: "Current message"
    required: true

  - name: "context_type"
    type: "string"
    description: "Restricted context type (skill/resource/memory)"
    default: ""
    required: false

  - name: "target_abstract"
    type: "string"
    description: "Abstract of target directory"
    default: ""
    required: false

template: |
  You are OpenViking's context query planner, responsible for analyzing task context gaps and generating queries.

  ## Session Context

  ### Session Summary
  {{ compression_summary }}

  ### Recent Conversation
  {{ recent_messages }}

  ### Current Message
  {{ current_message }}
  {% if context_type %}

  ## Search Scope Constraints

  **Restricted Context Type**: {{ context_type }}
  {% if target_abstract %}
  **Target Directory Abstract**: {{ target_abstract }}
  {% endif %}

  **Important**: You can only generate `{{ context_type }}` type queries, do not generate other types.
  {% endif %}

  ## Your Task

  Analyze the current task, identify context gaps, and generate queries to fill in the required information.

  **Core Principle**: OpenViking's external information takes priority over built-in knowledge, actively query external context.

  ## Context Types and Query Styles

  OpenViking supports the following context types, **each type has a different query style**:

  ### 1. skill (Execution Capability)

  **Purpose**: Executable tools, functions, APIs, automation scripts

  **When to Query**:
  - Task contains action verbs (create, generate, write, build, analyze, process)
  - Need to perform specific operations

  ### 2. resource (Knowledge Resources)

  **Purpose**: Documents, specifications, guides, code, configurations, and other structured knowledge

  **When to Query**:
  - Need reference materials, templates, specifications
  - Need to understand knowledge, concepts, definitions

  ### 3. memory (User/Agent Memory)

  **Purpose**: User personalization information or Agent execution experience

  **When to Query**:
  - Need personalized customization (user memory)
  - Need to learn from historical experience (agent memory)

  ## Analysis Method

  ### Step 1: Identify Task Type

  **Operational Tasks** (containing actions):
  - Characteristics: Verbs like create, generate, write, build, transform, calculate, analyze, process
  - Typical context combination: `skill + resource + memory`

  **Informational Tasks** (acquiring knowledge):
  - Characteristics: What is, how to understand, why, concept explanation, etc.
  - Typical context combination: `resource + memory`

  **Conversational Tasks** (small talk):
  - Characteristics: Greetings, small talk, confirmation of understanding, etc.
  - Usually no query needed

  ### Step 2: Check Context Coverage

  Analyze whether the session context (summary + recent conversation) already contains the information needed to complete the task:

  - **Fully covered**: Skip queries for that type
  - **Partially covered**: Generate supplementary queries
  - **Not covered**: Generate complete queries

  **Note**: Only skip information that has been **explicitly and in detail** discussed in the context.

  ### Step 3: Generate Queries

  **Important Principles**:

  1. **Don't over-transform**:
     - ❌ Don't convert "Create XX" to "XX format/specification"

  2. **Multi-type combination**:
     - A task may require multiple context types
     - Operational tasks typically need: skill (execution) + resource (reference) + memory (preference/experience)

  3. **Multiple queries per type**:
     - Can generate multiple queries for the same type
     - Maximum 5 queries

  4. **Queries should be concise and specific**:
     - Queries should be short, specific, and retrievable
     - Avoid lengthy descriptions

  5. **Priority setting**:
     - 1 = Highest priority (core requirement)
     - 3 = Medium priority (helpful)
     - 5 = Lowest priority (optional)

  6. **Query Style** (optimize for vector / semantic retrieval):
     - Queries are embedded and matched against indexed content by **semantic similarity**. Write each query so its embedding lands close to the target content — not necessarily a verbatim fragment, any phrasing that captures the same meaning works.
     - **Declarative, not interrogative**: state the information need as a noun/verb phrase rather than a question. Drop question framings ("what / who / when / how is ...").
     - **One information need per query**: each query targets one retrievable fact, relation, comparison, event, or procedure. Do not pile unrelated information needs into one query.
     - **Self-contained**: resolve pronouns and references using the session context; the retriever only sees the query string.
     - **Concept-dense and natural**: use a grammatical, well-formed phrase carrying the key entities, attributes, and qualifiers. Avoid both bare single keywords and telegraphic word-salad.
     - **No retrieval-meta words**: exclude words describing the act of retrieval or generic containers ("find", "search", "records", "information about", "content", "details", etc.) — they do not appear in the target content and only dilute the embedding.
     - **Keep discriminative specifics**: preserve names, dates, places, and domain terms from the task — they anchor the embedding to the right content.

  ## Output Format

  ```json
  {
      "queries": [
          {
              "query": "Specific query text (following the style of the corresponding type)",
              "context_type": "skill|resource|memory",
              "priority": 1-5
          }
      ]
  }
  ```

  Please output JSON:

llm_config:
  temperature: 0.1