From RAG to Agentic: Building Autonomous AI Workflows with OpenClaw
RAG answers questions. Agents solve problems. The difference matters.
When we started building J4SGON's AI infrastructure, we followed the same path everyone does: chunk documents, embed them, stuff them into a vector database, and query at inference time. It worked, sort of. The system could find relevant text. It couldn't do anything with it. It couldn't check a CRM, update a ticket, write a blog post, run a pipeline, or coordinate with other agents. It was a search engine with a chat interface.
This is the story of how we moved from retrieval to agency, using OpenClaw, LiteLLM, and a stack of open-source tools running entirely on a single DGX Spark node in Valencia.
The RAG Ceiling
RAG (Retrieval-Augmented Generation) has a well-defined ceiling. It retrieves relevant context and generates a response. That's it. The output is text. If you need the system to take an action (send an email, update a database, trigger a workflow), you need something more.
We hit this ceiling fast. Our J4SGON Learning platform (a Docebo consulting system with 200+ API endpoints and a 260-file knowledge base) could answer questions about SSO configuration. It couldn't actually configure SSO. It could explain Docebo Connect recipes. It couldn't run one. The gap between "knowing about" and "doing" is where RAG stops and agents begin.
The progression looks like this:
| Stage | What It Does | What It Can't Do |
|---|---|---|
| RAG | Retrieve documents → generate answer | Take actions, maintain state, coordinate |
| Tool-Use | LLM calls functions (API, DB, shell) | Plan multi-step workflows, delegate |
| Agentic | Plan → decompose → execute → verify | Scale to multiple concurrent workflows |
| Multi-Agent | Specialized agents coordinate via orchestration | (this is where we are) |
Each stage requires more infrastructure: tool definitions, planning logic, state management, inter-agent communication, and observability. RAG needs a vector DB and an embedding model. Agents need all of that plus tool registries, memory layers, and an orchestration layer.
Enter OpenClaw
OpenClaw is an open-source agent orchestration framework that runs locally on Linux. It provides:
- Agent sessions: persistent, stateful conversations with tool access
- Cron scheduling: recurring agent tasks (monitoring, content generation, maintenance)
- Subagent spawning: parallel task execution with isolated context
- MCP integration: Model Context Protocol servers for tool extensibility
- Memory system: daily notes, long-term memory files, semantic search
- Multi-model support: route through LiteLLM for model flexibility
We run OpenClaw on our DGX Spark (ARM64, 128GB RAM, one GB10 GPU). It coordinates six specialized subagents that maintain our infrastructure daily:
- vorlux-maintainer: orchestration engine health, agent configuration, DAG workflows
- learning-maintainer: J4SGON Learning (the Docebo consulting system), KB content, RAG pipeline
- j4sgon-web-maintainer: corporate sites, API endpoints, PWA
- youtube-maintainer: video pipeline, TTS, subtitles, thumbnails
- infra-maintainer: Docker services, monitoring, backups, security
- content-maintainer: blog posts, LinkedIn content, brand consistency
Each subagent runs on a daily cron schedule, checks its assigned systems, reviews the roadmap for the next task, and implements it. They write code, edit files, run tests, and commit changes, autonomously.
The Architecture
Here's what the stack looks like in production:
┌─────────────────────────────────────────────┐
│ OpenClaw │
│ ┌──────────┐ ┌──────────┐ ┌──────────┐ │
│ │ Subagent │ │ Subagent │ │ Subagent │ │
│ │ #1 │ │ #2 │ │ #3 │ │
│ └────┬─────┘ └────┬─────┘ └────┬─────┘ │
│ │ │ │ │
│ ┌────▼──────────────▼──────────────▼────┐ │
│ │ LiteLLM Gateway (:4000) │ │
│ │ qwen3.6 · vllm-qwen2.5-7b · nomic │ │
│ └────────────────┬───────────────────────┘ │
│ │ │
│ ┌────────────────▼───────────────────────┐ │
│ │ Tool Layer │ │
│ │ Graphiti MCP · SearXNG · R2R │ │
│ │ Qdrant · Memobase · Langfuse │ │
│ └────────────────────────────────────────┘ │
└─────────────────────────────────────────────┘
│ │ │
┌────▼────┐ ┌─────▼────┐ ┌─────▼────┐
│ Files │ │ Shell │ │ HTTP │
│ Read/ │ │ exec │ │ APIs │
│ Write │ │ │ │ │
└─────────┘ └──────────┘ └──────────┘
The key design decisions:
LiteLLM as the single entry point. Every LLM call goes through http://localhost:4000/v1. This gives us model routing (strong model for reasoning, fast model for simple tasks), automatic fallback, spend tracking, rate limiting, and Prometheus metrics. We never call Ollama or vLLM directly.
Graphiti for knowledge graph memory. Vector search finds similar text. Graphiti tracks entities, relationships, and when those facts were true. When a subagent needs to know "what did we decide about the J4SGON Learning rename?", Graphiti returns the structured answer instead of document chunks that mention "Learning" and "rename."
SearXNG for private web search. Agents that need current information (trending topics, documentation, competitive analysis) use SearXNG at :8085. No API keys, no rate limits, no data leaving the network.
Langfuse for observability. Every LLM call is traced. We can see which model was used, how many tokens, what the prompt was, and how long it took. This is non-negotiable for agent systems: you need to know what your agents are doing.
From RAG to Tool-Use to Agent
The transition from RAG to agentic happens in three concrete steps:
Step 1: Give the Model Tools
RAG retrieves text. Tools let the model act. In OpenClaw, tools are file operations (read, write, edit), shell execution (exec), and HTTP calls (web_fetch). The model decides when to use them based on the task.
# Before (RAG only):
response = llm.chat(prompt + retrieved_context)
# After (tool-use):
tools = [read_file, write_file, exec_command, web_search, web_fetch]
response = llm.chat_with_tools(prompt, tools)
The model reads a file, checks the system state, writes a fix, and commits it. The output is the action itself, not text about what to do.
Step 2: Add Memory and Context
Agents need to remember what happened between sessions. We use a layered approach:
- Daily notes (
memory/YYYY-MM-DD.md): raw logs of what happened each day - Long-term memory (
MEMORY.md): curated decisions, lessons, preferences - Semantic search:
memory_searchacross all memory files - Graphiti knowledge graph: entity relationships, temporal facts
When the content-maintainer subagent wakes up, it reads its memory, checks the roadmap, reviews the content calendar, and knows exactly where it left off. No cold start.
Step 3: Orchestrate Multiple Agents
A single agent with tools is powerful. Multiple specialized agents that coordinate are transformative. Our six subagents each own a workstream. They don't interfere with each other's files. They share a common roadmap. They run on staggered cron schedules (06:00, 06:15, 06:30, 06:45, 07:00, 07:15) to avoid resource contention.
The orchestration is lightweight: no complex message passing or event buses. Each agent reads the shared roadmap, finds its next task, and does it. If one agent's work unblocks another, the roadmap reflects it on the next run.
What We Learned in Production
After three months of running autonomous agents in production, here's what actually matters:
Context window discipline. Agents that read too much context get confused. We cap session context, summarize aggressively, and use memory_search instead of loading full history. A clean 40k-token session outperforms a bloated 110k one.
Model routing matters. Not every task needs the strong model. The infra-maintainer checking container health uses the fast model (vllm-qwen2.5-7b). The content-maintainer writing a blog post uses the strong model (qwen3.6). LiteLLM makes this transparent: the agent just calls the gateway.
Observability is not optional. Without Langfuse traces, you have no idea why an agent made a decision. With them, you can replay the full chain: prompt → tool call → result → next prompt. Debugging agents without traces is like debugging code without logs.
Agents need guardrails. Our agents can read and write files freely, but external actions (emails, social posts, public changes) require explicit user approval. This is enforced at the tool level, not as a suggestion in the prompt.
Memory is the hardest problem. Vector search retrieves similar text. Knowledge graphs track relationships. Neither captures judgment, the meta-knowledge about when to apply what. Our MEMORY.md files are the closest approximation: curated notes that distill lessons learned over time. They require active maintenance.
The Stack, Fully Open Source
Every component in our agent system is open source and self-hosted:
| Layer | Tool | License |
|---|---|---|
| Agent orchestration | OpenClaw | MIT |
| Model routing | LiteLLM | MIT |
| Inference | vLLM, Ollama | Apache 2.0 |
| Knowledge graph | Graphiti | Apache 2.0 |
| User profiles | Memobase | MIT |
| Vector DB | Qdrant | Apache 2.0 |
| Web search | SearXNG | AGPL-3.0 |
| RAG | R2R | MIT |
| Observability | Langfuse | MIT |
| Monitoring | Grafana + Prometheus | AGPL-3.0 / Apache 2.0 |
| Models | Qwen, Llama | Open weights |
No cloud APIs. No per-token charges. No vendor lock-in. The entire stack runs on one ARM64 node with 128GB RAM and stays inside the DGX Spark's rated power envelope even at peak load (NVIDIA's published spec for the unit is 240 W).
What's Next
We're moving from single-agent autonomy to multi-agent coordination. The next step is enabling agents to delegate to each other: the content-maintainer asking the infra-maintainer to check whether a service is healthy before writing about it, or the youtube-maintainer asking the content-maintainer for a blog post summary to include in a video description.
This requires a shared task queue, inter-agent messaging, and tighter state synchronization. It's the difference between six agents working in parallel on independent tasks and six agents collaborating on shared goals.
The progression from RAG to agentic isn't about better models. It's about better infrastructure around the models. The models are already capable enough. The bottleneck is tooling, memory, and orchestration. The boring engineering work that nobody tweets about.
That's fine. We're not here to tweet about it. We're here to run it.
If you run this for a company and need it hardened, that's VORLUX AI: https://vorluxai.com/