Skip to main content
Your team is about to sign off on 50 laptops, and the evidence for that call is scattered across two vendor sales conversations, a file of past purchase records, and a procurement policy document. A procurement agent has to read all three, keep them straight, and justify whichever vendor it picks.

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 is examples/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 ContextSearchType.GRAPH_COMPLETION is the search type behind every research answer, grounding it in graph triplets
  • Low-Level LLMLLMGateway.acreate_structured_output makes the final vendor call from the compiled evidence, with no retrieval of its own

What to Expect

The excerpts below are from a real run, trimmed. Ingestion takes a few minutes before the first question prints, and because every answer and the final recommendation are live LLM calls, the wording varies from run to run. One formatting note: the script prints each recall result as a one-line ResponseGraphEntry(...) object; the answers below are shown with their line breaks restored so you can read them. Memory goes in first. The four procurement documents — two vendor conversations, the purchase history, and the policy sheet — are ingested and cognified into their node set categories before any question is asked.
Nine questions, each scoped to its category. Every recall names the category it should draw from, so vendor claims, past performance, and policy limits stay separable — the same pattern repeats across vendor_conversations, purchase_history, and procurement_policies.
The evidence is compiled. All nine Q/A pairs are folded into one research summary — this text, not the raw graph, is what the decision prompt sees.
One decision, justified from the evidence. The recommendation cites the price after discount, the delivery windows, policy compliance, and both vendors’ track records — including Office Solutions failing the minimum-rating requirement.

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_PROVIDER to ladybug itself, before importing cognee, so no configuration is needed — but a GRAPH_DATABASE_PROVIDER in your environment will not win
  • Run it from a checkout of the cognee repo: it reads its four .txt inputs from the sibling agentic_reasoning_procurement_example_data/ folder, and loads your .env with load_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

Three 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

The research plan is a dictionary keyed by category: three questions per memory layer, each one asked only where its answer lives. Offers and delivery estimates come from the vendor conversations, past performance from the purchase history, and the thresholds a vendor must clear from the policy document.

Stage 4: Run the Research Loop

Nine scoped recalls run in sequence, and the top answer of each is kept alongside the question that produced it. This is the agent’s research phase: it gathers its own evidence before anything decides anything, and every note carries the question that justifies its presence.

Stage 5: Compile the Evidence

The per-category notes are flattened into one plain-text block of Q/A pairs. Category boundaries mattered during retrieval — they are what kept each answer honest — but the decision step needs to weigh price against rating against policy, so the evidence is deliberately merged back together here.

Stage 6: Decide from the Compiled Evidence

One direct LLM call turns the compiled research into a recommendation. It does no retrieval of its own — the only facts it can cite are the ones the nine scoped recalls put in front of it, which is what makes the resulting justification traceable back to memory.

Run 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 at remember() 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.