RAG chatbot example

This walkthrough runs vector memory retrieval in a single-agent workflow. You configure hybrid dense and sparse retrieval, run a query, and confirm MemoryRetrieved events in the trace. The primary script is RAG chatbot walkthrough.

What this example demonstrates

ArcFlow vector memory attaches to an agent via MemoryConfig. Chunking, embedding model selection, and hybrid retrieval weights live in workflow configuration. The sample uses stub embeddings for local runs; production swaps to real embedding providers and Qdrant.

A domain-heavy variant lives at RAG chatbot walkthrough for support-ticket Q&A patterns.

Prerequisites

ItemRequired for stub pathRequired for full RAG
Python SDKYesYes
ARCFLOW_QDRANT_URLNoYes (e.g. http://localhost:6333)
Embedding provider envNo (uses stub/8)Yes per provider configuration
Docker QdrantNoRecommended via dev compose
Tutorial trackTrack CSame

Step 1: Review memory configuration

From RAG chatbot walkthrough:

python
from arcflow import Agent, MemoryChunkingConfig, MemoryConfig, MemoryRetrievalConfig, MemoryScope, MemoryType, Workflow

memory = MemoryConfig(
 MemoryType.VECTOR,
 MemoryScope.AGENT,
 namespace="doc_qa",
 embedding="stub/8",
 retrieval=MemoryRetrievalConfig(
 mode="hybrid",
 dense_weight=0.7,
 sparse_weight=0.3,
 rerank="local",
 top_k=3,
 ),
 chunking=MemoryChunkingConfig(chunk_size=256, overlap=32),
)
agent = Agent(
 name="researcher",
 role="researcher",
 instructions="Answer using retrieved context.",
 memory=memory,
)
workflow = Workflow(name="document-qa", agents=[agent])

Step 2: Run with stub embeddings

bash
python examples/rag/document_qa.py

Stub mode exercises the workflow and trace path without Qdrant. Output includes a reminder to ingest documents when Qdrant is configured.

Step 3: Run with Qdrant (optional full path)

Start Qdrant (dev stack or standalone), then export:

bash
export ARCFLOW_QDRANT_URL=http://localhost:6333
# export embedding provider vars per your chosen model
python examples/rag/document_qa.py

Ingest the sample document in the script (SAMPLE_DOC) through vector ingest APIs or dashboard knowledge upload before expecting grounded answers. See vector RAG pipeline and knowledge ingestion.

Step 4: Verify trace events

After run(), inspect events:

python
result = workflow.run("Summarize hybrid retrieval in ArcFlow.")
kinds = {e.get("event_kind") for e in result.trace_events}
print(sorted(kinds))
if "MemoryRetrieved" in kinds:
 print("MemoryRetrieved present")

With populated vector store and matching namespace, expect MemoryRetrieved with chunk counts and scores (metadata only, no chunk text in trace export).

Expected output

Stub run prints stub answer text plus:

(Ingest SAMPLE_DOC via vector APIs when Qdrant is configured.)

Full RAG run prints an answer grounded on ingested content. Pass criteria: non-empty result.output, status == "completed", and MemoryRetrieved when the store contains matching namespace data.

Trace events you should see

Event kindWhen
WorkflowStartedRun begins
MemoryRetrievedVector query returns chunks (when store populated)
StepCompletedAgent step finishes
WorkflowCompletedSuccess

Optional: MemoryIngested during separate ingest operations, not during query-only runs.

Troubleshooting

SymptomLikely causeFix
No MemoryRetrieved eventsEmpty namespace or stub-only run without ingestIngest documents into doc_qa namespace or accept stub-only lifecycle events
Qdrant connection errorsWrong URL or service downVerify ARCFLOW_QDRANT_URL and container health
Generic answers despite ingestNamespace mismatchAlign MemoryConfig.namespace with ingest key
WorkflowConfigurationError on memoryInvalid retrieval weightsEnsure dense and sparse weights sum reasonably; see guide
ResourceLink
Tutorial trackTrack C
Static landing-page RAGstatic-chat-widget.md
Hybrid retrieval guidehybrid retrieval and reranking