03 Retrieval and agent wiring
Before you start
Complete 02 Ingest documents so namespace doc_qa (or your chosen id) contains at least one document. Qdrant must be running and ARCFLOW_QDRANT_URL exported.
Concept
Retrieval is automatic once an agent has vector memory config and the namespace holds embedded chunks. You do not call VectorStore.search inside the workflow for the default agent path; the runtime queries Qdrant during step execution and injects results into the prompt.
Wiring checklist:
- Ingest into namespace
NwithVectorStore.ingest(N, key, text). - Configure agent with
MemoryConfig(MemoryType.VECTOR,..., namespace=N, embedding=...). - Instruct the agent to use retrieved context (e.g. "Answer using retrieved context.").
- Run
workflow.run(user_question)and inspectresult.outputandresult.trace_events.
Trace event MemoryRetrieved confirms retrieval ran. Payload fields include chunk_count and total_bytes, not chunk text (trace data policy).
RAG chatbot walkthrough on the current branch shows steps 2 through 4; ingest is left as a comment. The restructure branch memory_guide_qa.py runs ingest and query in one main().
Example
End-to-end script combining ingest and query:
Run:
Compare with the split layout in document_qa.py (query only) versus memory_guide_qa.py (ingest file then query on restructure branch).
Verify
| Check | Expected |
|---|---|
result.status | "completed" |
result.output | Non-empty string |
MemoryRetrieved in trace kinds | Present when namespace populated and Qdrant reachable |
| Wrong namespace on agent | No retrieval hits; answer may ignore ingested facts |
Assertion used in Track C:
With a live LLM provider, answers should reference ingested facts. With stub provider, focus on trace presence and completed status.
Next
04 Hybrid retrieval intro explains dense versus hybrid mode and environment flags.