03 Vector memory setup
Before you start
Complete 01 Memory types overview. You should understand that MemoryType.VECTOR requires a namespace and usually an embedding string. For ingest and query together, read 02 Ingest documents in the RAG track after this page.
Concept
Vector memory stores embedded document chunks in Qdrant. At run time the runtime queries the collection named by your namespace, retrieves top chunks, and injects them into the agent prompt. Configuration lives on the agent:
Environment variables
| Variable | Purpose |
|---|---|
ARCFLOW_QDRANT_URL | Qdrant HTTP endpoint (e.g. http://localhost:6333) |
ARCFLOW_EMBEDDING_PROVIDER | Embedding backend for non-stub models |
ARCFLOW_QDRANT_HYBRID | Set to true when using hybrid retrieval mode |
OPENAI_API_KEY | Required when embedding string uses OpenAI models |
Stub embedding (stub/8, stub/384, etc.) lets you exercise config and workflow wiring without a real embedding provider. Qdrant is still required if you want chunks persisted and MemoryRetrieved events on query runs.
Namespace rules
The namespace on MemoryConfig must match the first argument passed to VectorStore.ingest(namespace, key, text). A mismatch produces empty retrieval and generic stub answers even when documents exist in another collection.
Pick one namespace per knowledge base or tutorial (e.g. doc_qa, track_c_kb, platform-docs-memory-guide) and use it consistently for ingest and agent config.
Example
This mirrors RAG chatbot walkthrough on the current branch. On the examples restructure branch the full ingest-plus-query flow is in examples/rag/memory_guide_qa.py.
Save as vector_memory_setup.py:
Start Qdrant (dev compose or standalone container), then export the URL before ingest and query:
Ingest sample text into the same namespace before expecting grounded answers:
Run ingest once, then run the workflow query again.
Verify
| Check | Expected |
|---|---|
MemoryConfig without namespace | MemoryConfigurationError |
| Workflow run with stub embedding | status == "completed", non-empty result.output |
| After ingest with matching namespace | MemoryRetrieved in result.trace_events when Qdrant is up |
Trace check:
trace data policy: trace payloads include chunk counts and byte totals, not chunk text.
Next
Continue to the RAG track for ingest patterns, agent wiring, and hybrid retrieval tuning.