Skip to content

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

feat(agent-evolution): add trajectory task query (#3856)

agentbca5a673883b
diff --git a/openviking/prompts/templates/memory/trajectories.yaml b/openviking/prompts/templates/memory/trajectories.yaml
index 108073246..bc910da91 100644
--- a/openviking/prompts/templates/memory/trajectories.yaml
+++ b/openviking/prompts/templates/memory/trajectories.yaml
@@ -35,6 +35,20 @@ fields:
Use exactly one of: success, failure, partial, unfinished, unknown.
merge_op: immutable
+ - name: task_query
+ type: string
+ description: |
+ Write a self-contained user task that can be copied and rerun to reproduce the intent represented by this trajectory.
+
+ Rules:
+ - Reconstruct the complete task from the relevant conversation context instead of copying unrelated turns or the whole session.
+ - Preserve the user's objective, target, constraints, requested output, and acceptance criteria that are necessary to execute the task independently.
+ - Preserve non-secret concrete inputs such as the requested topic, time range, and target object when they are required to rerun the task. Never include credentials, tokens, or authentication secrets.
+ - Remove conversational references such as "above", "continue", or "why did it stop" by resolving them into explicit task context.
+ - Do not include the assistant's solution, tool results, execution outcome, trajectory analysis, or any experience-memory content.
+ - Write in the user's voice and in {{ language }}. Use concise sentences, but include all information required to rerun the task.
+ merge_op: immutable
+
- name: retrieval_anchor
type: string
description: |
diff --git a/tests/unit/session/memory/test_embedding_template.py b/tests/unit/session/memory/test_embedding_template.py
index 9c246d33e..d1dffea5a 100644
--- a/tests/unit/session/memory/test_embedding_template.py
+++ b/tests/unit/session/memory/test_embedding_template.py
@@ -11,6 +11,7 @@ from openviking.session.memory.dataclass import MemoryField, MemoryFile
from openviking.session.memory.experience_lineage import experience_source_tag
from openviking.session.memory.memory_type_registry import MemoryTypeRegistry
from openviking.session.memory.memory_updater import MemoryUpdater, MemoryUpdateResult
+from openviking.session.memory.merge_op import MergeOp
from openviking.session.memory.merge_op.base import FieldType
from openviking.session.memory.utils.memory_file_utils import MemoryFileUtils
from openviking.storage.queuefs.embedding_msg_converter import EmbeddingMsgConverter
@@ -51,6 +52,13 @@ class TestEmbeddingTemplateYamlParsing:
schema = self.registry.get("trajectories")
assert schema.embedding_template == "{{ trajectory_name }}\n\n{{ retrieval_anchor }}"
+ def test_trajectories_exposes_immutable_task_query(self):
+ schema = self.registry.get("trajectories")
+ fields = {field.name: field for field in schema.fields}
+
+ assert "task_query" in fields
+ assert fields["task_query"].merge_op == MergeOp.IMMUTABLE
+
class TestContentTemplateRendering:
def test_content_template_can_access_content_extra_fields_and_extract_context(self):