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
1. Goal
Section titled “1. Goal”Build a retrieval-augmented agent that answers from a knowledge base stored in the Memory Engine — grounding answers in your data.
2. Create a Knowledge Namespace
Section titled “2. Create a Knowledge Namespace”memory/knowledge.yaml:
kind: MemoryNamespacename: product-kbproject: docs-botdefault_scope: projectembedding_model: text-embedding-3-largeretention: { semantic: permanent }wovyr memory namespaces create -f memory/knowledge.yamlThe embedding model is fixed per namespace.
3. Ingest Knowledge
Section titled “3. Ingest Knowledge”wovyr memory put -f - <<'YAML'scope: projectproject: docs-bottype: semantictitle: Refund policycontent: Refunds are processed within 14 days of purchase.tags: [policy, refunds]YAMLLong documents are chunked and embedded automatically.
4. Define the Agent
Section titled “4. Define the Agent”agents/docs-bot.yaml:
kind: Agentmetadata: { 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.
5. Run
Section titled “5. Run”wovyr agents run --local -f agents/docs-bot.yaml \ --input '{"message":"How long do refunds take?"}' --streamExpected: a grounded answer citing “Refund policy”, with the retrieved memory and its score breakdown visible in the trace.
6. How It Works
Section titled “6. How It Works”question → embed → hybrid retrieve (vector+keyword) → rank → compress → prompt (instructions + retrieved memory + question) → model → answerRetrieval and ranking happen in the Memory Engine; the agent runtime assembles the prompt via the Context Manager.
7. Verify Grounding
Section titled “7. Verify Grounding”- 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).
8. Next Steps
Section titled “8. Next Steps”- Add tools to act on answers → Code Agent
- Wrap in an approval flow → Customer Support
9. Related Documents
Section titled “9. Related Documents”10. Revision History
Section titled “10. Revision History”| Version | Date | Description |
|---|---|---|
| 1.0.0 | 2026-06-27 | Initial RAG Agent example |