What You’ll Build
Four procurement documents — two vendor conversations, a purchase-history record, and the company’s procurement policies — go into cognee memory under three separate category labels. The agent then runs a research phase: nine questions, each answered only from the category that can answer it, so pricing questions never get answered from the policy file and rating questions never get answered from a sales pitch. The nine question-and-answer pairs are compiled into a single evidence block, and one final LLM call turns that block into a vendor recommendation justified by the research it just did. The complete runnable script isexamples/demos/agentic/agentic_reasoning_procurement_example.py —
this page walks through its key moments rather than reproducing it.
Features in Play
- NodeSets — labels each document with its memory category at write time, and scopes each recall to one category at read time
- Remember — ingests the four documents into three labeled slices of one graph
- Recall — answers each research question against a single category, via
node_name - Inspecting Graph Completion Context —
SearchType.GRAPH_COMPLETIONis the search type behind every research answer, grounding it in graph triplets - Low-Level LLM —
LLMGateway.acreate_structured_outputmakes the final vendor call from the compiled evidence, with no retrieval of its own
Before You Start
- Complete Quickstart to understand basic operations
- Ensure you have LLM Providers configured — the research phase and the final decision are both live LLM calls
- Use Ladybug or Neo4j as your graph store: node sets are only supported on those two backends. The script sets
GRAPH_DATABASE_PROVIDERtoladybugitself, before importing cognee, so no configuration is needed — but aGRAPH_DATABASE_PROVIDERin your environment will not win - Run it from a checkout of the cognee repo: it reads its four
.txtinputs from the siblingagentic_reasoning_procurement_example_data/folder, and loads your.envwithload_dotenv() - The script starts with
cognee.forget(everything=True), so point it at a scratch instance rather than memory you want to keep — see Forget
How It Works
Stage 1: Categorize Memory by Node Set
remember() calls write into one graph but tag their data with three different node sets: vendor_conversations, purchase_history, and procurement_policies. Those labels are what make the research phase possible — without them, a question about vendor ratings would retrieve sales-pitch text just as readily as the actual rating records.
Stage 2: Scope Every Recall to One Category
node_name restricts retrieval to the node set named by the category, so each answer is grounded in one memory layer only. SearchType.GRAPH_COMPLETION means the answer is generated from graph triplets rather than raw chunks, and top_k=30 gives each question a wide slice of that layer to reason over.
Stage 3: Write the Research Plan
Stage 4: Run the Research Loop
Stage 5: Compile the Evidence
Stage 6: Decide from the Compiled Evidence
Run It
Final Decision: section holding the recommended vendor and the reasoning behind it.
Adapting It to Your Data
The shape here generalizes to any research-then-decide agent: pick the categories your decision actually depends on, tag each source with a node set atremember() time, and write one small set of questions per category. Two rules keep it working — a question is only asked in the category that can answer it, and the deciding call sees the compiled notes rather than the raw documents. Swapping in your own vendors, policies, or history files means editing the data folder and the research_questions dictionary, not the loop around them.
NodeSets
How node-set labels are written and how
node_name filters retrieval by them.Recall
The retrieval operation behind every research question, and its other parameters.
Low-Level LLM
Calling
acreate_structured_output directly, including Pydantic response models.Inspecting Graph Completion Context
What
GRAPH_COMPLETION retrieves before an answer is generated.