Skip to content

Example: RAG Agent

Document ID: EX-002
File Path: docs/16-examples/rag-agent.md
Version: 1.0.0
Status: Draft
Owner: Developer Relations Team
Last Updated: 2026-06-27


Build a retrieval-augmented agent that answers from a knowledge base stored in the Memory Engine — grounding answers in your data.


memory/knowledge.yaml:

kind: MemoryNamespace
name: product-kb
project: docs-bot
default_scope: project
embedding_model: text-embedding-3-large
retention: { semantic: permanent }
Terminal window
wovyr memory namespaces create -f memory/knowledge.yaml

The embedding model is fixed per namespace.


Terminal window
wovyr memory put -f - <<'YAML'
scope: project
project: docs-bot
type: semantic
title: Refund policy
content: Refunds are processed within 14 days of purchase.
tags: [policy, refunds]
YAML

Long documents are chunked and embedded automatically.


agents/docs-bot.yaml:

kind: Agent
metadata: { name: docs-bot }
spec:
model_selector: { capability: chat, class: balanced }
instructions: |
Answer using ONLY the retrieved knowledge. Cite the source title.
If the answer isn't in memory, say you don't know.
memory:
enabled: true
scopes: [project]
retrieval: { strategy: hybrid, token_budget: 1500 }

Enabling memory makes the runtime retrieve and compress relevant context before the model call.


Terminal window
wovyr agents run --local -f agents/docs-bot.yaml \
--input '{"message":"How long do refunds take?"}' --stream

Expected: a grounded answer citing “Refund policy”, with the retrieved memory and its score breakdown visible in the trace.


question → embed → hybrid retrieve (vector+keyword) → rank → compress
→ prompt (instructions + retrieved memory + question) → model → answer

Retrieval and ranking happen in the Memory Engine; the agent runtime assembles the prompt via the Context Manager.


  • Ask something not in the KB → the agent should say it doesn’t know.
  • Inspect the trace to confirm which memories were retrieved and used (Memory Explorer).



VersionDateDescription
1.0.02026-06-27Initial RAG Agent example